3 // UNTIL IMPLEMENTED IN GRAMMAR
4 #define ACCESS_CLASSDATA(_class, baseClass) \
5 (_class ? ((void *)(((char *)_class.data) + baseClass.offsetClass)) : null)
7 #define YYLTYPE Location
10 static Statement registerModuleBody;
11 static External registerModuleExternal;
12 static Statement unregisterModuleBody;
13 static External unregisterModuleExternal;
15 extern int propWatcherID;
17 bool buildingECERECOM = false;
18 public void SetBuildingEcereCom(bool b) { buildingECERECOM = b; } public bool GetBuildingEcereCom() { return buildingECERECOM; }
19 bool buildingECERECOMModule = false;
20 public void SetBuildingEcereComModule(bool b) { buildingECERECOMModule = b; } public bool GetBuildingEcereComModule() { return buildingECERECOMModule; }
22 // This will also be called by the instance processer to make the instance methods... (pass 1.5)
23 External ProcessClassFunction(Class owningClass, ClassFunction func, OldList defs, External after, bool makeStatic)
25 Identifier id = GetDeclId(func.declarator);
28 External external = null;
30 if(defs && func.declarator)
32 FunctionDefinition function = null;
34 int symid = func.declarator.symbol.id;
35 int symidCode = func.declarator.symbol.idCode;
40 func.specifiers = MkList();
41 // Add static to the specifiers
43 func.specifiers->Insert(null, MkSpecifier(STATIC));
46 propSymbol = func.declarator.symbol;
48 ReplaceThisClassSpecifiers(func.specifiers, owningClass);
50 if(propSymbol.externalGet == (External)func)
51 func.declarator.symbol = null;
52 else if(propSymbol.externalSet == (External)func)
54 func.declarator.symbol = null;
57 else if(propSymbol.externalIsSet == (External)func)
59 func.declarator.symbol = null;
60 symid += 2; // TOFIX: What should we do with this? Where are 2 IDs allocated for properties? In MkProperty...
65 /*FunctionDefinition*/ function = _MkFunction(func.specifiers, func.declarator, null, false);
66 function.propSet = func.propSet;
67 function.type = func.type;
68 if(func.type) func.type.refCount++;
69 ProcessFunctionBody(function, func.body);
70 external = MkExternalFunction(function);
72 external.symbol = func.declarator.symbol;
73 external.function._class = func._class;
76 symbol = func.declarator.symbol;
77 //symbol.id = func.id; //symid;
79 symbol.idCode = symidCode;
84 Method method = func.declarator.symbol.method;
85 func.declarator.symbol.methodExternal = external;
87 // DANGER: Added this one...
89 if(method && method.symbol)
90 //((Symbol)method.symbol).methodExternal = external;
91 ((Symbol)method.symbol).methodCodeExternal = external;
93 if(method && method.type == virtualMethod)
96 ProcessMethodType(method);
98 methodDataType = method.dataType;
100 // Do type checking here of type against method.dataType
101 // ThisClass must be the owning class for types not specified, static for static, or inherit from method's ThisClass is specified
102 // If not specified, defaults to ThisClass if ThisClass specified in method, otherwise overiding class or static
106 if(!type.staticMethod && !type.thisClass && !type.thisClassTemplate)
108 if(method.dataType.thisClassTemplate)
110 if(owningClass.templateArgs)
112 ClassTemplateArgument * arg = FindTemplateArg(owningClass, method.dataType.thisClassTemplate);
113 type.byReference = method.dataType.byReference;
115 methodDataType = ProcessTypeString(method.dataTypeString, false);
116 type.thisClass = methodDataType.thisClass = arg ? FindClass(arg->dataTypeString) : null;
119 else if(method.dataType.staticMethod)
120 type.staticMethod = true;
121 else if(method.dataType.thisClass)
123 type.thisClass = method.dataType.thisClass;
124 type.byReference = method.dataType.byReference;
128 if(!owningClass.symbol)
129 owningClass.symbol = FindClass(owningClass.fullName);
131 type.thisClass = owningClass.symbol;
132 // WORKING ON THIS TO SUPPORT : pass.NotifyClicked(this, pass, 0, 0, key.modifiers);
133 type.extraParam = true;
138 if(!MatchTypes(type, methodDataType, null, owningClass, method._class /*owningClass*/, true, true, true, false))
141 // MatchTypes(type, methodDataType, null, owningClass, owningClass, true, true, true, false);
143 Compiler_Error($"Incompatible virtual function %s\n", method.name);
147 // Mark typed_object/any_object parameters as such according to method type
149 Declarator funcDecl = GetFuncDecl(func.declarator);
150 if(funcDecl.function.parameters)
152 TypeName param = funcDecl.function.parameters->first;
154 for(typeParam = methodDataType.params.first; typeParam; typeParam = typeParam.next)
156 if(typeParam.classObjectType)
158 param.classObjectType = typeParam.classObjectType;
159 if(param.declarator && param.declarator.symbol)
160 param.declarator.symbol.type.classObjectType = typeParam.classObjectType;
166 if(methodDataType != method.dataType)
167 FreeType(methodDataType);
172 if(!type.staticMethod && !type.thisClass)
174 if(owningClass && !owningClass.symbol)
175 owningClass.symbol = FindClass(owningClass.fullName);
177 type.thisClass = owningClass ? FindClass(owningClass.fullName) : null;
183 // TESTING THIS HERE: (Implementing Class Properties)
184 if(symbol.type && !symbol.type.staticMethod && !symbol.type.thisClass)
186 if(!owningClass.symbol)
187 owningClass.symbol = FindClass(owningClass.fullName);
188 symbol.type.thisClass = owningClass.symbol;
191 // Those type of classes don't need a this parameter for Set methods, null thisClass before changing the externals
192 if(propSymbol.externalSet == (External)func && propSymbol._property && propSymbol._property.conversion)
194 if(symbol.type.thisClass && symbol.type.classObjectType != classPointer)
196 // TODO: Perhaps improve this so as to support both "this =" and "return " syntax for all types of classes
197 if(owningClass.type != structClass)
198 //function.propertyNoThis = true;
199 symbol.type.thisClass = null;
204 if(propSymbol.externalGet == (External)func)
206 propSymbol.externalGet = external;
208 else if(propSymbol.externalSet == (External)func)
210 propSymbol.externalSet = external;
212 else if(propSymbol.externalIsSet == (External)func)
214 propSymbol.externalIsSet = external;
218 // Constructor destructor
219 //symbol.type = Type { };
226 func.declarator = null;
227 func.specifiers = null;
230 defs.Insert(after, external);
234 Method method = func.declarator.symbol.method;
235 if(method && method.symbol)
236 ((Symbol)method.symbol).methodCodeExternal = null;
238 //external.function = null;
239 func.declarator = null;
240 func.specifiers = null;
242 FreeExternal(external); // Free external here?
247 globalContext /*curContext*/.symbols.Remove((BTNode)symbol);
248 excludedSymbols->Add(symbol);
251 defs.Insert(after, external);
253 external.function.declarator = CopyDeclarator(external.function.declarator);
254 external.function.specifiers = CopyList(external.function.specifiers, CopySpecifier);
255 external.function.body = null;
261 void CreateRegisterModuleBody()
263 if(!registerModuleBody && inCompiler)
265 char registerName[1024], moduleName[MAX_FILENAME];
266 OldList * specifiers;
267 Declarator declarator;
268 TypeName moduleParam;
270 registerModuleBody = MkCompoundStmt(MkList(), MkList());
271 registerModuleBody.compound.context = Context { parent = globalContext };
274 ListAdd(registerModuleBody.compound.declarations,
275 MkDeclaration(MkListOne(MkStructOrUnion(structSpecifier, MkIdentifier("__ecereNameSpace__ecere__com__Class"), null) /*MkSpecifierName("ecere::com::Class")*/ /*MkStructOrUnion(SpecifierStruct, MkIdentifier("Class"), null)*/),
276 MkListOne(MkInitDeclarator(MkDeclaratorPointer(MkPointer(null,null), MkDeclaratorIdentifier(MkIdentifier("class"))), null))));
278 ListAdd(registerModuleBody.compound.declarations,
279 MkDeclaration(MkListOne(MkSpecifierName("ecere::com::Class")),
280 MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("class")), null))));
282 specifiers = MkList();
283 ListAdd(specifiers, MkSpecifier(VOID));
285 moduleParam = MkTypeName(MkListOne(/*MkSpecifier(VOID)*/MkSpecifierName("Module")),
286 //MkDeclaratorPointer(MkPointer(null, null),
287 MkDeclaratorIdentifier(MkIdentifier("module")));
289 GetLastDirectory(outputFile, moduleName);
290 //strcpy(moduleName, argv[2]);
291 StripExtension(moduleName);
292 FixModuleName(moduleName);
293 sprintf(registerName, "__ecereRegisterModule_%s", moduleName);
295 declarator = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(registerName)),
296 MkListOne(moduleParam));
299 FunctionDefinition function = _MkFunction(specifiers, declarator, null, false);
300 ProcessFunctionBody(function, registerModuleBody);
301 function.declMode = defaultAccess;
302 if(!ast) ast = MkList();
303 ListAdd(ast, (registerModuleExternal = MkExternalFunction(function)));
308 if(!unregisterModuleBody && inCompiler)
310 char registerName[1024], moduleName[MAX_FILENAME];
311 OldList * specifiers;
312 Declarator declarator;
313 TypeName moduleParam;
315 unregisterModuleBody = MkCompoundStmt(MkList(), MkList());
316 unregisterModuleBody.compound.context = Context { parent = globalContext };
318 specifiers = MkList();
319 ListAdd(specifiers, MkSpecifier(VOID));
321 moduleParam = MkTypeName(MkListOne(/*MkSpecifier(VOID)*/ MkSpecifierName("Module")),
322 //MkDeclaratorPointer(MkPointer(null, null),
323 MkDeclaratorIdentifier(MkIdentifier("module")));
325 GetLastDirectory(outputFile, moduleName);
326 StripExtension(moduleName);
327 FixModuleName(moduleName);
328 //strcpy(moduleName, argv[2]);
329 sprintf(registerName, "__ecereUnregisterModule_%s", moduleName);
331 declarator = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(registerName)),
332 MkListOne(moduleParam));
335 FunctionDefinition function = _MkFunction(specifiers, declarator, null, false);
336 ProcessFunctionBody(function, unregisterModuleBody);
337 function.declMode = defaultAccess;
338 if(!ast) ast = MkList();
339 ListAdd(ast, (unregisterModuleExternal = MkExternalFunction(function)));
344 void RegisterMembersAndProperties(Class regClass, bool isMember, char * className, Statement statement)
346 DataMember dataMember = isMember ? (DataMember)regClass : null;
351 char dataMemberSize[16];
355 bool privateMembers = false;
357 sprintf(dataMemberSize, "%d", (int)sizeof(DataMember));
360 for(prop = regClass.conversions.first; prop; prop = prop.next)
362 OldList * args = MkList();
366 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
368 ListAdd(args, MkExpConstant("0"));
372 char * string = QMkString(prop.dataTypeString);
373 ListAdd(args, MkExpString(string));
379 strcpy(name, "__ecereProp_");
380 FullClassNameCat(name, regClass.fullName, false);
381 strcat(name, "_Set_");
382 // strcat(name, prop.name);
383 FullClassNameCat(name, prop.name, true);
384 MangleClassName(name);
385 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
388 ListAdd(args, MkExpConstant("0"));
392 strcpy(name, "__ecereProp_");
393 FullClassNameCat(name, regClass.fullName, false);
394 strcat(name, "_Get_");
395 // strcat(name, prop.name);
396 FullClassNameCat(name, prop.name, true);
397 MangleClassName(name);
399 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
402 ListAdd(args, MkExpConstant("0"));
406 switch(prop.memberAccess)
409 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
412 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
416 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
420 strcpy(name, "__ecereProp_");
421 FullClassNameCat(name, regClass.fullName, false);
423 FullClassNameCat(name, prop.name, true);
424 // strcat(name, prop.name);
425 MangleClassName(name);
427 stmt = MkExpressionStmt(MkListOne(
428 MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=',
429 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args))));
430 ListAdd(registerModuleBody.compound.statements, stmt);
434 for(member = isMember ? dataMember.members.first : regClass.membersAndProperties.first; member; member = member.next)
436 if(member.isProperty)
438 prop = (Property) member;
440 OldList * args = MkList();
441 char name[1024], nameM[1024];
442 char * string = QMkString(prop.name);
445 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
448 ListAdd(args, MkExpString(string));
453 char * string = QMkString(prop.dataTypeString);
454 ListAdd(args, MkExpString(string));
460 strcpy(name, "__ecereProp_");
461 FullClassNameCat(name, regClass.fullName, false);
462 strcat(name, "_Set_");
463 FullClassNameCat(name, prop.name, true);
464 // strcat(name, prop.name);
465 MangleClassName(name);
466 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
469 ListAdd(args, MkExpConstant("0"));
473 strcpy(name, "__ecereProp_");
474 FullClassNameCat(name, regClass.fullName, false);
475 strcat(name, "_Get_");
476 FullClassNameCat(name, prop.name, true);
477 // strcat(name, prop.name);
478 MangleClassName(name);
479 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
482 ListAdd(args, MkExpConstant("0"));
485 switch(prop.memberAccess)
488 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
491 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
495 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
499 strcpy(name, "__ecereProp_");
500 FullClassNameCat(name, regClass.fullName, false);
502 FullClassNameCat(name, prop.name, true);
503 // strcat(name, prop.name);
504 MangleClassName(name);
506 strcpy(nameM, "__ecerePropM_");
507 FullClassNameCat(nameM, regClass.fullName, false);
509 FullClassNameCat(nameM, prop.name, true);
510 // strcat(nameM, prop.name);
511 MangleClassName(nameM);
513 if(prop.dataTypeString)
515 stmt = MkExpressionStmt(MkListOne(
516 MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=',
517 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args))));
521 stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args)));
523 ListAdd(registerModuleBody.compound.statements, stmt);
528 strcpy(name, "__ecereProp_");
529 FullClassNameCat(name, regClass.fullName, true);
530 strcat(name, "_IsSet_");
531 FullClassNameCat(name, prop.name, false);
532 // strcat(name, prop.name);
533 MangleClassName(name);
535 stmt = MkExpressionStmt(MkListOne(
536 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier(nameM)), MkIdentifier("IsSet")), '=',
537 MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpIdentifier(MkIdentifier(name))))));
538 ListAdd(registerModuleBody.compound.statements, stmt);
540 if(prop.symbol && ((Symbol)prop.symbol).propCategory)
542 stmt = MkExpressionStmt(MkListOne(
543 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier(nameM)), MkIdentifier("category")), '=',
544 CopyExpression(((Symbol)prop.symbol).propCategory))));
545 ListAdd(registerModuleBody.compound.statements, stmt);
548 if(prop.dataTypeString)
550 OldList * list = MkList();
551 ListAdd(list, MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=', MkExpIdentifier(MkIdentifier(nameM))));
552 ListAdd(list, MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=', MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpConstant("0"))));
553 // stmt = MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(name)))), MkExpressionStmt(list), null);
554 stmt = MkIfStmt(MkListOne(MkExpOp(
555 MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP,
556 MkExpMember(MkExpIdentifier(MkIdentifier("__thisModule")), MkIdentifier("application")))), MkExpressionStmt(list), null);
558 ListAdd(registerModuleBody.compound.statements, stmt);
560 // Unregister 2nd property
561 stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=',
562 MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpConstant("0")))));
563 ListAdd(unregisterModuleBody.compound.statements, stmt);
567 else if(member.type == normalMember && !isMember && regClass.type == bitClass)
569 BitMember bitMember = (BitMember) member;
570 OldList * args = MkList();
573 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
577 char * string = QMkString(bitMember.name);
578 ListAdd(args, MkExpString(string));
583 char * string = QMkString(bitMember.dataTypeString);
584 ListAdd(args, MkExpString(string));
590 sprintf(string, "%d", bitMember.size);
591 ListAdd(args, (exp = MkExpConstant(string)));
596 sprintf(string, "%d", bitMember.pos);
597 ListAdd(args, (exp = MkExpConstant(string)));
601 switch(member.memberAccess)
604 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
607 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
611 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
615 stmt = MkExpressionStmt(MkListOne(
616 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddBitMember")), args)));
618 ListAdd(statement.compound.statements, stmt);
620 else if(member.memberAccess == publicAccess || (member.type == normalMember && !member.dataTypeString))
623 // ADD PRIVATE DATA PADDING HERE...
626 uint offset = member.offset - lastOffset;
631 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
636 sprintf(string, "\"__ecerePrivateData%d\"", privateID++);
637 ListAdd(args, MkExpString(string));
642 sprintf(string, "\"byte[%d]\"", offset);
643 ListAdd(args, MkExpString(string));
648 sprintf(string, "%d", offset);
649 ListAdd(args, (exp = MkExpConstant(string)));
653 ListAdd(args, (exp = MkExpConstant("1")));
656 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
658 stmt = MkExpressionStmt(MkListOne(
659 MkExpCall(MkExpIdentifier(MkIdentifier(isMember ? "eMember_AddDataMember" : "eClass_AddDataMember")), args)));
661 ListAdd(statement.compound.statements, stmt);
662 privateMembers = false;
665 if(member.type == normalMember)
668 member.dataType = ProcessTypeString(member.dataTypeString, false);
670 ComputeTypeSize(member.dataType);
675 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
679 char * string = QMkString(member.name);
680 ListAdd(args, MkExpString(string));
685 char * string = QMkString(member.dataTypeString);
686 ListAdd(args, MkExpString(string));
692 sprintf(string, "%d", member.dataType.size);
693 ListAdd(args, (exp = MkExpConstant(string)));
699 sprintf(string, "%d", member.dataType.alignment);
700 ListAdd(args, (exp = MkExpConstant(string)));
704 switch(member.memberAccess)
707 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
710 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
714 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
718 stmt = MkExpressionStmt(MkListOne(
719 MkExpCall(MkExpIdentifier(MkIdentifier(isMember ? "eMember_AddDataMember" : "eClass_AddDataMember")), args)));
721 ListAdd(statement.compound.statements, stmt);
723 lastOffset = member.offset + member.dataType.size;
727 static int memberCount = 0;
731 char memberName[256];
732 sprintf(memberName, "dataMember%d", memberCount);
735 curContext = statement.compound.context;
736 context = PushContext();
738 args = MkListOne(MkExpIdentifier(MkIdentifier((member.type == unionMember) ? "unionMember" : "structMember")));
741 switch(member.memberAccess)
744 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
747 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
751 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
755 compound = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("DataMember")),
756 MkListOne(MkInitDeclarator(/*MkDeclaratorPointer(MkPointer(null, null), */MkDeclaratorIdentifier(MkIdentifier(memberName))/*)*/,
757 MkInitializerAssignment(MkExpCall(MkExpIdentifier(MkIdentifier("eMember_New")), args)))))), MkList());
758 compound.compound.context = context;
762 // Class class / DataMember member
763 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
765 // DataMember dataMember
766 ListAdd(args, MkExpIdentifier(MkIdentifier(memberName)));
768 RegisterMembersAndProperties((Class)member, true, memberName, compound);
771 stmt = MkExpressionStmt(MkListOne(
772 MkExpCall(MkExpIdentifier(MkIdentifier("eMember_AddMember")), args)));
774 stmt = MkExpressionStmt(MkListOne(
775 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMember")), args)));
777 ListAdd(compound.compound.statements, stmt);
781 ListAdd(statement.compound.statements, compound);
785 lastOffset = member.offset + member.memberOffset;
789 privateMembers = true;
794 ClassProperty classProperty;
796 // Watchable properties
797 for(prop = regClass.membersAndProperties.first; prop; prop = prop.next)
799 if(prop.isProperty && prop.isWatchable)
802 char name[1024], nameM[1024];
804 strcpy(name, "__ecereProp_");
805 FullClassNameCat(name, regClass.fullName, true);
807 FullClassNameCat(name, prop.name, false);
808 // strcat(name, prop.name);
809 MangleClassName(name);
811 strcpy(nameM, "__ecerePropM_");
812 FullClassNameCat(nameM, regClass.fullName, true);
814 FullClassNameCat(nameM, prop.name, false);
815 // strcat(nameM, prop.name);
816 MangleClassName(nameM);
818 args = MkListOne(MkExpCondition(MkExpIdentifier(MkIdentifier(nameM)), MkListOne(MkExpIdentifier(MkIdentifier(nameM))), MkExpIdentifier(MkIdentifier(name))));
819 stmt = MkExpressionStmt(MkListOne(
820 MkExpCall(MkExpIdentifier(MkIdentifier("eProperty_Watchable")), args)));
821 ListAdd(registerModuleBody.compound.statements, stmt);
825 // Add Class Properties
826 for(classProperty = (ClassProperty)regClass.classProperties.first; classProperty; classProperty = (ClassProperty)((BTNode)classProperty).next)
828 OldList * args = MkList();
830 char * string = QMkString(classProperty.name);
833 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
836 ListAdd(args, MkExpString(string));
841 char * string = QMkString(classProperty.dataTypeString);
842 ListAdd(args, MkExpString(string));
846 if(classProperty.Set)
848 strcpy(name, "__ecereClassProp_");
849 FullClassNameCat(name, regClass.fullName, true);
850 strcat(name, "_Set_");
851 strcat(name, classProperty.name);
852 MangleClassName(name);
853 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
856 ListAdd(args, MkExpConstant("0"));
858 if(classProperty.Get)
860 strcpy(name, "__ecereClassProp_");
861 FullClassNameCat(name, regClass.fullName, true);
862 strcat(name, "_Get_");
863 strcat(name, classProperty.name);
864 MangleClassName(name);
866 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
869 ListAdd(args, MkExpConstant("0"));
871 stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddClassProperty")), args)));
872 ListAdd(registerModuleBody.compound.statements, stmt);
877 extern External curExternal;
879 void GetNameSpaceString(NameSpace ns, char * string)
882 GetNameSpaceString(ns.parent, string);
885 strcat(string, ns.name);
886 strcat(string, "::");
890 // *******************************************************************
891 static void ProcessClass(ClassType classType, OldList definitions, Symbol symbol, OldList baseSpecs, OldList enumValues, OldList defs, External external, AccessMode declMode)
894 Class regClass = symbol.registered;
898 classType = regClass.type;
899 if(classType == enumClass && enumValues && (inCompiler || !buildingECERECOMModule))
902 for(e = enumValues.first; e; e = e.next)
911 e.exp.destType = destType;
913 // Set parsingType to avoid producing errors
915 ProcessExpressionType(e.exp);
920 destType.kind = TypeKind::classType;
921 destType._class = symbol;
922 ProcessExpressionType(e.exp);
924 ComputeExpression(e.exp);
925 if(e.exp.isConstant && /*e.exp.expType.kind == intType*/ e.exp.type == constantExp)
927 Operand op = GetOperand(e.exp);
929 // TODO: 64 BIT ENUM SUPPORT...
932 case charType: value = op.c; break;
933 case shortType: value = op.s; break;
934 default: value = op.i;
937 // value = op.i; //strtol(e.exp.string, null, 0);
938 eEnum_AddFixedValue(regClass, e.id.string, value);
942 eEnum_AddValue(regClass, e.id.string);
945 eEnum_AddValue(regClass, e.id.string);
949 // Process all functions
950 if(definitions != null)
954 for(def = definitions.first; def; def = def.next)
956 if(def.type == propertyWatchClassDef && def.propertyWatch)
958 PropertyWatch propWatch = def.propertyWatch;
960 char watcherName[1024];
962 Statement stmt = MkExpressionStmt(MkList());
965 sprintf(watcherName,"__ecerePropertySelfWatcher_%d", propWatcherID++);
966 for(propID = propWatch.properties->first; propID; propID = propID.next)
968 strcat(watcherName, "_");
969 strcat(watcherName, propID.string);
972 // TESTING THIS STUFF... BEWARE OF SYMBOL ID ISSUES
973 decl = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(watcherName)), MkListOne(MkTypeName(MkListOne(MkSpecifier(VOID)), null)));
974 func = MkClassFunction(MkListOne(MkSpecifier(VOID)), null, decl, null);
975 ProcessClassFunctionBody(func, propWatch.compound);
977 // TESTING WITH SAME SYMBOL ID AS CLASS
981 idCode = symbol.idCode;
983 excludedSymbols->Add(decl.symbol);
986 func.idCode = symbol.idCode;
987 func.dontMangle = true;
989 // Create a declaration above for constructor to see
991 External externalDecl = MkExternalDeclaration(null);
993 OldList * specifiers = MkList();
994 ListAdd(specifiers, MkSpecifier(STATIC));
995 ListAdd(specifiers, MkSpecifier(VOID));
997 ast->Insert(curExternal.prev, externalDecl);
999 decl = MkDeclaration(specifiers,
1000 MkListOne(MkInitDeclarator(MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(watcherName)),
1001 MkListOne(MkTypeName(MkListOne(MkSpecifierName(regClass.fullName)), null))), null)));
1002 externalDecl.declaration = decl;
1003 if(decl.symbol && !decl.symbol.methodExternal)
1005 decl.symbol.methodExternal = externalDecl;
1007 // PATCHED THIS, 2 SYMBOLS WERE THERE.. THIS ONE HAD AN ID TOO BIG
1008 decl.symbol.id = symbol.id;
1009 decl.symbol.idCode = symbol.idCode;
1013 propWatch.compound = null;
1014 definitions.Insert(null, MkClassDefFunction(func));
1016 stmt.type = expressionStmt;
1017 stmt.expressions = MkList();
1019 for(propID = propWatch.properties->first; propID; propID = propID.next)
1021 Property prop = eClass_FindProperty(regClass, propID.string, privateModule);
1024 // eProperty_SelfWatch(_class, name, callback);
1025 OldList * args = MkList();
1026 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1027 ListAdd(args, MkExpString(QMkString(propID.string)));
1028 ListAdd(args, MkExpIdentifier(MkIdentifier(watcherName)));
1030 ListAdd(stmt.expressions, MkExpCall(MkExpIdentifier(MkIdentifier("eProperty_SelfWatch")), args));
1033 Compiler_Error($"Property %s not found in class %s\n", propID.string, regClass.fullName);
1035 FreePropertyWatch(def.propertyWatch);
1036 def.propertyWatch = (PropertyWatch)stmt; // Store this here to use it after CreateRegisterModuleBody is done
1038 // ListAdd(statements, stmt);
1043 for(def = definitions.first; def; def = def.next)
1045 if(def.type == functionClassDef)
1047 ProcessClassFunction(regClass, def.function, defs, external.prev, declMode == staticAccess);
1052 // Make the RegisterClass section
1054 if(inCompiler && symbol.id != MAXINT && regClass)
1057 OldList * args = MkList();
1060 char * registerFunction = null;
1061 AccessMode inheritanceAccess = publicAccess;
1063 CreateRegisterModuleBody();
1065 curExternal = registerModuleExternal;
1068 switch(regClass.type)
1070 case structClass: ListAdd(args, MkExpIdentifier(MkIdentifier("structClass"))); break;
1071 case bitClass: ListAdd(args, MkExpIdentifier(MkIdentifier("bitClass"))); break;
1072 case enumClass: ListAdd(args, MkExpIdentifier(MkIdentifier("enumClass"))); break;
1073 case noHeadClass: ListAdd(args, MkExpIdentifier(MkIdentifier("noHeadClass"))); break;
1074 case unitClass: ListAdd(args, MkExpIdentifier(MkIdentifier("unitClass"))); break;
1075 case normalClass: ListAdd(args, MkExpIdentifier(MkIdentifier("normalClass"))); break;
1079 char nameSpace[1024] = "";
1080 char className[1024] = "";
1082 GetNameSpaceString(regClass.nameSpace, nameSpace);
1084 if(declMode == staticAccess)
1086 GetLastDirectory(sourceFile, className);
1087 ChangeCh(className, '.', '_');
1088 strcat(className, "}");
1090 strcat(className, nameSpace);
1091 strcat(className, regClass.name);
1092 string = QMkString(className);
1093 ListAdd(args, MkExpString(string));
1099 char * string = QMkString(regClass.base.name);
1100 ListAdd(args, regClass.base ? MkExpString(string) :
1101 MkExpConstant("0"));
1106 if(baseSpecs != null)
1108 Type baseType = ProcessType(baseSpecs, null);
1109 if(baseType.kind != structType && baseType.kind != unionType)
1111 char baseName[1024] = "";
1113 if(baseType.kind == TypeKind::classType && baseType._class && baseType._class.isStatic)
1115 // TODO: Handle static classes and complex declarators...
1116 GetLastDirectory(sourceFile, baseName);
1117 ChangeCh(baseName, '.', '_');
1118 strcat(baseName, "}");
1119 strcat(baseName, baseType._class.string);
1122 PrintType(baseType, baseName, false, true);
1124 string = QMkString(baseName);
1125 ListAdd(args, MkExpString(string));
1129 ListAdd(args, MkExpConstant("0"));
1131 if(((Specifier)baseSpecs.first).type == baseSpecifier && ((Specifier)baseSpecs.first).specifier == PRIVATE)
1132 inheritanceAccess = privateAccess;
1135 ListAdd(args, MkExpConstant("0"));
1137 //ListAdd(args, class.declaredStruct ? MkExpTypeSize(MkTypeName(MkListOne(
1138 //MkSpecifierName(class.structName)), null)) : MkExpConstant("0"));
1140 if(regClass.type == structClass || regClass.type == normalClass || regClass.type == noHeadClass)
1142 // Check if we have a data member in this class
1143 DataMember member = null;
1146 for(base = regClass.base; base && base.type != systemClass; base = base.next)
1148 for(member = base.membersAndProperties.first; member; member = member.next)
1149 if(!member.isProperty)
1156 if(regClass.type == structClass && symbol.declaredStruct && member)
1158 char baseStructName[1024];
1159 baseStructName[0] = 0;
1160 // TESTING THIS HERE
1161 // FullClassNameCat(baseStructName, regClass.base.fullName, false);
1162 strcpy(baseStructName, (regClass.base.templateClass ? regClass.base.templateClass : regClass.base).fullName);
1164 ListAdd(args, MkExpOp(
1165 MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(structSpecifier, MkIdentifier(symbol.structName), null)), null)), '-',
1166 MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(structSpecifier, MkIdentifier(baseStructName), null)), null))));
1169 ListAdd(args, symbol.declaredStruct ? MkExpTypeSize(MkTypeName(MkListOne(
1170 MkStructOrUnion(structSpecifier, MkIdentifier(symbol.structName), null)), null)) : MkExpConstant("0"));
1174 ListAdd(args, MkExpConstant("0"));
1177 //if(regClass.type == normalClass)
1179 char classDataStructName[1024];
1180 strcpy(classDataStructName, "__ecereClassData_");
1181 FullClassNameCat(classDataStructName, symbol.string, false);
1183 ListAdd(args, symbol.classData ? MkExpTypeSize(MkTypeName(MkListOne(
1184 MkStructOrUnion(structSpecifier, MkIdentifier(classDataStructName), null)), null)) : MkExpConstant("0"));
1187 // TODO: Support Class Data for all other types of classes
1188 ListAdd(args, MkExpConstant("0"));
1191 if(regClass.type == normalClass || regClass.type == noHeadClass)
1194 ListAdd(args, symbol.needConstructor ?
1195 MkExpIdentifier(MkIdentifier(symbol.constructorName)) :
1196 MkExpConstant("0"));
1198 ListAdd(args, symbol.needDestructor ?
1199 MkExpIdentifier(MkIdentifier(symbol.destructorName)) :
1200 MkExpConstant("0"));
1204 // TODO: Support Constructors / Destructors for structs
1207 ListAdd(args, MkExpConstant("0"));
1209 ListAdd(args, MkExpConstant("0"));
1213 ListAdd(args, MkExpIdentifier(MkIdentifier("module")));
1219 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1222 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1226 ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess")));
1231 switch(inheritanceAccess)
1234 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1238 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1242 registerFunction = "eSystem_RegisterClass";
1244 stmt = MkExpressionStmt(MkListOne(
1245 MkExpOp(MkExpIdentifier(MkIdentifier("class")), '=',
1246 MkExpCall((exp = MkExpIdentifier(MkIdentifier(registerFunction))), args))));
1248 ListAdd(registerModuleBody.compound.statements, stmt);
1251 stmt = MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(symbol.className)))),
1252 MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol.className)), '=',
1253 MkExpIdentifier(MkIdentifier("class"))))), null);
1256 stmt = MkIfStmt(MkListOne(
1258 MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP,
1259 MkExpMember(MkExpIdentifier(MkIdentifier("__thisModule")), MkIdentifier("application"))), AND_OP, MkExpIdentifier(MkIdentifier("class")))),
1260 MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol.className)), '=',
1261 MkExpIdentifier(MkIdentifier("class"))))), null);
1263 stmt = MkIfStmt(MkListOne(
1264 MkExpOp(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(symbol.className))), AND_OP, MkExpIdentifier(MkIdentifier("class")))),
1265 MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol.className)), '=',
1266 MkExpIdentifier(MkIdentifier("class"))))), null);
1269 ListAdd(registerModuleBody.compound.statements, stmt);
1271 if(external && external.type == classExternal && external._class.deleteWatchable)
1273 args = MkListOne(MkExpIdentifier(MkIdentifier("class")));
1274 stmt = MkExpressionStmt(MkListOne(
1275 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_DestructionWatchable")), args)));
1276 ListAdd(registerModuleBody.compound.statements, stmt);
1279 // Add Virtual Methods
1282 Class base = regClass.base;
1284 for(c = 0; c<base.vTblSize; c++)
1286 Symbol method = (Symbol)regClass._vTbl[c];
1287 if((void *) method != DummyMethod && base._vTbl[c] != (void *)method ) // TOLOOKAT: Module check here?
1289 External external = method.methodExternal;
1290 OldList * args = MkList();
1291 Identifier id = external.function ? GetDeclId(external.function.declarator) : null;
1294 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1297 //char * string = QMkString(method.string);
1299 char * string = QMkString(method.method.name);
1300 ListAdd(args, MkExpString(string));
1304 ListAdd(args, MkExpConstant("0"));
1306 ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(
1310 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1312 exp.expType = Type { refCount = 1 };
1313 stmt = MkExpressionStmt(MkListOne(
1314 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMethod")), args)));
1315 ListAdd(registerModuleBody.compound.statements, stmt);
1320 // Add Virtual Methods in order
1323 for(c = regClass.base ? regClass.base.vTblSize : 0; c < regClass.vTblSize; c++)
1325 for(method = (Method)regClass.methods.first; method; method = (Method)((BTNode)method).next)
1327 if(method.type == virtualMethod && method._class == regClass && method.vid == c)
1332 //External external = method->symbol ? ((Symbol)method.symbol).methodExternal : null;
1333 External external = method.symbol ? ((Symbol)method.symbol).methodCodeExternal : null;
1334 OldList * args = MkList();
1335 Identifier id = (external && external.function) ? GetDeclId(external.function.declarator) : null;
1338 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1341 char * string = QMkString(method.name);
1342 ListAdd(args, MkExpString(string));
1347 char * string = QMkString(method.dataTypeString);
1348 ListAdd(args, MkExpString(string));
1352 if(id && external.function.body)
1354 ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(id.string))));
1355 exp.expType = Type { refCount = 1 };
1359 ListAdd(args, (exp = MkExpConstant("0")));
1363 switch(method.memberAccess)
1366 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1369 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1373 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1377 //sprintf(name, "__ecereVMethodID_%s_%s", method._class.fullName, method.name);
1378 strcpy(name, "__ecereVMethodID_");
1379 FullClassNameCat(name, method._class.fullName, false);
1381 strcat(name, method.name);
1383 exp = /*MkExpPointer(*/MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddVirtualMethod")), args)/*, MkIdentifier("vid"))*/;
1385 exp->expType = eSystem_New(sizeof(Type));
1386 exp->expType->refCount++;
1387 exp->expType->isSigned = true;
1388 exp->expType->kind = TypeInt;
1391 stmt = MkExpressionStmt(MkListOne(/*
1392 MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=', */exp/*)*/));
1394 DeclareMethod(method, name);
1396 ListAdd(registerModuleBody.compound.statements, stmt);
1403 // Add Public Methods (all for now)
1404 for(method = (Method)regClass.methods.first; method; method = (Method)((BTNode)method).next)
1406 if(method.type == virtualMethod && method._class == regClass);
1407 else if(method.memberAccess == publicAccess || !method.dataTypeString)
1409 //External external = method.symbol ? ((Symbol )method.symbol).methodExternal : null;
1410 External external = method.symbol ? ((Symbol )method.symbol).methodCodeExternal : null;
1411 OldList * args = MkList();
1412 Identifier id = (external && external.function) ? GetDeclId(external.function.declarator) : null;
1415 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1418 char * string = QMkString(method.name);
1419 ListAdd(args, MkExpString(string));
1424 char * string = QMkString(method.dataTypeString);
1425 ListAdd(args, MkExpString(string));
1429 if(id && external.function.body)
1431 ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(
1433 exp.expType = Type { refCount = 1 };
1437 ListAdd(args, (exp = MkExpConstant("0")));
1441 switch(method.memberAccess)
1444 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1447 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1451 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1455 stmt = MkExpressionStmt(MkListOne(
1456 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMethod")), args)));
1457 ListAdd(registerModuleBody.compound.statements, stmt);
1461 RegisterMembersAndProperties(regClass, false, "class", registerModuleBody);
1463 // Add Enumeration Values
1464 if(classType == enumClass)
1467 Class enumClass = eSystem_FindClass(privateModule, "enum");
1468 EnumClassData e = ACCESS_CLASSDATA(regClass, enumClass);
1470 for(value = e.values.first; value; value = value.next)
1472 OldList * args = MkList();
1475 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1478 char * string = QMkString(value.name);
1479 ListAdd(args, MkExpString(string));
1485 // TODO: Support 64 bit enums
1486 sprintf(temp, "%d", (int)value.data);
1487 ListAdd(args, MkExpConstant(temp));
1490 stmt = MkExpressionStmt(MkListOne(
1491 MkExpCall(MkExpIdentifier(MkIdentifier("eEnum_AddFixedValue")), args)));
1492 ListAdd(registerModuleBody.compound.statements, stmt);
1496 // Add Template Parameters
1497 if(symbol.templateParams)
1499 TemplateParameter param;
1500 for(param = symbol.templateParams->first; param; param = param.next)
1502 OldList * args = MkList();
1505 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1509 char * string = QMkString(param.identifier.string);
1510 ListAdd(args, MkExpString(string));
1515 ListAdd(args, MkExpIdentifier(MkIdentifier((param.type == type) ? "type" : ((param.type == identifier) ? "identifier" : "expression"))));
1523 char * typeString = param.dataType ? StringFromSpecDecl(param.dataType.specifiers, param.dataType.decl) : null;
1524 char * string = QMkString(typeString);
1525 ListAdd(args, MkExpString(string));
1532 char memberTypeString[132] = "TemplateMemberType::";
1533 bool needClass = true;
1535 param.memberType.OnGetString(memberTypeString + strlen(memberTypeString), null, &needClass);
1537 MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null, null), null)),
1538 MkExpIdentifier(MkIdentifier(memberTypeString))));
1544 if(param.defaultArgument)
1546 OldList * members = MkList();
1551 char * typeString = param.defaultArgument.templateDatatype ?
1552 StringFromSpecDecl(param.defaultArgument.templateDatatype.specifiers, param.defaultArgument.templateDatatype.decl) : null;
1553 char * string = QMkString(typeString);
1555 members->Add(MkMemberInit(MkListOne(MkIdentifier("dataTypeString")), MkInitializerAssignment(MkExpString(string))));
1563 char memberString[1024];
1565 memberString[0] = '\0';
1567 if(param.defaultArgument.identifier._class)
1569 if(param.defaultArgument.identifier._class.type == templateTypeSpecifier)
1570 strcpy(memberString, param.defaultArgument.identifier._class.templateParameter.identifier.string);
1571 else if(param.defaultArgument.identifier._class.name)
1572 strcpy(memberString, param.defaultArgument.identifier._class.name);
1575 strcat(memberString, "::");
1577 strcat(memberString, param.defaultArgument.identifier.string);
1579 string = QMkString(memberString);
1581 // TOFIX: UNIONS ARE BROKEN FOR ASSIGNMENTS, USING dataTypeString INSTEAD
1582 // members->Add(MkMemberInit(MkListOne(MkIdentifier("memberString")), MkInitializerAssignment(MkExpString(string))));
1583 members->Add(MkMemberInit(MkListOne(MkIdentifier("dataTypeString")), MkInitializerAssignment(MkExpString(string))));
1591 OldList * ids = MkList();
1593 char * string = null;
1595 //ProcessExpressionType(param.defaultArgument.expression);
1596 //ComputeExpression(param.defaultArgument.expression);
1598 op = GetOperand(param.defaultArgument.expression);
1599 ui64String = PrintUInt64(op.ui64);
1600 ids->Add(MkIdentifier("expression"));
1601 ids->Add(MkIdentifier("ui64"));
1603 //string = QMkString(ui64String);
1604 members->Add(MkMemberInit(ids, MkInitializerAssignment(MkExpConstant(ui64String))));
1611 ListAdd(args, MkExpInstance(MkInstantiation(MkSpecifierName("ClassTemplateArgument"), null,
1612 MkListOne(MkMembersInitList(members)))));
1615 ListAdd(args, MkExpIdentifier(MkIdentifier("null")));
1617 stmt = MkExpressionStmt(MkListOne(
1618 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddTemplateParameter")), args)));
1619 ListAdd(registerModuleBody.compound.statements, stmt);
1621 stmt = MkExpressionStmt(MkListOne(
1622 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_DoneAddingTemplateParameters")),
1623 MkListOne(MkExpIdentifier(MkIdentifier("class"))))));
1624 ListAdd(registerModuleBody.compound.statements, stmt);
1627 if(definitions != null)
1629 for(def = definitions.first; def; def = def.next)
1631 if(def.type == propertyWatchClassDef && def.propertyWatch)
1633 ListAdd(registerModuleBody.compound.statements, (Statement)def.propertyWatch);
1634 def.propertyWatch = null;
1636 else if(def.type == classDesignerClassDef)
1639 char className[1024];
1640 sprintf(className, "__ecereClass_%s", def.designer);
1641 MangleClassName(className);
1643 DeclareClass(FindClass(def.designer), className);
1646 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1647 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("designerClass")), '=',
1648 MkExpString(QMkString(def.designer))))), null);
1649 ListAdd(registerModuleBody.compound.statements, stmt);
1651 else if(def.type == classNoExpansionClassDef)
1653 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1654 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("noExpansion")), '=',
1655 MkExpConstant("1")))), null);
1656 ListAdd(registerModuleBody.compound.statements, stmt);
1658 else if(def.type == classFixedClassDef)
1660 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1661 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("fixed")), '=',
1662 MkExpConstant("1")))), null);
1663 ListAdd(registerModuleBody.compound.statements, stmt);
1665 regClass.fixed = true;
1667 else if(def.type == designerDefaultPropertyClassDef)
1669 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1670 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("defaultProperty")), '=',
1671 MkExpString(QMkString(def.defaultProperty.string))))), null);
1672 ListAdd(registerModuleBody.compound.statements, stmt);
1674 else if(def.type == classPropertyValueClassDef)
1676 OldList * args = MkList();
1677 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1678 ListAdd(args, MkExpString(QMkString(def.id.string)));
1679 ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(INT64)), null), def.initializer.exp));
1681 def.initializer.exp = null;
1683 stmt = MkExpressionStmt(MkListOne(
1684 MkExpCall(MkExpIdentifier(MkIdentifier("ecere::com::eClass_SetProperty")), args)));
1686 ListAdd(registerModuleBody.compound.statements, stmt);
1694 public void ProcessClassDefinitions()
1696 External external, next;
1698 CreateRegisterModuleBody();
1701 // (Need to do those things after in case something is not yet defined)
1702 for(external = ast->first; external; external = next)
1704 next = external.next;
1705 curExternal = external;
1706 if(external.type == classExternal)
1708 ClassDefinition _class = external._class;
1709 if(_class.definitions)
1711 ProcessClass(normalClass, _class.definitions, _class.symbol, _class.baseSpecs, null, ast, external, _class.declMode);
1715 ast->Remove(external);
1716 FreeExternal(external);
1719 else if(external.type == functionExternal)
1721 bool setStaticMethod = false;
1723 if(external.symbol && !external.symbol.type.thisClass && !external.symbol.type.staticMethod)
1725 // TOCHECK: Where do we actually need this to be set?
1726 external.symbol.type.staticMethod = true;
1727 setStaticMethod = true;
1732 FunctionDefinition function = external.function;
1736 if(!strcmp(function.declarator.symbol.string, "__on_register_module"))
1738 ListAdd(registerModuleBody.compound.statements, function.body);
1739 function.body.compound.context.parent = registerModuleBody.compound.context;
1740 ast->Remove(external);
1741 function.body = null;
1742 FreeExternal(external);
1746 if(function.declMode != privateAccess && function.declMode != publicAccess) continue;
1750 CreateRegisterModuleBody();
1754 char * string = QMkString(function.declarator.symbol.string);
1755 ListAdd(args, MkExpString(string));
1762 char type[1024] = "";
1763 // We don't want functions to be marked as static methods
1765 function.declarator.symbol.type.staticMethod = false;
1766 PrintType(function.declarator.symbol.type, type, true, true);
1768 function.declarator.symbol.type.staticMethod = true;
1769 string = QMkString(type);
1770 ListAdd(args, MkExpString(string));
1776 ListAdd(args, MkExpIdentifier(MkIdentifier(function.declarator.symbol.string)));
1780 ListAdd(args, MkExpIdentifier(MkIdentifier("module")));
1783 switch(function.declMode)
1786 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1789 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1793 ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess")));
1797 stmt = MkExpressionStmt(MkListOne(
1798 MkExpCall((MkExpIdentifier(MkIdentifier("eSystem_RegisterFunction"))), args)));
1800 ListAdd(registerModuleBody.compound.statements, stmt);
1803 else if(external.type == declarationExternal)
1805 Declaration declaration = external.declaration;
1809 if(external.symbol.type && external.symbol.type.kind == functionType && !external.symbol.type.thisClass)
1810 external.symbol.type.staticMethod = true;
1813 if(external.symbol && declaration.type == initDeclaration)
1815 if(declaration.specifiers)
1817 Specifier specifier;
1818 bool removeExternal = false;
1820 for(specifier = declaration.specifiers->first; specifier; specifier = specifier.next)
1822 if((specifier.type == enumSpecifier || specifier.type == structSpecifier || specifier.type == unionSpecifier) && specifier.id && specifier.id.string &&
1823 (declaration.declMode || specifier.baseSpecs || (specifier.type == enumSpecifier && specifier.definitions)))
1825 Symbol symbol = FindClass(specifier.id.string);
1828 ClassType classType;
1829 if(specifier.type == enumSpecifier)
1830 classType = enumClass;
1832 classType = structClass;
1834 removeExternal = true;
1835 // Transfer Context over to Symbol
1836 symbol.ctx = specifier.ctx;
1837 specifier.ctx = null;
1839 ProcessClass(classType, specifier.definitions, symbol, specifier.baseSpecs, specifier.list,ast, external, declaration.declMode);
1843 if(inCompiler && removeExternal)
1845 ast->Remove(external);
1846 FreeExternal(external);
1850 else if(declaration.type == defineDeclaration)
1852 if(inCompiler && declaration.declMode != staticAccess)
1855 OldList * args = MkList();
1857 CreateRegisterModuleBody();
1861 char * string = QMkString(declaration.id.string);
1862 ListAdd(args, MkExpString(string));
1869 char type[1024] = "";
1870 PrintExpression(declaration.exp, type);
1871 string = QMkString(type);
1872 ListAdd(args, MkExpString(string));
1877 ListAdd(args, MkExpIdentifier(MkIdentifier("module")));
1880 switch(declaration.declMode)
1883 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1886 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1890 ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess")));
1894 stmt = MkExpressionStmt(MkListOne(
1895 MkExpCall((MkExpIdentifier(MkIdentifier("eSystem_RegisterDefine"))), args)));
1897 ListAdd(registerModuleBody.compound.statements, stmt);