Discussions about Coding and Scripting
- Posts: 1946
- Joined: Fri Sep 25, 2015 9:01 pm
- Location: moved without proper hashing
This example shows that a comment is not fully ignored by the compiler:
Code: Select all
/* class Prototype */
class Test extends Actor;
ucc.exe wrote:Error, Class must be named Prototype, not Test
Failed due to errors.
- Single line comment "//" works.
- Expanding the comment with other characters or white space leads to the same result.
- Defining the class before the comment works.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
- Posts: 134
- Joined: Mon Nov 24, 2014 9:27 am
This is because UClassFactoryUC is parsing the class name and default properties ahead of time.
As you can see in the code below, there is nothing that handles multiline comments.
It looks like multiline comments was added later on and they simply forgot, or were too lazy to add the code in the factory.
Code: Select all
// Get script text.
ScriptText.Logf( TEXT("%s\r\n"), *StrLine );
// Stub out the comments.
INT Pos = StrLine.InStr(TEXT("//"));
if( Pos>=0 )
StrLine = StrLine.Left( Pos );
// Get class name.
if( ClassName==TEXT("") && (Temp=appStrfind(Str, TEXT("class")))!=0 )
ParseToken( Temp, ClassName, 0 );
&& ((Temp=appStrfind(Str, TEXT("expands")))!=0 || (Temp=appStrfind(Str, TEXT("extends")))!=0) )
ParseToken( Temp, BaseClassName, 0 );
while( BaseClassName.Right(1)==TEXT(";") )
BaseClassName = BaseClassName.LeftChop( 1 );
- Posts: 4772
- Joined: Sun May 09, 2010 6:15 pm
- Location: On the roof.
Is this even a problem ? I think after compiling package normally I can load this package in Editor -> EditScript -> Writing two page of comments in top of script -> Save package with new script (without recompiling changes) - it's like stripping out code without to recompile anything. You can even replace entire code with some lousy things which nobody will compile later as long as the "TEXT" can be "encrypted" on purpose a bit later... I recommend opening some web page in whatever language "encrypted" by default and copy some news (or fake news) from there inside class... some "coders" will be surprised to see some "birdisch" programming language supported in UT
Note: These habits won't help UT development in any way.