octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: embedded octave: how to define new functions?


From: Andrea Latina
Subject: Re: embedded octave: how to define new functions?
Date: Wed, 6 Sep 2006 00:44:23 +0200

Hi John,

thanks for your answer. I'm glad to see that you confirmed what, in
the meanwhile, I had already found looking at the code. Now I use the
scripts mkbuiltins and mkdefs in order to create my own builtins.cc
and I install my functions calling install_builtins().

So far everything works more than fine and I'm really eager to see my
simulation code working together with octave. Nevertheless I would
like to pose some other questions to the group, because I'm doubtful
about something. Here follow my questions:

As I didn't want to write any command line interface or a main's-argv
parsing routine (the octave's ones are ok and I actually need only to
extend the octave's instruction set with my own functions and data
structures, not more), I've thought of calling

int octave_main(argc, argv, embedded);

with embedded=0, i.e. "pretending" octave is not embedded, in order to
leave the control to octave itself and explot its solid interface
(after having installed my own functions, of course).

Here is the problem: this would be fine, if I only could call
my_install_builtins() at the "right" moment, which, as far as I
understamd, should be at some point in the octave_main() itself.
But... how can I do this?

How do you suggest to do?

The solution I've found is: I copied octave-main.cc into my project
dir and I've created my own version of the octave_main(). Which looks
exactly like the original, but calls my_install_builtins() right after
the original install_builtins() call.

This solution works correctly but I wonder if there is a better
solution to do that.

What would you think of putting some kind of hook, in the
octave_main() routine, in order to allow the users, in a situation
similar to mine, to call their own initialization functions, at the
right moment?

Thanks.

Regards,
Andrea

| I would like to embed octave into my code. I've used the canonical
| octave_embed.tgz example as a starting point. It compiles and works
| fine, but I've encountered a problem as soon as I've tried to define,
| with DEFUN(), my first new function.

You have to register them with the interpreter.  When Octave is built,
there is a script that scans the sources for DEFUN macros and builds
the file builtins.cc.  Look at that script and the generated file to
see what it is doing, and do that.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]