compiler/libec; ecere: Support for checking platform as a compile time constant
[sdk] / compiler / bootstrap / ecc / bootstrap / ecc.c
index c23d05f..040722a 100644 (file)
@@ -1,4 +1,11 @@
 /* Code generated from eC source file: ecc.ec */
+#if defined(_WIN32)
+#define __runtimePlatform 1
+#elif defined(__APPLE__)
+#define __runtimePlatform 3
+#else
+#define __runtimePlatform 2
+#endif
 #if defined(__GNUC__)
 typedef long long int64;
 typedef unsigned long long uint64;
@@ -41,6 +48,8 @@ typedef unsigned __int64 uint64;
 #define structSize_Instance               (_64BIT ? 24 : 12)
 #define structSize_Module                 (_64BIT ? 560 : 300)
 
+struct __ecereNameSpace__ecere__com__Instance;
+
 extern void *  __ecereNameSpace__ecere__com__eSystem_New(unsigned int size);
 
 extern void *  __ecereNameSpace__ecere__com__eSystem_New0(unsigned int size);
@@ -650,8 +659,6 @@ __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(f, "   .\n");
 
 static struct __ecereNameSpace__ecere__com__Class * __ecereClass_CompilerApp;
 
-extern int __ecereNameSpace__ecere__com__GetRuntimePlatform(void);
-
 extern int GetHostBits(void);
 
 extern void SetSymbolsDir(const char *  s);
@@ -885,10 +892,10 @@ char * cppCommand = (((void *)0));
 char * cppOptions = (((void *)0));
 int cppOptionsLen = 0;
 int c;
-unsigned int valid = 0x1;
+unsigned int valid = 1;
 char defaultOutputFile[797];
-unsigned int buildingBootStrap = 0x0;
-int targetPlatform = __ecereNameSpace__ecere__com__GetRuntimePlatform();
+unsigned int buildingBootStrap = 0;
+int targetPlatform = __runtimePlatform;
 int targetBits = GetHostBits();
 
 SetSymbolsDir("");
@@ -925,11 +932,11 @@ cppOptionsLen = cppOptionsLen + 1 + strlen(buf);
 if(arg[1] == 'D')
 {
 if(!strcmp(arg, "-DBUILDING_ECERE_COM"))
-SetBuildingEcereCom(0x1);
+SetBuildingEcereCom(1);
 else if(!strcmp(arg, "-DECERE_COM_MODULE"))
-SetBuildingEcereComModule(0x1);
+SetBuildingEcereComModule(1);
 else if(!strcmp(arg, "-DECERE_BOOTSTRAP"))
-buildingBootStrap = 0x1;
+buildingBootStrap = 1;
 }
 }
 else if(!strcmp(arg + 1, "t"))
@@ -937,14 +944,14 @@ else if(!strcmp(arg + 1, "t"))
 if(++c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
 targetPlatform = __ecereProp___ecereNameSpace__ecere__com__Platform_Set_char__PTR_(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c]);
 else
-valid = 0x0;
+valid = 0;
 }
 else if(!strcmp(arg + 1, "cpp"))
 {
 if(++c < ((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argc)
 cppCommand = __ecereNameSpace__ecere__sys__CopyString(((struct __ecereNameSpace__ecere__com__Application *)(((char *)this + structSize_Module)))->argv[c]);
 else
-valid = 0x0;
+valid = 0;
 }
 else if(!strcmp(arg + 1, "o"))
 {
@@ -954,7 +961,7 @@ SetOutputFile(((struct __ecereNameSpace__ecere__com__Application *)(((char *)thi
 c++;
 }
 else
-valid = 0x0;
+valid = 0;
 }
 else if(!strcmp(arg + 1, "c"))
 {
@@ -964,7 +971,7 @@ SetSourceFile(((struct __ecereNameSpace__ecere__com__Application *)(((char *)thi
 c++;
 }
 else
-valid = 0x0;
+valid = 0;
 }
 else if(!strcmp(arg + 1, "isystem") || !strcmp(arg + 1, "isysroot"))
 {
@@ -983,7 +990,7 @@ buf = PassArg(buf, arg1);
 cppOptionsLen = buf - cppOptions;
 }
 else
-valid = 0x0;
+valid = 0;
 }
 else if(!strcmp(arg + 1, "fno-diagnostics-show-caret"))
 {
@@ -1004,7 +1011,7 @@ SetSymbolsDir(((struct __ecereNameSpace__ecere__com__Application *)(((char *)thi
 c++;
 }
 else
-valid = 0x0;
+valid = 0;
 }
 else if(!strcmp(arg + 1, "module"))
 {
@@ -1014,11 +1021,11 @@ SetI18nModuleName(((struct __ecereNameSpace__ecere__com__Application *)(((char *
 c++;
 }
 else
-valid = 0x0;
+valid = 0;
 }
 else if(!strcmp(arg + 1, "memguard"))
 {
-SetMemoryGuard(0x1);
+SetMemoryGuard(1);
 }
 else if(!strcmp(arg + 1, "defaultns"))
 {
@@ -1028,26 +1035,26 @@ SetDefaultNameSpace(((struct __ecereNameSpace__ecere__com__Application *)(((char
 c++;
 }
 else
-valid = 0x0;
+valid = 0;
 }
 else if(!strcmp(arg + 1, "strictns"))
 {
-SetStrictNameSpaces(0x1);
+SetStrictNameSpaces(1);
 }
 else if(!strcmp(arg + 1, "nolinenumbers"))
 {
-SetOutputLineNumbers(0x0);
+SetOutputLineNumbers(0);
 }
 }
 else
-valid = 0x0;
+valid = 0;
 }
 if(valid)
 {
 if(!cppCommand)
 cppCommand = __ecereNameSpace__ecere__sys__CopyString("gcc");
 if(!GetSourceFile())
-valid = 0x0;
+valid = 0;
 else if(!GetOutputFile())
 {
 strcpy(defaultOutputFile, "");
@@ -1072,58 +1079,58 @@ SetCurrentContext(globalContext);
 SetTopContext(globalContext);
 SetDefines(&defines);
 SetImports(&imports);
-SetInCompiler(0x1);
+SetInCompiler(1);
 SetTargetPlatform(targetPlatform);
 SetTargetBits(targetBits);
-SetEchoOn(0x0);
-privateModule = (struct __ecereNameSpace__ecere__com__Instance *)__ecereNameSpace__ecere__com____ecere_COM_Initialize((unsigned int)(0x1 | (targetBits == sizeof(uintptr_t) * 8 ? (unsigned int)0 : targetBits == 64 ? 2 : targetBits == 32 ? 4 : (unsigned int)0) | 8), 1, (((void *)0)));
+SetEchoOn(0);
+privateModule = (struct __ecereNameSpace__ecere__com__Instance *)__ecereNameSpace__ecere__com____ecere_COM_Initialize((unsigned int)(1 | (targetBits == sizeof(uintptr_t) * 8 ? (unsigned int)0 : targetBits == 64 ? 2 : targetBits == 32 ? 4 : (unsigned int)0) | 8), 1, (((void *)0)));
 SetPrivateModule(privateModule);
 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
 
-__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint"), __ecereInstance1->type = ProcessTypeString("unsigned int", 0x0), __ecereInstance1;
+__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint"), __ecereInstance1->type = ProcessTypeString("unsigned int", 0), __ecereInstance1;
 }));
 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
 
-__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint64"), __ecereInstance1->type = ProcessTypeString("unsigned int64", 0x0), __ecereInstance1;
+__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint64"), __ecereInstance1->type = ProcessTypeString("unsigned int64", 0), __ecereInstance1;
 }));
 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
 
-__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint32"), __ecereInstance1->type = ProcessTypeString("unsigned int", 0x0), __ecereInstance1;
+__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint32"), __ecereInstance1->type = ProcessTypeString("unsigned int", 0), __ecereInstance1;
 }));
 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
 
-__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint16"), __ecereInstance1->type = ProcessTypeString("unsigned short", 0x0), __ecereInstance1;
+__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uint16"), __ecereInstance1->type = ProcessTypeString("unsigned short", 0), __ecereInstance1;
 }));
 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
 
-__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("byte"), __ecereInstance1->type = ProcessTypeString("unsigned char", 0x0), __ecereInstance1;
+__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("byte"), __ecereInstance1->type = ProcessTypeString("unsigned char", 0), __ecereInstance1;
 }));
 if(buildingBootStrap)
 {
 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
 
-__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("intptr_t"), __ecereInstance1->type = ProcessTypeString("intptr", 0x0), __ecereInstance1;
+__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("intptr_t"), __ecereInstance1->type = ProcessTypeString("intptr", 0), __ecereInstance1;
 }));
 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
 
-__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uintptr_t"), __ecereInstance1->type = ProcessTypeString("uintptr", 0x0), __ecereInstance1;
+__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("uintptr_t"), __ecereInstance1->type = ProcessTypeString("uintptr", 0), __ecereInstance1;
 }));
 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
 
-__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("ssize_t"), __ecereInstance1->type = ProcessTypeString("intsize", 0x0), __ecereInstance1;
+__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("ssize_t"), __ecereInstance1->type = ProcessTypeString("intsize", 0), __ecereInstance1;
 }));
 __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalContext->types, (struct __ecereNameSpace__ecere__sys__BTNode *)__extension__ ({
 struct Symbol * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol);
 
-__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("size_t"), __ecereInstance1->type = ProcessTypeString("uintsize", 0x0), __ecereInstance1;
+__ecereInstance1->string = __ecereNameSpace__ecere__sys__CopyString("size_t"), __ecereInstance1->type = ProcessTypeString("uintsize", 0), __ecereInstance1;
 }));
 }
 {
@@ -1134,7 +1141,7 @@ __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Add(&globalData.functions
 }
 snprintf(command, sizeof (command), "%s%s -x c -E %s\"%s\"", cppCommand, cppOptions ? cppOptions : "", buildingBootStrap ? "" : "-include stdint.h -include sys/types.h ", GetSourceFile());
 command[sizeof (command) - 1] = (char)0;
-if((cppOutput = __ecereNameSpace__ecere__sys__DualPipeOpen((((unsigned int)(0x1))), command)))
+if((cppOutput = __ecereNameSpace__ecere__sys__DualPipeOpen((((unsigned int)(1))), command)))
 {
 char impFile[797];
 struct ImportedModule * module;
@@ -1192,7 +1199,7 @@ strcpy(symFile, sourceFileName);
 __ecereNameSpace__ecere__sys__ChangeExtension(symFile, "sym", symFile);
 strcpy(symLocation, GetSymbolsDir());
 __ecereNameSpace__ecere__sys__PathCat(symLocation, symFile);
-LoadSymbols(symLocation, 3, 0x0);
+LoadSymbols(symLocation, 3, 0);
 for(module = defines.first; module; module = next)
 {
 next = module->next;
@@ -1207,7 +1214,7 @@ __ecereNameSpace__ecere__com__eModule_LoadStrict(privateModule, "ecereCOM", 1);
 }
 ParseEc();
 CheckDataRedefinitions();
-SetYydebug(0x0);
+SetYydebug(0);
 SetCurrentNameSpace((((void *)0)));
 SetDefaultNameSpace((((void *)0)));
 SetDeclMode(2);
@@ -1238,6 +1245,13 @@ struct __ecereNameSpace__ecere__com__Instance * output = __ecereNameSpace__ecere
 if(output)
 {
 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "/* Code generated from eC source file: %s */\n", sourceFileName);
+__ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#if defined(_WIN32)\n");
+__ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __runtimePlatform 1\n");
+__ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#elif defined(__APPLE__)\n");
+__ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __runtimePlatform 3\n");
+__ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#else\n");
+__ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#define __runtimePlatform 2\n");
+__ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#endif\n");
 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "#if defined(__GNUC__)\n");
 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef long long int64;\n");
 __ecereMethod___ecereNameSpace__ecere__sys__File_Printf(output, "typedef unsigned long long uint64;\n");
@@ -1328,7 +1342,7 @@ extern struct __ecereNameSpace__ecere__com__Method * __ecereNameSpace__ecere__co
 
 void __ecereRegisterModule_ecc(struct __ecereNameSpace__ecere__com__Instance * module)
 {
-struct __ecereNameSpace__ecere__com__Class * class;
+struct __ecereNameSpace__ecere__com__Class __attribute__((unused)) * class;
 
 class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(0, "CompilerApp", "ecere::com::Application", 0, 0, 0, 0, module, 2, 1);
 if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application && class)