Jump to content
  • Advertisement
Sign in to follow this  
Arthur Valitov

Preprocessing

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

Hello,

I have a few questions about possibility own built-in preprocessing to realize addition functionality.

1) I would like to add #define directive. How can I do this?
2) Is it possible to add some another preprocessor directives?
3) Is it possible to replace not-AS type to built-in type? For example from "unassigned int" to "uint".
4) Is it possible to re-declare arrays from AS-way to C-way. I mean using "int arr[5]" instead of "int[] arr(5)".

Thank you in advance. Edited by Apmyp

Share this post


Link to post
Share on other sites
Advertisement
1-2) One option might be ro run a C-style preprocessor on the source before giving it to AngelCode it.

You can usually configure a C or C++ compiler to stop after preprocessing and output the resulting files. You could also try a standalone preprocessor to avoid depending on a complex compiler suite.

Share this post


Link to post
Share on other sites
rip-off, thanks, i got idea, so will make my own preprocessing utility. Seems, that in the same way I can solve 3-4 questions.. But, hope AngelScript will be better with this functionality due avoiding to rewrite old C-sources in AS-syntax.

Share this post


Link to post
Share on other sites
I have no intention of mimicking C/C++ syntax in every aspect with the AngelScript language. I take ideas from a lot of different programming languages, C++ is obviously a major source, but it is not the only one, and not all aspects of C++ are well suited for a scripting language.

That said, I believe it should be relatively easy to automatically translate C/C++ code into AngelScript code. If you're planning on writing your own pre-processor, then perhaps the CScriptBuilder add-on may serve as a foundation. It does some basic preprocessing already, and I'm sure you can expand it to do what you desire.

Regards,
Andreas

Share this post


Link to post
Share on other sites
As my question is somewhat related, I might as well post it here...
My question is about possibility of using HLSL preprocessor with anglescript:

1. Is it possible to specify an absolute line number instead of offsets that AddScriptSection accepts?

2. Can AddScriptSection handle "broken" code, for example if the preprocessor produced the following code:

void FloatingEffect ( ref @ r ) {
Actor @ a = cast < Actor @ > ( r ) ;
#line 20
Base::Entity::LinearVelocityLayer @ vl = a . be . GetLinearVelocityLayer ( 1 ) ;
}

This would be handled in two AddScriptSection -calls, one containing code before the #line and one containing after.
Ideally this line-directive would come after some #included code, but unfortunately the HLSL preprocessor throws them all over the place.

I already tried this, but I'm getting "unexpected end of file" -errors so I suspect that AddScriptSection doesn't like incomplete code.
I could just add the whole script as one section, but then I couldn't take advantage of the line -directives and that would be a mess...
A doomed idea or any workarounds?

Share this post


Link to post
Share on other sites
Each script section must contain complete entities. Sections can refer to entities in other sections without a problem, but you cannot have half of a class or function in one section and the other half in another section.

There is currently no directive to adjust the line number like the above. It would be possible to enhance the CScriptBuilder to keep a translation table for line numbers, so that a line number reported by the script engine can be translated into the corresponding line number in the original code before the preprocessor ran.

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!