Hi Steve and Dale!
Thank you very much for these elaborated explanations! Together with the rhinocommon code and the Moose example this should be a big help when writing the lisp interface! Maybe I even can reuse some of your efforts, for example the c wrappers for the C++ code.
ECL allows to embed C or C++ code directly into the lisp code. So it is possible to write, for example, a ‘make-cone’ function in lisp which contains the C++ code necessary for creating and manipulating the Rhino objects:
(defun make-cone (height radius b-cap-bottom)
(height radius b-cap-bottom) (:double :double :bool) :void
ON_Plane plane = ON_xy_plane;
double height = #0;
double radius = #1;
BOOL bCapBottom = #2;
const CRhinoCommandContext *context = RhinoLispContext::getRhinoCommandContext();
ON_Cone cone(plane, height, radius);
ON_Brep* cone_brep = ON_BrepCone(cone, bCapBottom);
CRhinoBrepObject* cone_object = new CRhinoBrepObject();
I would suppose that the method name together with its signature / type of the parameters and return type should be enough to select the right method? Why are there still problems with name mangling?
So if I understand right, there are three steps? First the C wrappers, than the C# code generated from the wrappers by methodgen, and finally the C# classes which are based on the generated C# wrappers? And while the second step is automated, the C wrappers as well as the final C# classes are hand-crafted? That sounds like lot or work! No wonder that the API is as nice as it is if you put this amount of effort into it! Thanks a lot for the good work
Concerning the access of the C++ code through pinvoke, is this necessary as well for the memory management? I had the impression that the C++ code itself dynamically manages its memory and that objects are garbage collected when not needed anymore? When I create, for example, some Rhino object in lisp and wrap the reference into a lisp object which immediatly after goes out of scope, do I have to care about the created Rhino object and its destruction myself?
There is still a lot to think about before writing my own wrappers. Should I base my interface on functions or classes? How to deal with the different constructors for Rhino objects? The best might be to just start with something and learn by experimenting with the different possibilities. So I probably will come back soon with more questions concerning your explanations
Thanks a lot,