Scripting a standalone application with haXe

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Scripting a standalone application with haXe

Simon TRENY
Hi,


I'd like to add the ability to script an existing application (a
game-engine) with haXe. But all the solutions I have seen so far
implies creating a separate .ndll file and using the neko.Lib.load()
function to import functions from the .ndll.

The thing is, since the application is already created and can't be
controlled by a separated library, I can't use a .ndll file. What I'd
like to do is to embed a Neko VM inside the application, and to
register some application's functions in the VM (as I would do with Lua
for example). Is there a way to do this?

I've seen that there is a NEKO_STANDALONE define that could maybe be
used for this, but I'm really not sure, and I don't see how this works
exactly.

Ultimately, I'd like to port the game-engine to PSP, but there is no
such things as dlopen() on PSP (afaik at least). So even if
NEKO_STANDALONE would work, I could not use it for the PSP version
because it still uses dlopen(), and there is no way to resolve symbols
in PSP executable. Would it be possible to import functions into the
Neko VM without having to use symbol-resolving?


Thanks for the great language :)
Simon

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Scripting a standalone application with haXe

Gamehaxe
Hi,
What you describe is very possible.
When you create the neko vm from inside your app, you can
set up anything you want - eg, set function pointers to
call back into your statically linked c code.
You can't use the DEFINE_PRIM though, you will have to do it
explicitly (or make some other kind of macro).

The "nekovm.org" site has more details, eg

http://nekovm.org/doc/vm#embedding_the_vm

Hugh

> Hi,
>
>
> I'd like to add the ability to script an existing application (a
> game-engine) with haXe. But all the solutions I have seen so far
> implies creating a separate .ndll file and using the neko.Lib.load()
> function to import functions from the .ndll.
>
> The thing is, since the application is already created and can't be
> controlled by a separated library, I can't use a .ndll file. What I'd
> like to do is to embed a Neko VM inside the application, and to
> register some application's functions in the VM (as I would do with Lua
> for example). Is there a way to do this?
>
> I've seen that there is a NEKO_STANDALONE define that could maybe be
> used for this, but I'm really not sure, and I don't see how this works
> exactly.
>
> Ultimately, I'd like to port the game-engine to PSP, but there is no
> such things as dlopen() on PSP (afaik at least). So even if
> NEKO_STANDALONE would work, I could not use it for the PSP version
> because it still uses dlopen(), and there is no way to resolve symbols
> in PSP executable. Would it be possible to import functions into the
> Neko VM without having to use symbol-resolving?
>
>
> Thanks for the great language :)
> Simon
>



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Scripting a standalone application with haXe

Nicolas Cannasse
In reply to this post by Simon TRENY
> Ultimately, I'd like to port the game-engine to PSP, but there is no
> such things as dlopen() on PSP (afaik at least). So even if
> NEKO_STANDALONE would work, I could not use it for the PSP version
> because it still uses dlopen(), and there is no way to resolve symbols
> in PSP executable. Would it be possible to import functions into the
> Neko VM without having to use symbol-resolving?

Yes it's possible, you'll only have to setup a function table and write
a custom loader that look into it and return the function pointer
depending on its name.

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Scripting a standalone application with haXe

Simon TRENY
On Sun, 09 Nov 2008 09:40:51 +0100,
Nicolas Cannasse <[hidden email]> wrote :

> > Ultimately, I'd like to port the game-engine to PSP, but there is no
> > such things as dlopen() on PSP (afaik at least). So even if
> > NEKO_STANDALONE would work, I could not use it for the PSP version
> > because it still uses dlopen(), and there is no way to resolve
> > symbols in PSP executable. Would it be possible to import functions
> > into the Neko VM without having to use symbol-resolving?
>
> Yes it's possible, you'll only have to setup a function table and
> write a custom loader that look into it and return the function
> pointer depending on its name.
>
> Best,
> Nicolas
>

Thanks, using a custom-loader works great! :)

Simon

--
haXe - an open source web programming language
http://haxe.org