Private class-member variables act like C++'s protected?

Started by
23 comments, last by WitchLord 9 years, 3 months ago
If you're replacing the program that loads the scripts, you can do your search / replace during load time.
Advertisement

you can do your search / replace during load time

That's tricky.. stuff like


string foo = "this is private";

all of a sudden becomes


string foo = "this is protected";

? smile.png

It would have to be sensitive to the language rules, yes.

Is the string "private:" (with the colon) used in the script anywhere except in classes? If not, it's a simple find-and-replace.

The only thing you want to be careful of is making sure not the replace *new* scripts that are legitimately trying to use 'private' in the new way.

You can check the timestamp of the file when loading it, but I don't trust OS-given timestamps.

Instead, the easiest way would be to change your file extension. Any file loaded with ".as" extension (or whatever you used to use), automaticly replaces "private:" with "protected:" or "public:" (if protected isn't available). But from now on, new scripts can use ".as1" extension, or another extension of your choice.

This all happens seamlessly in your engine without having to hinder new scripts and without modifying old scripts.

The CScriptBuilder add-on can quite easily be modified to automatically change the private keyword for something else. It already has logic to parse scripts to identify class methods and properties (for use with metadata).

Since in your case you already know that the scripts work (i.e. you don't have to worry about scripts having compiler errors before the change) the solution would be to simply change the private keyword to blanks. The properties that are declared as private aren't accessed anyway, otherwise the script wouldn't compile successfully before.

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