#MP If 0 ;tombstone header Unimal helper for C-SLang 2.0. Helps produce C-SLang-compatible data for the dumbest non-compliant C compilers. (C) 2005 MacroExpressions.com Description: By the macro replacements defined here, Unimal is sent to loop between CSLang_ScriptStart and CSLang_ScriptEnd (a feat a C preprocessor cannot accomplish). In each loop iteration, Unimal picks up some things and ignores others. As a result, it emits data in the format even the dumbest C compilers should easily understand. The resulting data is not exactly the same as C-SLang would make with a compliant C compiler but it is equivalent, and C-SLang virtual machine understands it. Version control: $Date: 2004/08/07 $ $Change: 70 $ $Revision: #6 $ #MP Endif ;tombstone header #MP #MP #MP ;2 helper macros #MP Macro CSLang_RegStart_raw ;() static const cslbyte_t * const CSL_RegStartDummy3[]={ #MP Endm #MP Macro CSLang_RegEnd_raw ;() NULL}; static script_t *CSL_CONST CSL_RegStartDummy2 = (script_t *)&CSL_RegStartDummy3; #MP Endm #MP #MP #MP ;These two are needed to emit correctly comments placed outsidr functions #MP Macro CSLang_ForceEmit_start ;() #MP If pass == cslang_femit #MP Endm #MP Macro CSLang_ForceEmit_end ;() #MP Endif #MP Endm #MP #MP #MP ;Unimal replacement for Function() #MP Macro CSLang_Function ;(name) #MP Expand CSLang_ForceEmit_end() #MP If pass == cslang_fcount #define Foffset__#mp%s#1# #mp%ucslang_Fcount #MP Set cslang_Fcount = cslang_Fcount + 1 #MP Endif #MP If pass == cslang_autoreg #MP Ifdef cslang_reg_seen #MP ; nothing #MP Else #MP If cslang_Fcount1 == 0 #MP Expand CSLang_RegStart_raw() #MP Endif #mp%s#1#, /* automatically registered */ #MP If cslang_Fcount1+1 == cslang_Fcount #MP Expand CSLang_RegEnd_raw(); #MP Endif #MP Set cslang_Fcount1 = cslang_Fcount1 + 1 #MP Endif #MP Endif ;pass == cslang_autoreg #MP If pass == cslang_femit static const cslbyte_t #mp%s#1#[]={ #MP Endm #MP #MP #MP ;Unimal replacement for EndFunction() #MP Macro CSLang_EndFunction ;() RetNZP}; #MP Endif ;pass == cslang_femit #MP Expand CSLang_ForceEmit_start() #MP Endm #MP #MP #MP ;Unimal replacement for ScriptStart() #MP Macro CSLang_ScriptStart ;(name) #MP Set cslang_Fcount = 0 ; no functions yet #MP Set cslang_Fcount1 = 0 ; no functions yet #MP Set pass0 = 0 #MP Set cslang_fcount = pass0 #MP Set cslang_femit = cslang_fcount+1 #MP Set cslang_remit = cslang_femit+1 #MP Set cslang_autoreg = cslang_remit+1 #MP Set cslang_semit = cslang_autoreg+1 #MP Set pass1 = cslang_semit #MP For pass = pass0, pass1 #MP If pass == cslang_semit CSLscript_t #mp%s#1# = &CSL_RegStartDummy2; #MP Endif #MP If pass == cslang_femit #MP Endm #MP #MP #MP ;Unimal replacement for ScriptEnd() #MP Macro CSLang_ScriptEnd ;() #MP Expand CSLang_ForceEmit_end() #MP Endfor ;pass loop #MP ;Cleanup #MP Undef pass #MP Undef pass0 #MP Undef pass1 #MP Undef cslang_Fcount #MP Undef cslang_Fcount1 #MP Undef cslang_fcount #MP Undef cslang_femit #MP Undef cslang_remit #MP Undef cslang_autoreg #MP Undef cslang_semit #MP Endm #MP #MP #MP ;Unimal replacement for RegStart( #MP Macro CSLang_RegStart ;() #MP Expand CSLang_ForceEmit_end() #MP If pass == cslang_fcount #MP Set cslang_reg_seen = 1 ;just define it before functions are listed #MP Endif #MP If pass == cslang_remit #MP Expand CSLang_RegStart_raw() #MP Endm #MP #MP #MP ;Unimal replacement the ) of RegStart call (RegEnd) #MP Macro CSLang_RegEnd ;() #MP Expand CSLang_RegEnd_raw() #MP Endif #MP Expand CSLang_ForceEmit_start() #MP Endm #include "csldef.h" #include "cslpubl.h" /* Unimal production requires a different definition as follows: */ #undef Foffset #define Foffset(f) Foffset__##f #MP ;The end