Exporting a c++ function to scheme

Hi. How do I export a c++ function to scheme?

Look into src/Scheme/Glue you have to add it to one of the .scm files and then regenerate the corresponding glue code via running the script in that directory. When you recompile TeXmacs the function will be visible from Scheme.


Yes, but what do I put into the scheme file?
For example, in build-guile-editor.scm, we see the line that exports (I guess) defines the cursor-path symbol in scheme

(cursor-path the_path (path))

I deduced that (path) is the return type (if it was (void int) then it would mean that the function returns void and takes an int as parameter). But what does the_path mean in the above statement?

the_path is the C++ function that is called. It is defined in src/Edit/Editor/edit_main.cpp

1 Like

I see. How does it know that it needs to look in the class edit_main_rep? Do all c++ functions need to be methods of this class, if I want to export them to scheme?

EDIT: To me, it looks like they are called on the instance that is returned by get_current_editor() as hinted by the lines


There are three different glue files because they refer to different targets. basic is for global functions, server is for methods of the server object and editor are methods targeted to the current editor. Give a look at the generated .cpp files to see how these three different modes applies.

Looks like the build-glue script works only with guile 1.8.8 it only produces the copyright header when run with guile 3.0.8 that is what confused me.

If you just need to add a function you can also try to modify the .cpp files by hand.