MCPcopy Create free account
hub / github.com/CytopiaTeam/Cytopia / ExcludeCode

Method ExcludeCode

external/as_add_on/scriptbuilder/scriptbuilder.cpp:783–822  ·  view source on GitHub ↗

Overwrite all code with blanks until the matching #endif

Source from the content-addressed store, hash-verified

781
782// Overwrite all code with blanks until the matching #endif
783int CScriptBuilder::ExcludeCode(int pos)
784{
785 asUINT len = 0;
786 int nested = 0;
787 while( pos < (int)modifiedScript.size() )
788 {
789 engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
790 if( modifiedScript[pos] == '#' )
791 {
792 modifiedScript[pos] = ' ';
793 pos++;
794
795 // Is it an #if or #endif directive?
796 engine->ParseToken(&modifiedScript[pos], modifiedScript.size() - pos, &len);
797 string token;
798 token.assign(&modifiedScript[pos], len);
799 OverwriteCode(pos, len);
800
801 if( token == "if" )
802 {
803 nested++;
804 }
805 else if( token == "endif" )
806 {
807 if( nested-- == 0 )
808 {
809 pos += len;
810 break;
811 }
812 }
813 }
814 else if( modifiedScript[pos] != '\n' )
815 {
816 OverwriteCode(pos, len);
817 }
818 pos += len;
819 }
820
821 return pos;
822}
823
824// Overwrite all characters except line breaks with blanks
825void CScriptBuilder::OverwriteCode(int start, int len)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected