Il 27/04/2013 14:11,
garthy...@entropicsoftware.com ha scritto:
> Hi,
>
> I've just started experimenting with embedding Falcon (I'm using
> 0.9.6.8- latest stable), under Debian Linux 6 (64-bit), and I've run
> into a few problems.
>
> Firstly, I'm trying to obtain a class from a loaded file. Using
> "findGlobalSymbol" and "findGlobalItem" doesn't find it, although
> using the main live module and "findModuleItem" does work. However, if
> I get this item, confirm it is callable, and attempt to call it
> ("callItem"), I get an immediate segfault. The docs suggest I should
> be able to call a class (and it presumbly creates an instance of it),
> and "isCallable()" suggests it should be callable, so I'm not quite
> sure what I am doing wrong.
>
The symbol you're searching is not global in the VM. To make it
VM-global, you have to add the "export" keyword to the module you're loaing.
Also, from your code, I see you launch the VM prior doing any of the
operations.
Launching the VM means running the __main__ function of the "main"
module, which is usually the last one loaded in the runtime. After the
launch returns, the VM will probably have Garbage-collected the entities
bound with the module symbols (hence, you find the symbol in the module,
but the associated object is destroyed, and calling or using it results
in a segfalut).
I didn't dig your code, but I suppose that, if you do all the operations
you're doing prior to VMachine::launch(), it should work.
If you see the Falcon.exe code or the Wopi-apache module code (great
source for embedding), you'll see launch() is done after configuring the
VM as desired. Of course, you don't have access to local variables prior
launch(); access to local variables is meant to be working while the
machine is running, from within the machine itself (i.e. from functions
called by your script).
It is also posible to just run specific functions via call(), without
ever invoking launch().
I'll try to help you out if you have further problems.