• Advertisement
Sign in to follow this  

JewelScript updated to v0.5.1.24

This topic is 4665 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My free, open source scripting language has been updated. Next to adding source code documentation for the most relevant functions (browsable online on my site, or downloadable), I have implemented a new two-pass compilation scheme. Source code sent to the library for compilation will now be compiled in two passes: The "pre-compile" pass will make sure that all classes, interfaces, methods, functions and member variables of all project files are properly declared; while the "compile" pass will then compile and generate the actual code. The result of this is that developers using JewelScript will no longer need to forward declare things in most cases. This makes using the language much easier. The only case left where you need to forward declare a type, is when you use that type in another declaration, for example:
class Date;
class Person
{
    Date m_Birthday; // need to forward 'Date' to declare member variable
}
Documentation, information and demos can be reviewed on my site: http://www.jewe.org Source-code distributions can be downloaded from sourceforge.net: http://sourceforge.net/projects/jilruntime Best, jewe

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by evolutional
Hey,

Can you show me some examples of how to bind this to native code? Or is the purpose of JewelScript to be more like Java?


Hello evolutional,

sorry to be so late to answer, I didn't notice someone actually asked a question! :o

For the purpose of JewelScript, I tried to be as "open" as possible. You can use it as a stand-alone language for developing applications, similar to Java, but it is also possible to embed the compiler and runtime into your C/C++ application (which is the main purpose I had in mind).

The binding to the native side can only be done using the API functions currently. Basically what you do is pushing all values onto the VM stack and then call a API function that executes the given script function. This should be quite similar to what you need to do in other script language APIs.
Here's an example code fragment:

// push the parameter array onto the virtual machine stack
JILPushHandleToStack(pMachine, hParameterArray);
// run function 'main'
err = JILRunStatic(pMachine, functionMain);
THROW( err, err, NULL )
// get the function result
hResult = JILGetResultHandle(pMachine);
// pop the parameter array from the stack
hParameterArray = JILPopHandleFromStack(pMachine);


For the moment, this may be sufficient, but of course it will become hell if you need to call lots of different functions with lots of arguments. Therefore, a "Binding Generator" for C++ is planned (and already specified) for the future (keep in mind that JewelScript is just at v0.5).

The tool will support both, code generation to call C++ functions from script, as well as calling script functions from C++.

EDIT: If you would like to take a closer look, I'd like to point you to my "JILRunOnly" project. This is a command line application that embeds the JILRuntime/JewelScript library and demonstrates how to call a script function, as well as how to write classes/functions in C/C++ and import them into JewelScript, in order to call them.

The JILRunOnly source code can be downloaded from here:
http://sourceforge.net/projects/jilruntime

More information can be found here:
http://www.jewe.org/jewelscript/

Cheers,
jewe

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement