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 ChangeCh(moduleName, '.', '_');
293 ChangeCh(moduleName, ' ', '_');
294 ChangeCh(moduleName, '-', '_');
295 sprintf(registerName, "__ecereRegisterModule_%s", moduleName);
297 declarator = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(registerName)),
298 MkListOne(moduleParam));
301 FunctionDefinition function = _MkFunction(specifiers, declarator, null, false);
302 ProcessFunctionBody(function, registerModuleBody);
303 function.declMode = defaultAccess;
304 if(!ast) ast = MkList();
305 ListAdd(ast, (registerModuleExternal = MkExternalFunction(function)));
310 if(!unregisterModuleBody && inCompiler)
312 char registerName[1024], moduleName[MAX_FILENAME];
313 OldList * specifiers;
314 Declarator declarator;
315 TypeName moduleParam;
317 unregisterModuleBody = MkCompoundStmt(MkList(), MkList());
318 unregisterModuleBody.compound.context = Context { parent = globalContext };
320 specifiers = MkList();
321 ListAdd(specifiers, MkSpecifier(VOID));
323 moduleParam = MkTypeName(MkListOne(/*MkSpecifier(VOID)*/ MkSpecifierName("Module")),
324 //MkDeclaratorPointer(MkPointer(null, null),
325 MkDeclaratorIdentifier(MkIdentifier("module")));
327 GetLastDirectory(outputFile, moduleName);
328 StripExtension(moduleName);
329 ChangeCh(moduleName, '.', '_');
330 ChangeCh(moduleName, ' ', '_');
331 ChangeCh(moduleName, '-', '_');
332 //strcpy(moduleName, argv[2]);
333 sprintf(registerName, "__ecereUnregisterModule_%s", moduleName);
335 declarator = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(registerName)),
336 MkListOne(moduleParam));
339 FunctionDefinition function = _MkFunction(specifiers, declarator, null, false);
340 ProcessFunctionBody(function, unregisterModuleBody);
341 function.declMode = defaultAccess;
342 if(!ast) ast = MkList();
343 ListAdd(ast, (unregisterModuleExternal = MkExternalFunction(function)));
348 void RegisterMembersAndProperties(Class regClass, bool isMember, char * className, Statement statement)
350 DataMember dataMember = isMember ? (DataMember)regClass : null;
355 char dataMemberSize[16];
359 bool privateMembers = false;
361 sprintf(dataMemberSize, "%d", (int)sizeof(DataMember));
364 for(prop = regClass.conversions.first; prop; prop = prop.next)
366 OldList * args = MkList();
370 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
372 ListAdd(args, MkExpConstant("0"));
376 char * string = QMkString(prop.dataTypeString);
377 ListAdd(args, MkExpString(string));
383 strcpy(name, "__ecereProp_");
384 FullClassNameCat(name, regClass.fullName, false);
385 strcat(name, "_Set_");
386 // strcat(name, prop.name);
387 FullClassNameCat(name, prop.name, true);
388 MangleClassName(name);
389 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
392 ListAdd(args, MkExpConstant("0"));
396 strcpy(name, "__ecereProp_");
397 FullClassNameCat(name, regClass.fullName, false);
398 strcat(name, "_Get_");
399 // strcat(name, prop.name);
400 FullClassNameCat(name, prop.name, true);
401 MangleClassName(name);
403 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
406 ListAdd(args, MkExpConstant("0"));
410 switch(prop.memberAccess)
413 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
416 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
420 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
424 strcpy(name, "__ecereProp_");
425 FullClassNameCat(name, regClass.fullName, false);
427 FullClassNameCat(name, prop.name, true);
428 // strcat(name, prop.name);
429 MangleClassName(name);
431 stmt = MkExpressionStmt(MkListOne(
432 MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=',
433 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args))));
434 ListAdd(registerModuleBody.compound.statements, stmt);
438 for(member = isMember ? dataMember.members.first : regClass.membersAndProperties.first; member; member = member.next)
440 if(member.isProperty)
442 prop = (Property) member;
444 OldList * args = MkList();
445 char name[1024], nameM[1024];
446 char * string = QMkString(prop.name);
449 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
452 ListAdd(args, MkExpString(string));
457 char * string = QMkString(prop.dataTypeString);
458 ListAdd(args, MkExpString(string));
464 strcpy(name, "__ecereProp_");
465 FullClassNameCat(name, regClass.fullName, false);
466 strcat(name, "_Set_");
467 FullClassNameCat(name, prop.name, true);
468 // strcat(name, prop.name);
469 MangleClassName(name);
470 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
473 ListAdd(args, MkExpConstant("0"));
477 strcpy(name, "__ecereProp_");
478 FullClassNameCat(name, regClass.fullName, false);
479 strcat(name, "_Get_");
480 FullClassNameCat(name, prop.name, true);
481 // strcat(name, prop.name);
482 MangleClassName(name);
483 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
486 ListAdd(args, MkExpConstant("0"));
489 switch(prop.memberAccess)
492 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
495 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
499 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
503 strcpy(name, "__ecereProp_");
504 FullClassNameCat(name, regClass.fullName, false);
506 FullClassNameCat(name, prop.name, true);
507 // strcat(name, prop.name);
508 MangleClassName(name);
510 strcpy(nameM, "__ecerePropM_");
511 FullClassNameCat(nameM, regClass.fullName, false);
513 FullClassNameCat(nameM, prop.name, true);
514 // strcat(nameM, prop.name);
515 MangleClassName(nameM);
517 if(prop.dataTypeString)
519 stmt = MkExpressionStmt(MkListOne(
520 MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=',
521 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args))));
525 stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args)));
527 ListAdd(registerModuleBody.compound.statements, stmt);
532 strcpy(name, "__ecereProp_");
533 FullClassNameCat(name, regClass.fullName, true);
534 strcat(name, "_IsSet_");
535 FullClassNameCat(name, prop.name, false);
536 // strcat(name, prop.name);
537 MangleClassName(name);
539 stmt = MkExpressionStmt(MkListOne(
540 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier(nameM)), MkIdentifier("IsSet")), '=',
541 MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpIdentifier(MkIdentifier(name))))));
542 ListAdd(registerModuleBody.compound.statements, stmt);
544 if(prop.symbol && ((Symbol)prop.symbol).propCategory)
546 stmt = MkExpressionStmt(MkListOne(
547 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier(nameM)), MkIdentifier("category")), '=',
548 CopyExpression(((Symbol)prop.symbol).propCategory))));
549 ListAdd(registerModuleBody.compound.statements, stmt);
552 if(prop.dataTypeString)
554 OldList * list = MkList();
555 ListAdd(list, MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=', MkExpIdentifier(MkIdentifier(nameM))));
556 ListAdd(list, MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=', MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpConstant("0"))));
557 // stmt = MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(name)))), MkExpressionStmt(list), null);
558 stmt = MkIfStmt(MkListOne(MkExpOp(
559 MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP,
560 MkExpMember(MkExpIdentifier(MkIdentifier("__thisModule")), MkIdentifier("application")))), MkExpressionStmt(list), null);
562 ListAdd(registerModuleBody.compound.statements, stmt);
564 // Unregister 2nd property
565 stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=',
566 MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpConstant("0")))));
567 ListAdd(unregisterModuleBody.compound.statements, stmt);
571 else if(member.type == normalMember && !isMember && regClass.type == bitClass)
573 BitMember bitMember = (BitMember) member;
574 OldList * args = MkList();
577 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
581 char * string = QMkString(bitMember.name);
582 ListAdd(args, MkExpString(string));
587 char * string = QMkString(bitMember.dataTypeString);
588 ListAdd(args, MkExpString(string));
594 sprintf(string, "%d", bitMember.size);
595 ListAdd(args, (exp = MkExpConstant(string)));
600 sprintf(string, "%d", bitMember.pos);
601 ListAdd(args, (exp = MkExpConstant(string)));
605 switch(member.memberAccess)
608 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
611 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
615 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
619 stmt = MkExpressionStmt(MkListOne(
620 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddBitMember")), args)));
622 ListAdd(statement.compound.statements, stmt);
624 else if(member.memberAccess == publicAccess || (member.type == normalMember && !member.dataTypeString))
627 // ADD PRIVATE DATA PADDING HERE...
630 uint offset = member.offset - lastOffset;
635 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
640 sprintf(string, "\"__ecerePrivateData%d\"", privateID++);
641 ListAdd(args, MkExpString(string));
646 sprintf(string, "\"byte[%d]\"", offset);
647 ListAdd(args, MkExpString(string));
652 sprintf(string, "%d", offset);
653 ListAdd(args, (exp = MkExpConstant(string)));
657 ListAdd(args, (exp = MkExpConstant("1")));
660 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
662 stmt = MkExpressionStmt(MkListOne(
663 MkExpCall(MkExpIdentifier(MkIdentifier(isMember ? "eMember_AddDataMember" : "eClass_AddDataMember")), args)));
665 ListAdd(statement.compound.statements, stmt);
666 privateMembers = false;
669 if(member.type == normalMember)
672 member.dataType = ProcessTypeString(member.dataTypeString, false);
674 ComputeTypeSize(member.dataType);
679 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
683 char * string = QMkString(member.name);
684 ListAdd(args, MkExpString(string));
689 char * string = QMkString(member.dataTypeString);
690 ListAdd(args, MkExpString(string));
696 sprintf(string, "%d", member.dataType.size);
697 ListAdd(args, (exp = MkExpConstant(string)));
703 sprintf(string, "%d", member.dataType.alignment);
704 ListAdd(args, (exp = MkExpConstant(string)));
708 switch(member.memberAccess)
711 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
714 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
718 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
722 stmt = MkExpressionStmt(MkListOne(
723 MkExpCall(MkExpIdentifier(MkIdentifier(isMember ? "eMember_AddDataMember" : "eClass_AddDataMember")), args)));
725 ListAdd(statement.compound.statements, stmt);
727 lastOffset = member.offset + member.dataType.size;
731 static int memberCount = 0;
735 char memberName[256];
736 sprintf(memberName, "dataMember%d", memberCount);
739 curContext = statement.compound.context;
740 context = PushContext();
742 args = MkListOne(MkExpIdentifier(MkIdentifier((member.type == unionMember) ? "unionMember" : "structMember")));
745 switch(member.memberAccess)
748 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
751 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
755 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
759 compound = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("DataMember")),
760 MkListOne(MkInitDeclarator(/*MkDeclaratorPointer(MkPointer(null, null), */MkDeclaratorIdentifier(MkIdentifier(memberName))/*)*/,
761 MkInitializerAssignment(MkExpCall(MkExpIdentifier(MkIdentifier("eMember_New")), args)))))), MkList());
762 compound.compound.context = context;
766 // Class class / DataMember member
767 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
769 // DataMember dataMember
770 ListAdd(args, MkExpIdentifier(MkIdentifier(memberName)));
772 RegisterMembersAndProperties((Class)member, true, memberName, compound);
775 stmt = MkExpressionStmt(MkListOne(
776 MkExpCall(MkExpIdentifier(MkIdentifier("eMember_AddMember")), args)));
778 stmt = MkExpressionStmt(MkListOne(
779 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMember")), args)));
781 ListAdd(compound.compound.statements, stmt);
785 ListAdd(statement.compound.statements, compound);
789 lastOffset = member.offset + member.memberOffset;
793 privateMembers = true;
798 ClassProperty classProperty;
800 // Watchable properties
801 for(prop = regClass.membersAndProperties.first; prop; prop = prop.next)
803 if(prop.isProperty && prop.isWatchable)
806 char name[1024], nameM[1024];
808 strcpy(name, "__ecereProp_");
809 FullClassNameCat(name, regClass.fullName, true);
811 FullClassNameCat(name, prop.name, false);
812 // strcat(name, prop.name);
813 MangleClassName(name);
815 strcpy(nameM, "__ecerePropM_");
816 FullClassNameCat(nameM, regClass.fullName, true);
818 FullClassNameCat(nameM, prop.name, false);
819 // strcat(nameM, prop.name);
820 MangleClassName(nameM);
822 args = MkListOne(MkExpCondition(MkExpIdentifier(MkIdentifier(nameM)), MkListOne(MkExpIdentifier(MkIdentifier(nameM))), MkExpIdentifier(MkIdentifier(name))));
823 stmt = MkExpressionStmt(MkListOne(
824 MkExpCall(MkExpIdentifier(MkIdentifier("eProperty_Watchable")), args)));
825 ListAdd(registerModuleBody.compound.statements, stmt);
829 // Add Class Properties
830 for(classProperty = (ClassProperty)regClass.classProperties.first; classProperty; classProperty = (ClassProperty)((BTNode)classProperty).next)
832 OldList * args = MkList();
834 char * string = QMkString(classProperty.name);
837 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
840 ListAdd(args, MkExpString(string));
845 char * string = QMkString(classProperty.dataTypeString);
846 ListAdd(args, MkExpString(string));
850 if(classProperty.Set)
852 strcpy(name, "__ecereClassProp_");
853 FullClassNameCat(name, regClass.fullName, true);
854 strcat(name, "_Set_");
855 strcat(name, classProperty.name);
856 MangleClassName(name);
857 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
860 ListAdd(args, MkExpConstant("0"));
862 if(classProperty.Get)
864 strcpy(name, "__ecereClassProp_");
865 FullClassNameCat(name, regClass.fullName, true);
866 strcat(name, "_Get_");
867 strcat(name, classProperty.name);
868 MangleClassName(name);
870 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
873 ListAdd(args, MkExpConstant("0"));
875 stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddClassProperty")), args)));
876 ListAdd(registerModuleBody.compound.statements, stmt);
881 extern External curExternal;
883 void GetNameSpaceString(NameSpace ns, char * string)
886 GetNameSpaceString(ns.parent, string);
889 strcat(string, ns.name);
890 strcat(string, "::");
894 // *******************************************************************
895 static void ProcessClass(ClassType classType, OldList definitions, Symbol symbol, OldList baseSpecs, OldList enumValues, OldList defs, External external, AccessMode declMode)
898 Class regClass = symbol.registered;
902 classType = regClass.type;
903 if(classType == enumClass && enumValues && (inCompiler || !buildingECERECOMModule))
906 for(e = enumValues.first; e; e = e.next)
915 e.exp.destType = destType;
917 // Set parsingType to avoid producing errors
919 ProcessExpressionType(e.exp);
924 destType.kind = TypeKind::classType;
925 destType._class = symbol;
926 ProcessExpressionType(e.exp);
928 ComputeExpression(e.exp);
929 if(e.exp.isConstant && /*e.exp.expType.kind == intType*/ e.exp.type == constantExp)
931 Operand op = GetOperand(e.exp);
933 // TODO: 64 BIT ENUM SUPPORT...
936 case charType: value = op.c; break;
937 case shortType: value = op.s; break;
938 default: value = op.i;
941 // value = op.i; //strtol(e.exp.string, null, 0);
942 eEnum_AddFixedValue(regClass, e.id.string, value);
946 eEnum_AddValue(regClass, e.id.string);
949 eEnum_AddValue(regClass, e.id.string);
953 // Process all functions
954 if(definitions != null)
958 for(def = definitions.first; def; def = def.next)
960 if(def.type == propertyWatchClassDef && def.propertyWatch)
962 PropertyWatch propWatch = def.propertyWatch;
964 char watcherName[1024];
966 Statement stmt = MkExpressionStmt(MkList());
969 sprintf(watcherName,"__ecerePropertySelfWatcher_%d", propWatcherID++);
970 for(propID = propWatch.properties->first; propID; propID = propID.next)
972 strcat(watcherName, "_");
973 strcat(watcherName, propID.string);
976 // TESTING THIS STUFF... BEWARE OF SYMBOL ID ISSUES
977 decl = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(watcherName)), MkListOne(MkTypeName(MkListOne(MkSpecifier(VOID)), null)));
978 func = MkClassFunction(MkListOne(MkSpecifier(VOID)), null, decl, null);
979 ProcessClassFunctionBody(func, propWatch.compound);
981 // TESTING WITH SAME SYMBOL ID AS CLASS
985 idCode = symbol.idCode;
987 excludedSymbols->Add(decl.symbol);
990 func.idCode = symbol.idCode;
991 func.dontMangle = true;
993 // Create a declaration above for constructor to see
995 External externalDecl = MkExternalDeclaration(null);
997 OldList * specifiers = MkList();
998 ListAdd(specifiers, MkSpecifier(STATIC));
999 ListAdd(specifiers, MkSpecifier(VOID));
1001 ast->Insert(curExternal.prev, externalDecl);
1003 decl = MkDeclaration(specifiers,
1004 MkListOne(MkInitDeclarator(MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(watcherName)),
1005 MkListOne(MkTypeName(MkListOne(MkSpecifierName(regClass.fullName)), null))), null)));
1006 externalDecl.declaration = decl;
1007 if(decl.symbol && !decl.symbol.methodExternal)
1009 decl.symbol.methodExternal = externalDecl;
1011 // PATCHED THIS, 2 SYMBOLS WERE THERE.. THIS ONE HAD AN ID TOO BIG
1012 decl.symbol.id = symbol.id;
1013 decl.symbol.idCode = symbol.idCode;
1017 propWatch.compound = null;
1018 definitions.Insert(null, MkClassDefFunction(func));
1020 stmt.type = expressionStmt;
1021 stmt.expressions = MkList();
1023 for(propID = propWatch.properties->first; propID; propID = propID.next)
1025 Property prop = eClass_FindProperty(regClass, propID.string, privateModule);
1028 // eProperty_SelfWatch(_class, name, callback);
1029 OldList * args = MkList();
1030 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1031 ListAdd(args, MkExpString(QMkString(propID.string)));
1032 ListAdd(args, MkExpIdentifier(MkIdentifier(watcherName)));
1034 ListAdd(stmt.expressions, MkExpCall(MkExpIdentifier(MkIdentifier("eProperty_SelfWatch")), args));
1037 Compiler_Error($"Property %s not found in class %s\n", propID.string, regClass.fullName);
1039 FreePropertyWatch(def.propertyWatch);
1040 def.propertyWatch = (PropertyWatch)stmt; // Store this here to use it after CreateRegisterModuleBody is done
1042 // ListAdd(statements, stmt);
1047 for(def = definitions.first; def; def = def.next)
1049 if(def.type == functionClassDef)
1051 ProcessClassFunction(regClass, def.function, defs, external.prev, declMode == staticAccess);
1056 // Make the RegisterClass section
1058 if(inCompiler && symbol.id != MAXINT && regClass)
1061 OldList * args = MkList();
1064 char * registerFunction = null;
1065 AccessMode inheritanceAccess = publicAccess;
1067 CreateRegisterModuleBody();
1069 curExternal = registerModuleExternal;
1072 switch(regClass.type)
1074 case structClass: ListAdd(args, MkExpIdentifier(MkIdentifier("structClass"))); break;
1075 case bitClass: ListAdd(args, MkExpIdentifier(MkIdentifier("bitClass"))); break;
1076 case enumClass: ListAdd(args, MkExpIdentifier(MkIdentifier("enumClass"))); break;
1077 case noHeadClass: ListAdd(args, MkExpIdentifier(MkIdentifier("noHeadClass"))); break;
1078 case unitClass: ListAdd(args, MkExpIdentifier(MkIdentifier("unitClass"))); break;
1079 case normalClass: ListAdd(args, MkExpIdentifier(MkIdentifier("normalClass"))); break;
1083 char nameSpace[1024] = "";
1084 char className[1024] = "";
1086 GetNameSpaceString(regClass.nameSpace, nameSpace);
1088 if(declMode == staticAccess)
1090 GetLastDirectory(sourceFile, className);
1091 ChangeCh(className, '.', '_');
1092 strcat(className, "}");
1094 strcat(className, nameSpace);
1095 strcat(className, regClass.name);
1096 string = QMkString(className);
1097 ListAdd(args, MkExpString(string));
1103 char * string = QMkString(regClass.base.name);
1104 ListAdd(args, regClass.base ? MkExpString(string) :
1105 MkExpConstant("0"));
1110 if(baseSpecs != null)
1112 Type baseType = ProcessType(baseSpecs, null);
1113 if(baseType.kind != structType && baseType.kind != unionType)
1115 char baseName[1024] = "";
1117 if(baseType.kind == TypeKind::classType && baseType._class && baseType._class.isStatic)
1119 // TODO: Handle static classes and complex declarators...
1120 GetLastDirectory(sourceFile, baseName);
1121 ChangeCh(baseName, '.', '_');
1122 strcat(baseName, "}");
1123 strcat(baseName, baseType._class.string);
1126 PrintType(baseType, baseName, false, true);
1128 string = QMkString(baseName);
1129 ListAdd(args, MkExpString(string));
1133 ListAdd(args, MkExpConstant("0"));
1135 if(((Specifier)baseSpecs.first).type == baseSpecifier && ((Specifier)baseSpecs.first).specifier == PRIVATE)
1136 inheritanceAccess = privateAccess;
1139 ListAdd(args, MkExpConstant("0"));
1141 //ListAdd(args, class.declaredStruct ? MkExpTypeSize(MkTypeName(MkListOne(
1142 //MkSpecifierName(class.structName)), null)) : MkExpConstant("0"));
1144 if(regClass.type == structClass || regClass.type == normalClass || regClass.type == noHeadClass)
1146 // Check if we have a data member in this class
1147 DataMember member = null;
1150 for(base = regClass.base; base && base.type != systemClass; base = base.next)
1152 for(member = base.membersAndProperties.first; member; member = member.next)
1153 if(!member.isProperty)
1160 if(regClass.type == structClass && symbol.declaredStruct && member)
1162 char baseStructName[1024];
1163 baseStructName[0] = 0;
1164 // TESTING THIS HERE
1165 // FullClassNameCat(baseStructName, regClass.base.fullName, false);
1166 strcpy(baseStructName, (regClass.base.templateClass ? regClass.base.templateClass : regClass.base).fullName);
1168 ListAdd(args, MkExpOp(
1169 MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(structSpecifier, MkIdentifier(symbol.structName), null)), null)), '-',
1170 MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(structSpecifier, MkIdentifier(baseStructName), null)), null))));
1173 ListAdd(args, symbol.declaredStruct ? MkExpTypeSize(MkTypeName(MkListOne(
1174 MkStructOrUnion(structSpecifier, MkIdentifier(symbol.structName), null)), null)) : MkExpConstant("0"));
1178 ListAdd(args, MkExpConstant("0"));
1181 //if(regClass.type == normalClass)
1183 char classDataStructName[1024];
1184 strcpy(classDataStructName, "__ecereClassData_");
1185 FullClassNameCat(classDataStructName, symbol.string, false);
1187 ListAdd(args, symbol.classData ? MkExpTypeSize(MkTypeName(MkListOne(
1188 MkStructOrUnion(structSpecifier, MkIdentifier(classDataStructName), null)), null)) : MkExpConstant("0"));
1191 // TODO: Support Class Data for all other types of classes
1192 ListAdd(args, MkExpConstant("0"));
1195 if(regClass.type == normalClass || regClass.type == noHeadClass)
1198 ListAdd(args, symbol.needConstructor ?
1199 MkExpIdentifier(MkIdentifier(symbol.constructorName)) :
1200 MkExpConstant("0"));
1202 ListAdd(args, symbol.needDestructor ?
1203 MkExpIdentifier(MkIdentifier(symbol.destructorName)) :
1204 MkExpConstant("0"));
1208 // TODO: Support Constructors / Destructors for structs
1211 ListAdd(args, MkExpConstant("0"));
1213 ListAdd(args, MkExpConstant("0"));
1217 ListAdd(args, MkExpIdentifier(MkIdentifier("module")));
1223 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1226 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1230 ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess")));
1235 switch(inheritanceAccess)
1238 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1242 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1246 registerFunction = "eSystem_RegisterClass";
1248 stmt = MkExpressionStmt(MkListOne(
1249 MkExpOp(MkExpIdentifier(MkIdentifier("class")), '=',
1250 MkExpCall((exp = MkExpIdentifier(MkIdentifier(registerFunction))), args))));
1252 ListAdd(registerModuleBody.compound.statements, stmt);
1255 stmt = MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(symbol.className)))),
1256 MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol.className)), '=',
1257 MkExpIdentifier(MkIdentifier("class"))))), null);
1260 stmt = MkIfStmt(MkListOne(
1262 MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP,
1263 MkExpMember(MkExpIdentifier(MkIdentifier("__thisModule")), MkIdentifier("application"))), AND_OP, MkExpIdentifier(MkIdentifier("class")))),
1264 MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol.className)), '=',
1265 MkExpIdentifier(MkIdentifier("class"))))), null);
1267 stmt = MkIfStmt(MkListOne(
1268 MkExpOp(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(symbol.className))), AND_OP, MkExpIdentifier(MkIdentifier("class")))),
1269 MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol.className)), '=',
1270 MkExpIdentifier(MkIdentifier("class"))))), null);
1273 ListAdd(registerModuleBody.compound.statements, stmt);
1275 if(external && external.type == classExternal && external._class.deleteWatchable)
1277 args = MkListOne(MkExpIdentifier(MkIdentifier("class")));
1278 stmt = MkExpressionStmt(MkListOne(
1279 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_DestructionWatchable")), args)));
1280 ListAdd(registerModuleBody.compound.statements, stmt);
1283 // Add Virtual Methods
1286 Class base = regClass.base;
1288 for(c = 0; c<base.vTblSize; c++)
1290 Symbol method = (Symbol)regClass._vTbl[c];
1291 if((void *) method != DummyMethod && base._vTbl[c] != (void *)method ) // TOLOOKAT: Module check here?
1293 External external = method.methodExternal;
1294 OldList * args = MkList();
1295 Identifier id = external.function ? GetDeclId(external.function.declarator) : null;
1298 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1301 //char * string = QMkString(method.string);
1303 char * string = QMkString(method.method.name);
1304 ListAdd(args, MkExpString(string));
1308 ListAdd(args, MkExpConstant("0"));
1310 ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(
1314 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1316 exp.expType = Type { refCount = 1 };
1317 stmt = MkExpressionStmt(MkListOne(
1318 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMethod")), args)));
1319 ListAdd(registerModuleBody.compound.statements, stmt);
1324 // Add Virtual Methods in order
1327 for(c = regClass.base ? regClass.base.vTblSize : 0; c < regClass.vTblSize; c++)
1329 for(method = (Method)regClass.methods.first; method; method = (Method)((BTNode)method).next)
1331 if(method.type == virtualMethod && method._class == regClass && method.vid == c)
1336 //External external = method->symbol ? ((Symbol)method.symbol).methodExternal : null;
1337 External external = method.symbol ? ((Symbol)method.symbol).methodCodeExternal : null;
1338 OldList * args = MkList();
1339 Identifier id = (external && external.function) ? GetDeclId(external.function.declarator) : null;
1342 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1345 char * string = QMkString(method.name);
1346 ListAdd(args, MkExpString(string));
1351 char * string = QMkString(method.dataTypeString);
1352 ListAdd(args, MkExpString(string));
1356 if(id && external.function.body)
1358 ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(id.string))));
1359 exp.expType = Type { refCount = 1 };
1363 ListAdd(args, (exp = MkExpConstant("0")));
1367 switch(method.memberAccess)
1370 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1373 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1377 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1381 //sprintf(name, "__ecereVMethodID_%s_%s", method._class.fullName, method.name);
1382 strcpy(name, "__ecereVMethodID_");
1383 FullClassNameCat(name, method._class.fullName, false);
1385 strcat(name, method.name);
1387 exp = /*MkExpPointer(*/MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddVirtualMethod")), args)/*, MkIdentifier("vid"))*/;
1389 exp->expType = eSystem_New(sizeof(Type));
1390 exp->expType->refCount++;
1391 exp->expType->isSigned = true;
1392 exp->expType->kind = TypeInt;
1395 stmt = MkExpressionStmt(MkListOne(/*
1396 MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=', */exp/*)*/));
1398 DeclareMethod(method, name);
1400 ListAdd(registerModuleBody.compound.statements, stmt);
1407 // Add Public Methods (all for now)
1408 for(method = (Method)regClass.methods.first; method; method = (Method)((BTNode)method).next)
1410 if(method.type == virtualMethod && method._class == regClass);
1411 else if(method.memberAccess == publicAccess || !method.dataTypeString)
1413 //External external = method.symbol ? ((Symbol )method.symbol).methodExternal : null;
1414 External external = method.symbol ? ((Symbol )method.symbol).methodCodeExternal : null;
1415 OldList * args = MkList();
1416 Identifier id = (external && external.function) ? GetDeclId(external.function.declarator) : null;
1419 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1422 char * string = QMkString(method.name);
1423 ListAdd(args, MkExpString(string));
1428 char * string = QMkString(method.dataTypeString);
1429 ListAdd(args, MkExpString(string));
1433 if(id && external.function.body)
1435 ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(
1437 exp.expType = Type { refCount = 1 };
1441 ListAdd(args, (exp = MkExpConstant("0")));
1445 switch(method.memberAccess)
1448 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1451 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1455 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1459 stmt = MkExpressionStmt(MkListOne(
1460 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMethod")), args)));
1461 ListAdd(registerModuleBody.compound.statements, stmt);
1465 RegisterMembersAndProperties(regClass, false, "class", registerModuleBody);
1467 // Add Enumeration Values
1468 if(classType == enumClass)
1471 Class enumClass = eSystem_FindClass(privateModule, "enum");
1472 EnumClassData e = ACCESS_CLASSDATA(regClass, enumClass);
1474 for(value = e.values.first; value; value = value.next)
1476 OldList * args = MkList();
1479 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1482 char * string = QMkString(value.name);
1483 ListAdd(args, MkExpString(string));
1489 // TODO: Support 64 bit enums
1490 sprintf(temp, "%d", (int)value.data);
1491 ListAdd(args, MkExpConstant(temp));
1494 stmt = MkExpressionStmt(MkListOne(
1495 MkExpCall(MkExpIdentifier(MkIdentifier("eEnum_AddFixedValue")), args)));
1496 ListAdd(registerModuleBody.compound.statements, stmt);
1500 // Add Template Parameters
1501 if(symbol.templateParams)
1503 TemplateParameter param;
1504 for(param = symbol.templateParams->first; param; param = param.next)
1506 OldList * args = MkList();
1509 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1513 char * string = QMkString(param.identifier.string);
1514 ListAdd(args, MkExpString(string));
1519 ListAdd(args, MkExpIdentifier(MkIdentifier((param.type == type) ? "type" : ((param.type == identifier) ? "identifier" : "expression"))));
1527 char * typeString = param.dataType ? StringFromSpecDecl(param.dataType.specifiers, param.dataType.decl) : null;
1528 char * string = QMkString(typeString);
1529 ListAdd(args, MkExpString(string));
1536 char memberTypeString[132] = "TemplateMemberType::";
1537 bool needClass = true;
1539 param.memberType.OnGetString(memberTypeString + strlen(memberTypeString), null, &needClass);
1541 MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null, null), null)),
1542 MkExpIdentifier(MkIdentifier(memberTypeString))));
1548 if(param.defaultArgument)
1550 OldList * members = MkList();
1555 char * typeString = param.defaultArgument.templateDatatype ?
1556 StringFromSpecDecl(param.defaultArgument.templateDatatype.specifiers, param.defaultArgument.templateDatatype.decl) : null;
1557 char * string = QMkString(typeString);
1559 members->Add(MkMemberInit(MkListOne(MkIdentifier("dataTypeString")), MkInitializerAssignment(MkExpString(string))));
1567 char memberString[1024];
1569 memberString[0] = '\0';
1571 if(param.defaultArgument.identifier._class)
1573 if(param.defaultArgument.identifier._class.type == templateTypeSpecifier)
1574 strcpy(memberString, param.defaultArgument.identifier._class.templateParameter.identifier.string);
1575 else if(param.defaultArgument.identifier._class.name)
1576 strcpy(memberString, param.defaultArgument.identifier._class.name);
1579 strcat(memberString, "::");
1581 strcat(memberString, param.defaultArgument.identifier.string);
1583 string = QMkString(memberString);
1585 // TOFIX: UNIONS ARE BROKEN FOR ASSIGNMENTS, USING dataTypeString INSTEAD
1586 // members->Add(MkMemberInit(MkListOne(MkIdentifier("memberString")), MkInitializerAssignment(MkExpString(string))));
1587 members->Add(MkMemberInit(MkListOne(MkIdentifier("dataTypeString")), MkInitializerAssignment(MkExpString(string))));
1595 OldList * ids = MkList();
1597 char * string = null;
1599 //ProcessExpressionType(param.defaultArgument.expression);
1600 //ComputeExpression(param.defaultArgument.expression);
1602 op = GetOperand(param.defaultArgument.expression);
1603 ui64String = PrintUInt64(op.ui64);
1604 ids->Add(MkIdentifier("expression"));
1605 ids->Add(MkIdentifier("ui64"));
1607 //string = QMkString(ui64String);
1608 members->Add(MkMemberInit(ids, MkInitializerAssignment(MkExpConstant(ui64String))));
1615 ListAdd(args, MkExpInstance(MkInstantiation(MkSpecifierName("ClassTemplateArgument"), null,
1616 MkListOne(MkMembersInitList(members)))));
1619 ListAdd(args, MkExpIdentifier(MkIdentifier("null")));
1621 stmt = MkExpressionStmt(MkListOne(
1622 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddTemplateParameter")), args)));
1623 ListAdd(registerModuleBody.compound.statements, stmt);
1625 stmt = MkExpressionStmt(MkListOne(
1626 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_DoneAddingTemplateParameters")),
1627 MkListOne(MkExpIdentifier(MkIdentifier("class"))))));
1628 ListAdd(registerModuleBody.compound.statements, stmt);
1631 if(definitions != null)
1633 for(def = definitions.first; def; def = def.next)
1635 if(def.type == propertyWatchClassDef && def.propertyWatch)
1637 ListAdd(registerModuleBody.compound.statements, (Statement)def.propertyWatch);
1638 def.propertyWatch = null;
1640 else if(def.type == classDesignerClassDef)
1643 char className[1024];
1644 sprintf(className, "__ecereClass_%s", def.designer);
1645 MangleClassName(className);
1647 DeclareClass(FindClass(def.designer), className);
1650 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1651 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("designerClass")), '=',
1652 MkExpString(QMkString(def.designer))))), null);
1653 ListAdd(registerModuleBody.compound.statements, stmt);
1655 else if(def.type == classNoExpansionClassDef)
1657 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1658 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("noExpansion")), '=',
1659 MkExpConstant("1")))), null);
1660 ListAdd(registerModuleBody.compound.statements, stmt);
1662 else if(def.type == classFixedClassDef)
1664 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1665 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("fixed")), '=',
1666 MkExpConstant("1")))), null);
1667 ListAdd(registerModuleBody.compound.statements, stmt);
1669 regClass.fixed = true;
1671 else if(def.type == designerDefaultPropertyClassDef)
1673 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1674 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("defaultProperty")), '=',
1675 MkExpString(QMkString(def.defaultProperty.string))))), null);
1676 ListAdd(registerModuleBody.compound.statements, stmt);
1678 else if(def.type == classPropertyValueClassDef)
1680 OldList * args = MkList();
1681 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1682 ListAdd(args, MkExpString(QMkString(def.id.string)));
1683 ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(INT64)), null), def.initializer.exp));
1685 def.initializer.exp = null;
1687 stmt = MkExpressionStmt(MkListOne(
1688 MkExpCall(MkExpIdentifier(MkIdentifier("ecere::com::eClass_SetProperty")), args)));
1690 ListAdd(registerModuleBody.compound.statements, stmt);
1698 public void ProcessClassDefinitions()
1700 External external, next;
1702 CreateRegisterModuleBody();
1705 // (Need to do those things after in case something is not yet defined)
1706 for(external = ast->first; external; external = next)
1708 next = external.next;
1709 curExternal = external;
1710 if(external.type == classExternal)
1712 ClassDefinition _class = external._class;
1713 if(_class.definitions)
1715 ProcessClass(normalClass, _class.definitions, _class.symbol, _class.baseSpecs, null, ast, external, _class.declMode);
1719 ast->Remove(external);
1720 FreeExternal(external);
1723 else if(external.type == functionExternal)
1725 bool setStaticMethod = false;
1727 if(external.symbol && !external.symbol.type.thisClass && !external.symbol.type.staticMethod)
1729 // TOCHECK: Where do we actually need this to be set?
1730 external.symbol.type.staticMethod = true;
1731 setStaticMethod = true;
1736 FunctionDefinition function = external.function;
1740 if(!strcmp(function.declarator.symbol.string, "__on_register_module"))
1742 ListAdd(registerModuleBody.compound.statements, function.body);
1743 function.body.compound.context.parent = registerModuleBody.compound.context;
1744 ast->Remove(external);
1745 function.body = null;
1746 FreeExternal(external);
1750 if(function.declMode != privateAccess && function.declMode != publicAccess) continue;
1754 CreateRegisterModuleBody();
1758 char * string = QMkString(function.declarator.symbol.string);
1759 ListAdd(args, MkExpString(string));
1766 char type[1024] = "";
1767 // We don't want functions to be marked as static methods
1769 function.declarator.symbol.type.staticMethod = false;
1770 PrintType(function.declarator.symbol.type, type, true, true);
1772 function.declarator.symbol.type.staticMethod = true;
1773 string = QMkString(type);
1774 ListAdd(args, MkExpString(string));
1780 ListAdd(args, MkExpIdentifier(MkIdentifier(function.declarator.symbol.string)));
1784 ListAdd(args, MkExpIdentifier(MkIdentifier("module")));
1787 switch(function.declMode)
1790 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1793 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1797 ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess")));
1801 stmt = MkExpressionStmt(MkListOne(
1802 MkExpCall((MkExpIdentifier(MkIdentifier("eSystem_RegisterFunction"))), args)));
1804 ListAdd(registerModuleBody.compound.statements, stmt);
1807 else if(external.type == declarationExternal)
1809 Declaration declaration = external.declaration;
1813 if(external.symbol.type && external.symbol.type.kind == functionType && !external.symbol.type.thisClass)
1814 external.symbol.type.staticMethod = true;
1817 if(external.symbol && declaration.type == initDeclaration)
1819 if(declaration.specifiers)
1821 Specifier specifier;
1822 bool removeExternal = false;
1824 for(specifier = declaration.specifiers->first; specifier; specifier = specifier.next)
1826 if((specifier.type == enumSpecifier || specifier.type == structSpecifier || specifier.type == unionSpecifier) && specifier.id && specifier.id.string &&
1827 (declaration.declMode || specifier.baseSpecs || (specifier.type == enumSpecifier && specifier.definitions)))
1829 Symbol symbol = FindClass(specifier.id.string);
1832 ClassType classType;
1833 if(specifier.type == enumSpecifier)
1834 classType = enumClass;
1836 classType = structClass;
1838 removeExternal = true;
1839 // Transfer Context over to Symbol
1840 symbol.ctx = specifier.ctx;
1841 specifier.ctx = null;
1843 ProcessClass(classType, specifier.definitions, symbol, specifier.baseSpecs, specifier.list,ast, external, declaration.declMode);
1847 if(inCompiler && removeExternal)
1849 ast->Remove(external);
1850 FreeExternal(external);
1854 else if(declaration.type == defineDeclaration)
1856 if(inCompiler && declaration.declMode != staticAccess)
1859 OldList * args = MkList();
1861 CreateRegisterModuleBody();
1865 char * string = QMkString(declaration.id.string);
1866 ListAdd(args, MkExpString(string));
1873 char type[1024] = "";
1874 PrintExpression(declaration.exp, type);
1875 string = QMkString(type);
1876 ListAdd(args, MkExpString(string));
1881 ListAdd(args, MkExpIdentifier(MkIdentifier("module")));
1884 switch(declaration.declMode)
1887 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1890 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1894 ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess")));
1898 stmt = MkExpressionStmt(MkListOne(
1899 MkExpCall((MkExpIdentifier(MkIdentifier("eSystem_RegisterDefine"))), args)));
1901 ListAdd(registerModuleBody.compound.statements, stmt);