anglescript preprocor concatenation

Started by
7 comments, last by WitchLord 5 years, 1 month ago

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?

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.

 

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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.

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!

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?

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?

 

 

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Both. I'm modifying one app and creating a new one.

Is there a tutorial how to use c/c++ in a AS?

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.

 

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement