MCPcopy Create free account
hub / github.com/anjo76/angelscript / ExcludeCode

Method ExcludeCode

sdk/add_on/scriptbuilder/scriptbuilder.cpp:846–885  ·  view source on GitHub ↗

Overwrite all code with blanks until the matching #endif

Source from the content-addressed store, hash-verified

844
845// Overwrite all code with blanks until the matching #endif
846int CScriptBuilder::ExcludeCode(int pos)
847{
848 asUINT len = 0;
849 int nested = 0;
850 while( pos < (int)modifiedScript.size() )
851 {
852 engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
853 if( modifiedScript[pos] == '#' )
854 {
855 modifiedScript[pos] = ' ';
856 pos++;
857
858 // Is it an #if or #endif directive?
859 engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
860 string token;
861 token.assign(&modifiedScript[pos], len);
862 OverwriteCode(pos, len);
863
864 if( token == "if" )
865 {
866 nested++;
867 }
868 else if( token == "endif" )
869 {
870 if( nested-- == 0 )
871 {
872 pos += len;
873 break;
874 }
875 }
876 }
877 else if( modifiedScript[pos] != '\n' )
878 {
879 OverwriteCode(pos, len);
880 }
881 pos += len;
882 }
883
884 return pos;
885}
886
887// Overwrite all characters except line breaks with blanks
888void CScriptBuilder::OverwriteCode(int start, int len)

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
ParseTokenMethod · 0.45

Tested by

no test coverage detected