Skip to content
Snippets Groups Projects
Commit a848b860 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

fix isizefun in gmsh.h_cwrap

parent f1325a91
No related branches found
No related tags found
No related merge requests found
...@@ -738,7 +738,14 @@ def isizefun(name): ...@@ -738,7 +738,14 @@ def isizefun(name):
a.cpp = "std::function<double(int, int, double, double, double)> " + name a.cpp = "std::function<double(int, int, double, double, double)> " + name
a.c_arg = "std::bind(" + name + ", std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, " + name + "_data)" a.c_arg = "std::bind(" + name + ", std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, " + name + "_data)"
a.c = "double (*" + name + ")(int dim, int tag, double x, double y, double z, void * data), void * " + name + "_data" a.c = "double (*" + name + ")(int dim, int tag, double x, double y, double z, void * data), void * " + name + "_data"
a.cwrap_arg = a.c_arg a.cwrap_pre = "struct " + name + """_caller_ {
static double call(int entity_dim, int entity_tag, double x, double y, double z, void *callbackp) {
return (*static_cast<std::function<double(int,int,double,double,double)>*> (callbackp))(entity_dim, entity_tag, x, y, z);
}
};
auto *""" + name + "_ptr_ = new std::function<double(int,int,double,double,double)>("+name+""");
"""
a.cwrap_arg = "&" + name + "_caller_::call, "+name+"_ptr_"
a.python_pre = ("global api_" + name + "_type_\n" + a.python_pre = ("global api_" + name + "_type_\n" +
" api_" + name + "_type_ = " + " api_" + name + "_type_ = " +
"CFUNCTYPE(c_double, c_int, c_int, c_double, c_double, c_double)\n" + "CFUNCTYPE(c_double, c_int, c_int, c_double, c_double, c_double)\n" +
......
...@@ -1791,7 +1791,13 @@ namespace gmsh { // Top-level functions ...@@ -1791,7 +1791,13 @@ namespace gmsh { // Top-level functions
inline void setSizeCallback(std::function<double(int, int, double, double, double)> callback) inline void setSizeCallback(std::function<double(int, int, double, double, double)> callback)
{ {
int ierr = 0; int ierr = 0;
gmshModelMeshSetSizeCallback(std::bind(callback, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, callback_data), &ierr); struct callback_caller_ {
static double call(int entity_dim, int entity_tag, double x, double y, double z, void *callbackp) {
return (*static_cast<std::function<double(int,int,double,double,double)>*> (callbackp))(entity_dim, entity_tag, x, y, z);
}
};
auto *callback_ptr_ = new std::function<double(int,int,double,double,double)>(callback);
gmshModelMeshSetSizeCallback(&callback_caller_::call, callback_ptr_, &ierr);
if(ierr) throwLastError(); if(ierr) throwLastError();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment