7 #ifndef LLU_WSTP_RELEASE_H_
8 #define LLU_WSTP_RELEASE_H_
20 using Func = std::function<void(WSLINK, T*,
int)>;
22 ReleaseList() =
default;
23 ReleaseList(WSLINK m,
int l) : m(m), length(l) {}
25 void operator()(T* data) {
26 Release(m, data, length);
29 int getLength()
const {
42 using Func = std::function<void(WSLINK, T*,
int*,
char**,
int)>;
44 ReleaseArray() =
default;
45 ReleaseArray(WSLINK m,
int* d,
char** h,
int r) : m(m), dims(d), heads(h), rank(r) {}
47 void operator()(T* data) {
48 Release(m, data, dims, heads, rank);
51 int* getDims()
const {
55 char** getHeads()
const {
68 char** heads =
nullptr;
73 typename ReleaseArray<T>::Func ReleaseArray<T>::Release = [](WSLINK , T* ,
int* ,
char** ,
int ) {
74 static_assert(dependent_false_v<T>,
"Trying to use WS::ReleaseArray<T>::Release for unsupported type T");
78 typename ReleaseList<T>::Func ReleaseList<T>::Release = [](WSLINK , T* ,
int ) {
79 static_assert(dependent_false_v<T>,
"Trying to use WS::ReleaseList<T>::Release for unsupported type T");
85 #define WS_RELEASE_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(T) \
87 ReleaseArray<T>::Func ReleaseArray<T>::Release; \
89 ReleaseList<T>::Func ReleaseList<T>::Release;
91 WS_RELEASE_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(
unsigned char)
92 WS_RELEASE_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(
short)
93 WS_RELEASE_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(
int)
94 WS_RELEASE_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(wsint64)
95 WS_RELEASE_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(
float)
96 WS_RELEASE_DECLARE_SPECIALIZATIONS_OF_STATIC_MEMBERS(
double)
100 ReleaseArray<unsigned char>::Func ReleaseArray<unsigned char>::Release = WSReleaseInteger8Array;
103 ReleaseList<unsigned char>::Func ReleaseList<unsigned char>::Release = WSReleaseInteger8List;
106 ReleaseArray<short>::Func ReleaseArray<short>::Release = WSReleaseInteger16Array;
109 ReleaseList<short>::Func ReleaseList<short>::Release = WSReleaseInteger16List;
112 ReleaseArray<int>::Func ReleaseArray<int>::Release = WSReleaseInteger32Array;
115 ReleaseList<int>::Func ReleaseList<int>::Release = WSReleaseInteger32List;
118 ReleaseArray<wsint64>::Func ReleaseArray<wsint64>::Release = WSReleaseInteger64Array;
121 ReleaseList<wsint64>::Func ReleaseList<wsint64>::Release = WSReleaseInteger64List;
124 ReleaseArray<float>::Func ReleaseArray<float>::Release = WSReleaseReal32Array;
127 ReleaseList<float>::Func ReleaseList<float>::Release = WSReleaseReal32List;
130 ReleaseArray<double>::Func ReleaseArray<double>::Release = WSReleaseReal64Array;
133 ReleaseList<double>::Func ReleaseList<double>::Release = WSReleaseReal64List;