void* charDataHandle(const char* s) { DataHandle* h = new DataHandle; size_t len = strlen(s); char* d = (char*)malloc(len + 1); //strcpy_s(d, len + 1, s); strcpy(d, s); h->set((void*)d, 0, GRAB); return (void*)h; }
static void* parameterNotFound(const char* name, const char* file, int line) { DataHandle* handle = new DataHandle; std::string error = "parameter "; error += name; error += " not found"; ExecutionStatus status(error.c_str(), file, line); handle->set(0, &status); return (void*)handle; }
static void* unknownObject(const char* obj, const char* name, const char* file, int line) { DataHandle* handle = new DataHandle; std::string error = "unknown "; error += obj; error += " '"; error += name; error += "'"; ExecutionStatus status(error.c_str(), file, line); handle->set(0, &status); return (void*)handle; }
void* copyOfObjectHandle(void* ptr) { try { CAST_PTR(anObjectHandle, ptr_obj, ptr); return (void*)ptr_obj->copy(); } catch (LocalisedException& le) { ExecutionStatus status(le.what(), le.file(), le.line()); DataHandle* handle = new DataHandle; handle->set(0, &status); return (void*)handle; } }
void* cGT_norm(const void* ptr_x) { try { CAST_PTR(DataHandle, h_x, ptr_x); aDataContainer& x = objectFromHandle<aDataContainer>(h_x); double* result = (double*)malloc(sizeof(double)); *result = x.norm(); DataHandle* handle = new DataHandle; handle->set(result, 0, GRAB); return (void*)handle; } CATCH; }
void* cGT_dataItems(const void* ptr_x) { try { CAST_PTR(DataHandle, h_x, ptr_x); aDataContainer& x = objectFromHandle<aDataContainer>(h_x); int* result = (int*)malloc(sizeof(int)); *result = x.items(); DataHandle* handle = new DataHandle; handle->set(result, 0, GRAB); return (void*)handle; } CATCH; }
void* cGT_dot(const void* ptr_x, const void* ptr_y) { try { CAST_PTR(DataHandle, h_x, ptr_x); CAST_PTR(DataHandle, h_y, ptr_y); aDataContainer& x = objectFromHandle<aDataContainer>(h_x); aDataContainer& y = objectFromHandle<aDataContainer>(h_y); complex_double_t* result = (complex_double_t*)malloc(sizeof(complex_double_t)); *result = x.dot(y); DataHandle* handle = new DataHandle; handle->set(result, 0, GRAB); return (void*)handle; } CATCH; }