Jump to content
  • Advertisement
drsthammer

anglescript preprocor concatenation

Recommended Posts

I have to use anglescript in my work for non-game programming and I'm really missing the good-old C/C++ preprocessor. For example I have to write in some fixed name variables (registers) and they are different only by an index. In C/C++ I can save a huge amount of code lines and effort just by defining a macro like that

#define regname(idx) (reg_ ## idx)

Is this possible in anglescript and how?

Share this post


Link to post
Share on other sites
Advertisement

It's unfortunately not possible with the scriptbuilder add-on that comes with the SDK. However, it really depends on the application you use. The application could be using a different pre-processor which may add such capabilities.

 

Share this post


Link to post
Share on other sites

Thank you very much for your answer.

Is there a documentation about the SDK? How can the pre-processor be adapted (if it can at all) and how to use different pre-processor?

I must admit that I have experience in C/C++ and Java, but the anglescript is a completely new topic for me.. :(

Many thanks.

Share this post


Link to post
Share on other sites
Posted (edited)

There's some general purpose preprocessors out there that you can use instead of the pre-processor that comes with CScriptBuilder. You basically just have to modify the contents of the script you're passing to the builder.

I made a generic pre-processor myself, but unfortunately it does not support macros yet. (ccpp) I know there's also another pre-processor made by Anthony Casteel, but I don't know how well it works or if it has macros. (ScriptablePreprocessor)

You can also take a look at gpp, which only seems to do preprocessing as part of a binary (eg. you run gpp.exe on some file), but you might be able to tweak that into a library with some work. (Although, it seems LGPL'd, so it might not be the best solution.)

Good luck!

Edited by Miss

Share this post


Link to post
Share on other sites

Thank you very much for your answer!

I'm gonna really miss this feature of C/C++. It's very powerful and saves a lot of code. Of course there are pro and cons. But it saves really in some cases huge amount of code. Especially if you need to deal with registers. Unfortunately writing an own processor is unlikely an option since I don't have any experience in that... But is of course an interesting option thanks for all the references and the contribution.

Btw. if anyone knows for another way to build up variable names other than creating a new AS file from another script language like python, or changing the preprocessor would be also nice to know. Is it actually possible to call a C/C++ function from AS?

Share this post


Link to post
Share on other sites

You can find the AngelScript SDK on my site: angelcode.com/angelscript

Yes, AngelScript can call C/C++ functions. That is its sole purpose for existance. 😊 AngelScript is a programming library meant to be used by C/C++ to give scripting capabilities to the host application.

Are you creating your own application or are you just modifying an existing one?

 

 

Share this post


Link to post
Share on other sites

Manual: Your first script

SDK: Samples

Further resources: Community wiki (unfortunately not too active, but there is some useful content there)

The documentation is pretty detailed. And hopefully not too difficult to follow. I suggest you browse through it. 

I'll be happy to hear your feedback on how to improve the documentation/SDK even further if there is something it doesn't clearly explain.

 

Share this post


Link to post
Share on other sites

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!