Sign in to follow this  

some general questions

This topic is 4521 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

hi, I've got some general questions about angelscript: 1. can you load/save compiled versions of a script? if so, how? 2. are there any build in functions/classes or do you have to register every class/function yourself. 3. does it support unicode (the interface and the scripting language)? 4. if you register want to register a c++ class, do you also have to register all private members or is this or is this not possible/required/suggested? I've you don't understand what I mean, feel free to ask (I'm not a native english speaker -> german). I'm sorry if this information is in the documentation, I didn't find it. cu blueprogrammer

Share this post


Link to post
Share on other sites
1. Yes, look up SaveByteCode and LoadByteCode from here: http://www.angelcode.com/angelscript/sdk/docs/appmanual/pages/ref_engine.html

2. No, a std::string binding is given in a few ways and so is std::vector, the rest is up to you.

3. Not sure about unicode

4. You cannot to my knowledge register private data. You are only required to register an object type and any public methods you wish to expose. You do not have to register all public methods or properties, only those you wish. Also, if you wish to have a script instantiate these objects, you will need to register constructor/destructor. A templated example can be found here: http://www.gamedev.net/community/forums/topic.asp?topic_id=316064

Also, if you plan to use references, you need to register addref/release behaviours for the object.

Share this post


Link to post
Share on other sites
Hi blueprogrammer,

1. Yes, you can. Use the methods SaveByteCode()/LoadByteCode().
2. Not really, there are script structures, arrays, and the any type. But all other object types and functions has to be registered by the application, including the string type. Take a look at asCScriptString (in the add_on directory), for an idea on how types are registered.
3. Unicode is not yet supported.
4. You choose which members to register, the scripts will only be able to use the members you have registered. It is possible to register private members but not recommended, as they wouldn't be private if you did so. Again, look at the asCScriptString, for an idea on how types are registered.

Feel free to ask anything you want. The library documentation has most of the information, but I know that it may not always be easy to find all the necessary information. Once the library stabilizes some more, I'll work on fleshing out the documentation with better descriptive texts and not just an API reference.

Regards,
Andreas




Share this post


Link to post
Share on other sites
Guest Anonymous Poster
As for 3, you can always try to use utf8 instead of wide character unicode. As utf8 is compatible with ascii strings, there's a big chance it works without changes. To/from the scripting engine you can use MultiByteToWideChar and WideCharToMultiByte to convert to and from utf8.

Share this post


Link to post
Share on other sites
hi,

thanks for the fast replies.

to point 1:
I've got a question about your interface/code design: why do you use the class asIBinaryStream for SaveByteCode()/LoadByteCode(), but for AddScriptSection() you use a simple pointer to the data. Seems to me a little bit inconsistent. I would delete the asIBinaryStream (if it is only used in SaveByteCode()/LoadByteCode()) and use a simple pointer to an array with the data. I'm sorry if I missed something important here.

to point 4:
If you do not register the private members how does the script know the size of the object (when allocating memory and constructing the object)?

What are these code "sections" in AddScriptSection()? I didn't get the point. Are global/local data/funtions shared between "sections" or what is it used for?

cu blueprogrammer

Share this post


Link to post
Share on other sites
RainDog has a sort of IDE he's working on, but AFAIK it's rather domain-specific. You might be able to convince him to fork out a general purpose version.

Otherwise, you can edit angelscript in Visual Studio or whatever IDE you use. Just give your scripts an extension it knows how to parse. I use .c myself. You can even get intellisense. In every angelscript file, I include a header called 'vsintellisense' that includes declarations of everything bound to the script. It's setup to preprocess to an empty file when compiling in angelscript. Of course that requires using a preprocessor with angelscript.

Share this post


Link to post
Share on other sites
1. I hadn't really thought about it before. The initial support for saving/loading bytecode wasn't implemented by me, so I kind of accepted the contribution as it was without changing it.

I'll give it some more thought. Maybe I'll do some changes. Thanks for pointing that out to me.

4. The size of the object is known from RegisterObjectType() where the second parameter is the size of the object, you should use the sizeof(type) operator to determine this value. For most classes you should also register a constructor, which will do the initialization of the members, so the script library doesn't have to know about them.

You can think of script sections as separate files. But all script sections added to the same module share the same scope, so functions/variables/types declared in one section is available in the other ones as well. All declarations are order independent, so you don't have to register the sections in any specific order.

To the library, it doesn't make a difference if you add two sections or if you first concatenate them and add them as one unique section. However, error messages report the script section name, so that can be used to make it easier to find the origin of the error.

Share this post


Link to post
Share on other sites

This topic is 4521 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this