dao
dao copied to clipboard
[Embedding] Use structs/classes for Dao + C/C++
Hello! I wanted to know how I could use structs/classes in my program. What I want to do is to create a struct usable by Dao in my program (with functions), send it to Dao, use it in the Dao script, which will transform it and finally send the transformed struct back to the C code (which I will then use).
Here is the version with arrows: create struct in program for Dao -> send it to Dao -> use it in Dao -> return it to program -> use it in program
Thanks!
Short answer: bind you struct/class to Dao using the provided C API. Consult modules on how to do that. The API is not documented, but it's mostly self-explaining, and you may always ask for help here.
Ok. Thank you! What is CData? EDIT: How can I send a class to Dao?
CData is basically a wrapped (C-defined) type/class. In order to use your class in Dao you need to wrap it, registering it as Dao type. It involves defining a DaoTypeBase typer and adding it to certain namespace via DaoNamespace_WrapType(). Then, for example, you can create a Dao routine accepting instance of the corresponding class and call it from C code, passing in the data you want it to process in wrapped form.
Some relevant info is available here.
OK. Thank you :)