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);
66 function.propSet = func.propSet;
67 ProcessFunctionBody(function, func.body);
68 external = MkExternalFunction(function);
70 external.symbol = func.declarator.symbol;
71 external.function._class = func._class;
74 symbol = func.declarator.symbol;
75 //symbol.id = func.id; //symid;
77 symbol.idCode = symidCode;
82 Method method = func.declarator.symbol.method;
83 func.declarator.symbol.methodExternal = external;
85 // DANGER: Added this one...
87 if(method && method.symbol)
88 //((Symbol)method.symbol).methodExternal = external;
89 ((Symbol)method.symbol).methodCodeExternal = external;
91 if(method && method.type == virtualMethod)
94 ProcessMethodType(method);
96 methodDataType = method.dataType;
98 // Do type checking here of type against method.dataType
99 // ThisClass must be the owning class for types not specified, static for static, or inherit from method's ThisClass is specified
100 // If not specified, defaults to ThisClass if ThisClass specified in method, otherwise overiding class or static
104 if(!type.staticMethod && !type.thisClass && !type.thisClassTemplate)
106 if(method.dataType.thisClassTemplate)
108 if(owningClass.templateArgs)
110 ClassTemplateArgument * arg = FindTemplateArg(owningClass, method.dataType.thisClassTemplate);
111 type.byReference = method.dataType.byReference;
113 methodDataType = ProcessTypeString(method.dataTypeString, false);
114 type.thisClass = methodDataType.thisClass = arg ? FindClass(arg->dataTypeString) : null;
117 else if(method.dataType.staticMethod)
118 type.staticMethod = true;
119 else if(method.dataType.thisClass)
121 type.thisClass = method.dataType.thisClass;
122 type.byReference = method.dataType.byReference;
126 if(!owningClass.symbol)
127 owningClass.symbol = FindClass(owningClass.fullName);
129 type.thisClass = owningClass.symbol;
130 // WORKING ON THIS TO SUPPORT : pass.NotifyClicked(this, pass, 0, 0, key.modifiers);
131 type.extraParam = true;
136 if(!MatchTypes(type, methodDataType, null, owningClass, method._class /*owningClass*/, true, true, true, false))
139 // MatchTypes(type, methodDataType, null, owningClass, owningClass, true, true, true, false);
141 Compiler_Error("Incompatible virtual function %s\n", method.name);
145 // Mark typed_object/any_object parameters as such according to method type
147 Declarator funcDecl = GetFuncDecl(func.declarator);
148 if(funcDecl.function.parameters)
150 TypeName param = funcDecl.function.parameters->first;
152 for(typeParam = methodDataType.params.first; typeParam; typeParam = typeParam.next)
154 if(typeParam.classObjectType)
156 param.classObjectType = typeParam.classObjectType;
157 if(param.declarator && param.declarator.symbol)
158 param.declarator.symbol.type.classObjectType = typeParam.classObjectType;
164 if(methodDataType != method.dataType)
165 FreeType(methodDataType);
170 if(!type.staticMethod && !type.thisClass)
172 if(owningClass && !owningClass.symbol)
173 owningClass.symbol = FindClass(owningClass.fullName);
175 type.thisClass = owningClass ? FindClass(owningClass.fullName) : null;
181 // TESTING THIS HERE: (Implementing Class Properties)
182 if(symbol.type && !symbol.type.staticMethod && !symbol.type.thisClass)
184 if(!owningClass.symbol)
185 owningClass.symbol = FindClass(owningClass.fullName);
186 symbol.type.thisClass = owningClass.symbol;
189 // Those type of classes don't need a this parameter for Set methods, null thisClass before changing the externals
190 if(propSymbol.externalSet == (External)func && propSymbol._property && propSymbol._property.conversion)
192 if(symbol.type.thisClass && symbol.type.classObjectType != classPointer)
194 // TODO: Perhaps improve this so as to support both "this =" and "return " syntax for all types of classes
195 if(owningClass.type != structClass)
196 //function.propertyNoThis = true;
197 symbol.type.thisClass = null;
202 if(propSymbol.externalGet == (External)func)
204 propSymbol.externalGet = external;
206 else if(propSymbol.externalSet == (External)func)
208 propSymbol.externalSet = external;
210 else if(propSymbol.externalIsSet == (External)func)
212 propSymbol.externalIsSet = external;
216 // Constructor destructor
217 //symbol.type = Type { };
224 func.declarator = null;
225 func.specifiers = null;
228 defs.Insert(after, external);
232 Method method = func.declarator.symbol.method;
233 if(method && method.symbol)
234 ((Symbol)method.symbol).methodCodeExternal = null;
236 //external.function = null;
237 func.declarator = null;
238 func.specifiers = null;
240 FreeExternal(external); // Free external here?
245 globalContext /*curContext*/.symbols.Remove((BTNode)symbol);
246 excludedSymbols->Add(symbol);
249 defs.Insert(after, external);
251 external.function.declarator = CopyDeclarator(external.function.declarator);
252 external.function.specifiers = CopyList(external.function.specifiers, CopySpecifier);
253 external.function.body = null;
259 void CreateRegisterModuleBody()
261 if(!registerModuleBody && inCompiler)
263 char registerName[1024], moduleName[MAX_FILENAME];
264 OldList * specifiers;
265 Declarator declarator;
266 TypeName moduleParam;
268 registerModuleBody = MkCompoundStmt(MkList(), MkList());
269 registerModuleBody.compound.context = Context { parent = globalContext };
272 ListAdd(registerModuleBody.compound.declarations,
273 MkDeclaration(MkListOne(MkStructOrUnion(structSpecifier, MkIdentifier("__ecereNameSpace__ecere__com__Class"), null) /*MkSpecifierName("ecere::com::Class")*/ /*MkStructOrUnion(SpecifierStruct, MkIdentifier("Class"), null)*/),
274 MkListOne(MkInitDeclarator(MkDeclaratorPointer(MkPointer(null,null), MkDeclaratorIdentifier(MkIdentifier("class"))), null))));
276 ListAdd(registerModuleBody.compound.declarations,
277 MkDeclaration(MkListOne(MkSpecifierName("ecere::com::Class")),
278 MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("class")), null))));
280 specifiers = MkList();
281 ListAdd(specifiers, MkSpecifier(VOID));
283 moduleParam = MkTypeName(MkListOne(/*MkSpecifier(VOID)*/MkSpecifierName("Module")),
284 //MkDeclaratorPointer(MkPointer(null, null),
285 MkDeclaratorIdentifier(MkIdentifier("module")));
287 GetLastDirectory(outputFile, moduleName);
288 //strcpy(moduleName, argv[2]);
289 StripExtension(moduleName);
290 ChangeCh(moduleName, '.', '_');
291 ChangeCh(moduleName, ' ', '_');
292 ChangeCh(moduleName, '-', '_');
293 sprintf(registerName, "__ecereRegisterModule_%s", moduleName);
295 declarator = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(registerName)),
296 MkListOne(moduleParam));
299 FunctionDefinition function = MkFunction(specifiers, declarator, null);
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 ChangeCh(moduleName, '.', '_');
328 ChangeCh(moduleName, ' ', '_');
329 ChangeCh(moduleName, '-', '_');
330 //strcpy(moduleName, argv[2]);
331 sprintf(registerName, "__ecereUnregisterModule_%s", moduleName);
333 declarator = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(registerName)),
334 MkListOne(moduleParam));
337 FunctionDefinition function = MkFunction(specifiers, declarator, null);
338 ProcessFunctionBody(function, unregisterModuleBody);
339 function.declMode = defaultAccess;
340 if(!ast) ast = MkList();
341 ListAdd(ast, (unregisterModuleExternal = MkExternalFunction(function)));
346 void RegisterMembersAndProperties(Class regClass, bool isMember, char * className, Statement statement)
348 DataMember dataMember = isMember ? (DataMember)regClass : null;
353 char dataMemberSize[16];
357 bool privateMembers = false;
359 sprintf(dataMemberSize, "%d", sizeof(DataMember));
362 for(prop = regClass.conversions.first; prop; prop = prop.next)
364 OldList * args = MkList();
368 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
370 ListAdd(args, MkExpConstant("0"));
374 char * string = QMkString(prop.dataTypeString);
375 ListAdd(args, MkExpString(string));
381 strcpy(name, "__ecereProp_");
382 FullClassNameCat(name, regClass.fullName, false);
383 strcat(name, "_Set_");
384 // strcat(name, prop.name);
385 FullClassNameCat(name, prop.name, true);
386 MangleClassName(name);
387 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
390 ListAdd(args, MkExpConstant("0"));
394 strcpy(name, "__ecereProp_");
395 FullClassNameCat(name, regClass.fullName, false);
396 strcat(name, "_Get_");
397 // strcat(name, prop.name);
398 FullClassNameCat(name, prop.name, true);
399 MangleClassName(name);
401 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
404 ListAdd(args, MkExpConstant("0"));
408 switch(prop.memberAccess)
411 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
414 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
418 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
422 strcpy(name, "__ecereProp_");
423 FullClassNameCat(name, regClass.fullName, false);
425 FullClassNameCat(name, prop.name, true);
426 // strcat(name, prop.name);
427 MangleClassName(name);
429 stmt = MkExpressionStmt(MkListOne(
430 MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=',
431 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args))));
432 ListAdd(registerModuleBody.compound.statements, stmt);
436 for(member = isMember ? dataMember.members.first : regClass.membersAndProperties.first; member; member = member.next)
438 if(member.isProperty)
440 prop = (Property) member;
442 OldList * args = MkList();
443 char name[1024], nameM[1024];
444 char * string = QMkString(prop.name);
447 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
450 ListAdd(args, MkExpString(string));
455 char * string = QMkString(prop.dataTypeString);
456 ListAdd(args, MkExpString(string));
462 strcpy(name, "__ecereProp_");
463 FullClassNameCat(name, regClass.fullName, false);
464 strcat(name, "_Set_");
465 FullClassNameCat(name, prop.name, true);
466 // strcat(name, prop.name);
467 MangleClassName(name);
468 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
471 ListAdd(args, MkExpConstant("0"));
475 strcpy(name, "__ecereProp_");
476 FullClassNameCat(name, regClass.fullName, false);
477 strcat(name, "_Get_");
478 FullClassNameCat(name, prop.name, true);
479 // strcat(name, prop.name);
480 MangleClassName(name);
481 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
484 ListAdd(args, MkExpConstant("0"));
487 switch(prop.memberAccess)
490 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
493 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
497 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
501 strcpy(name, "__ecereProp_");
502 FullClassNameCat(name, regClass.fullName, false);
504 FullClassNameCat(name, prop.name, true);
505 // strcat(name, prop.name);
506 MangleClassName(name);
508 strcpy(nameM, "__ecerePropM_");
509 FullClassNameCat(nameM, regClass.fullName, false);
511 FullClassNameCat(nameM, prop.name, true);
512 // strcat(nameM, prop.name);
513 MangleClassName(nameM);
515 if(prop.dataTypeString)
517 stmt = MkExpressionStmt(MkListOne(
518 MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=',
519 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args))));
523 stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args)));
525 ListAdd(registerModuleBody.compound.statements, stmt);
530 strcpy(name, "__ecereProp_");
531 FullClassNameCat(name, regClass.fullName, true);
532 strcat(name, "_IsSet_");
533 FullClassNameCat(name, prop.name, false);
534 // strcat(name, prop.name);
535 MangleClassName(name);
537 stmt = MkExpressionStmt(MkListOne(
538 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier(nameM)), MkIdentifier("IsSet")), '=',
539 MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpIdentifier(MkIdentifier(name))))));
540 ListAdd(registerModuleBody.compound.statements, stmt);
542 if(((Symbol)prop.symbol).propCategory)
544 stmt = MkExpressionStmt(MkListOne(
545 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier(nameM)), MkIdentifier("category")), '=',
546 CopyExpression(((Symbol)prop.symbol).propCategory))));
547 ListAdd(registerModuleBody.compound.statements, stmt);
550 if(prop.dataTypeString)
552 OldList * list = MkList();
553 ListAdd(list, MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=', MkExpIdentifier(MkIdentifier(nameM))));
554 ListAdd(list, MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=', MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpConstant("0"))));
555 // stmt = MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(name)))), MkExpressionStmt(list), null);
556 stmt = MkIfStmt(MkListOne(MkExpOp(
557 MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP,
558 MkExpMember(MkExpIdentifier(MkIdentifier("__thisModule")), MkIdentifier("application")))), MkExpressionStmt(list), null);
560 ListAdd(registerModuleBody.compound.statements, stmt);
562 // Unregister 2nd property
563 stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=',
564 MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null,null), null)), MkExpConstant("0")))));
565 ListAdd(unregisterModuleBody.compound.statements, stmt);
569 else if(member.type == normalMember && !isMember && regClass.type == bitClass)
571 BitMember bitMember = (BitMember) member;
572 OldList * args = MkList();
575 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
579 char * string = QMkString(bitMember.name);
580 ListAdd(args, MkExpString(string));
585 char * string = QMkString(bitMember.dataTypeString);
586 ListAdd(args, MkExpString(string));
592 sprintf(string, "%d", bitMember.size);
593 ListAdd(args, (exp = MkExpConstant(string)));
598 sprintf(string, "%d", bitMember.pos);
599 ListAdd(args, (exp = MkExpConstant(string)));
603 switch(member.memberAccess)
606 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
609 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
613 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
617 stmt = MkExpressionStmt(MkListOne(
618 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddBitMember")), args)));
620 ListAdd(statement.compound.statements, stmt);
622 else if(member.memberAccess == publicAccess || (member.type == normalMember && !member.dataTypeString))
625 // ADD PRIVATE DATA PADDING HERE...
628 uint offset = member.offset - lastOffset;
633 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
638 sprintf(string, "\"__ecerePrivateData%d\"", privateID++);
639 ListAdd(args, MkExpString(string));
644 sprintf(string, "\"byte[%d]\"", offset);
645 ListAdd(args, MkExpString(string));
650 sprintf(string, "%d", offset);
651 ListAdd(args, (exp = MkExpConstant(string)));
655 ListAdd(args, (exp = MkExpConstant("1")));
658 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
660 stmt = MkExpressionStmt(MkListOne(
661 MkExpCall(MkExpIdentifier(MkIdentifier(isMember ? "eMember_AddDataMember" : "eClass_AddDataMember")), args)));
663 ListAdd(statement.compound.statements, stmt);
664 privateMembers = false;
667 if(member.type == normalMember)
670 member.dataType = ProcessTypeString(member.dataTypeString, false);
672 ComputeTypeSize(member.dataType);
677 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
681 char * string = QMkString(member.name);
682 ListAdd(args, MkExpString(string));
687 char * string = QMkString(member.dataTypeString);
688 ListAdd(args, MkExpString(string));
694 sprintf(string, "%d", member.dataType.size);
695 ListAdd(args, (exp = MkExpConstant(string)));
701 sprintf(string, "%d", member.dataType.alignment);
702 ListAdd(args, (exp = MkExpConstant(string)));
706 switch(member.memberAccess)
709 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
712 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
716 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
720 stmt = MkExpressionStmt(MkListOne(
721 MkExpCall(MkExpIdentifier(MkIdentifier(isMember ? "eMember_AddDataMember" : "eClass_AddDataMember")), args)));
723 ListAdd(statement.compound.statements, stmt);
725 lastOffset = member.offset + member.dataType.size;
729 static int memberCount = 0;
733 char memberName[256];
734 sprintf(memberName, "dataMember%d", memberCount);
737 curContext = statement.compound.context;
738 context = PushContext();
740 args = MkListOne(MkExpIdentifier(MkIdentifier((member.type == unionMember) ? "unionMember" : "structMember")));
743 switch(member.memberAccess)
746 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
749 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
753 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
757 compound = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("DataMember")),
758 MkListOne(MkInitDeclarator(/*MkDeclaratorPointer(MkPointer(null, null), */MkDeclaratorIdentifier(MkIdentifier(memberName))/*)*/,
759 MkInitializerAssignment(MkExpCall(MkExpIdentifier(MkIdentifier("eMember_New")), args)))))), MkList());
760 compound.compound.context = context;
764 // Class class / DataMember member
765 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
767 // DataMember dataMember
768 ListAdd(args, MkExpIdentifier(MkIdentifier(memberName)));
770 RegisterMembersAndProperties((Class)member, true, memberName, compound);
773 stmt = MkExpressionStmt(MkListOne(
774 MkExpCall(MkExpIdentifier(MkIdentifier("eMember_AddMember")), args)));
776 stmt = MkExpressionStmt(MkListOne(
777 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMember")), args)));
779 ListAdd(compound.compound.statements, stmt);
783 ListAdd(statement.compound.statements, compound);
787 lastOffset = member.offset + member.memberOffset;
791 privateMembers = true;
796 ClassProperty classProperty;
798 // Watchable properties
799 for(prop = regClass.membersAndProperties.first; prop; prop = prop.next)
801 if(prop.isProperty && prop.isWatchable)
804 char name[1024], nameM[1024];
806 strcpy(name, "__ecereProp_");
807 FullClassNameCat(name, regClass.fullName, true);
809 FullClassNameCat(name, prop.name, false);
810 // strcat(name, prop.name);
811 MangleClassName(name);
813 strcpy(nameM, "__ecerePropM_");
814 FullClassNameCat(nameM, regClass.fullName, true);
816 FullClassNameCat(nameM, prop.name, false);
817 // strcat(nameM, prop.name);
818 MangleClassName(nameM);
820 args = MkListOne(MkExpCondition(MkExpIdentifier(MkIdentifier(nameM)), MkListOne(MkExpIdentifier(MkIdentifier(nameM))), MkExpIdentifier(MkIdentifier(name))));
821 stmt = MkExpressionStmt(MkListOne(
822 MkExpCall(MkExpIdentifier(MkIdentifier("eProperty_Watchable")), args)));
823 ListAdd(registerModuleBody.compound.statements, stmt);
827 // Add Class Properties
828 for(classProperty = (ClassProperty)regClass.classProperties.first; classProperty; classProperty = (ClassProperty)((BTNode)classProperty).next)
830 OldList * args = MkList();
832 char * string = QMkString(classProperty.name);
835 ListAdd(args, MkExpIdentifier(MkIdentifier(className)));
838 ListAdd(args, MkExpString(string));
843 char * string = QMkString(classProperty.dataTypeString);
844 ListAdd(args, MkExpString(string));
848 if(classProperty.Set)
850 strcpy(name, "__ecereClassProp_");
851 FullClassNameCat(name, regClass.fullName, true);
852 strcat(name, "_Set_");
853 strcat(name, classProperty.name);
854 MangleClassName(name);
855 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
858 ListAdd(args, MkExpConstant("0"));
860 if(classProperty.Get)
862 strcpy(name, "__ecereClassProp_");
863 FullClassNameCat(name, regClass.fullName, true);
864 strcat(name, "_Get_");
865 strcat(name, classProperty.name);
866 MangleClassName(name);
868 ListAdd(args, MkExpIdentifier(MkIdentifier(name)));
871 ListAdd(args, MkExpConstant("0"));
873 stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddClassProperty")), args)));
874 ListAdd(registerModuleBody.compound.statements, stmt);
879 extern External curExternal;
881 void GetNameSpaceString(NameSpace ns, char * string)
884 GetNameSpaceString(ns.parent, string);
887 strcat(string, ns.name);
888 strcat(string, "::");
892 // *******************************************************************
893 static void ProcessClass(ClassType classType, OldList definitions, Symbol symbol, OldList baseSpecs, OldList enumValues, OldList defs, External external, AccessMode declMode)
896 Class regClass = symbol.registered;
900 classType = regClass.type;
901 if(classType == enumClass && enumValues && (inCompiler || !buildingECERECOMModule))
904 for(e = enumValues.first; e; e = e.next)
913 e.exp.destType = destType;
915 // Set parsingType to avoid producing errors
917 ProcessExpressionType(e.exp);
922 destType.kind = TypeKind::classType;
923 destType._class = symbol;
924 ProcessExpressionType(e.exp);
926 ComputeExpression(e.exp);
927 if(e.exp.isConstant && /*e.exp.expType.kind == intType*/ e.exp.type == constantExp)
929 Operand op = GetOperand(e.exp);
931 // TODO: 64 BIT ENUM SUPPORT...
934 case charType: value = op.c; break;
935 case shortType: value = op.s; break;
936 default: value = op.i;
939 // value = op.i; //strtol(e.exp.string, null, 0);
940 eEnum_AddFixedValue(regClass, e.id.string, value);
944 eEnum_AddValue(regClass, e.id.string);
947 eEnum_AddValue(regClass, e.id.string);
951 // Process all functions
952 if(definitions != null)
956 for(def = definitions.first; def; def = def.next)
958 if(def.type == propertyWatchClassDef && def.propertyWatch)
960 PropertyWatch propWatch = def.propertyWatch;
962 char watcherName[1024];
964 Statement stmt = MkExpressionStmt(MkList());
967 sprintf(watcherName,"__ecerePropertySelfWatcher_%d", propWatcherID++);
968 for(propID = propWatch.properties->first; propID; propID = propID.next)
970 strcat(watcherName, "_");
971 strcat(watcherName, propID.string);
974 // TESTING THIS STUFF... BEWARE OF SYMBOL ID ISSUES
975 decl = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(watcherName)), MkListOne(MkTypeName(MkListOne(MkSpecifier(VOID)), null)));
976 func = MkClassFunction(MkListOne(MkSpecifier(VOID)), null, decl, null);
977 ProcessClassFunctionBody(func, propWatch.compound);
979 // TESTING WITH SAME SYMBOL ID AS CLASS
983 idCode = symbol.idCode;
985 excludedSymbols->Add(decl.symbol);
988 func.idCode = symbol.idCode;
989 func.dontMangle = true;
991 // Create a declaration above for constructor to see
993 External externalDecl = MkExternalDeclaration(null);
995 OldList * specifiers = MkList();
996 ListAdd(specifiers, MkSpecifier(STATIC));
997 ListAdd(specifiers, MkSpecifier(VOID));
999 ast->Insert(curExternal.prev, externalDecl);
1001 decl = MkDeclaration(specifiers,
1002 MkListOne(MkInitDeclarator(MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(watcherName)),
1003 MkListOne(MkTypeName(MkListOne(MkSpecifierName(regClass.fullName)), null))), null)));
1004 externalDecl.declaration = decl;
1005 if(decl.symbol && !decl.symbol.methodExternal)
1007 decl.symbol.methodExternal = externalDecl;
1009 // PATCHED THIS, 2 SYMBOLS WERE THERE.. THIS ONE HAD AN ID TOO BIG
1010 decl.symbol.id = symbol.id;
1011 decl.symbol.idCode = symbol.idCode;
1015 propWatch.compound = null;
1016 definitions.Insert(null, MkClassDefFunction(func));
1018 stmt.type = expressionStmt;
1019 stmt.expressions = MkList();
1021 for(propID = propWatch.properties->first; propID; propID = propID.next)
1023 Property prop = eClass_FindProperty(regClass, propID.string, privateModule);
1026 // eProperty_SelfWatch(_class, name, callback);
1027 OldList * args = MkList();
1028 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1029 ListAdd(args, MkExpString(QMkString(propID.string)));
1030 ListAdd(args, MkExpIdentifier(MkIdentifier(watcherName)));
1032 ListAdd(stmt.expressions, MkExpCall(MkExpIdentifier(MkIdentifier("eProperty_SelfWatch")), args));
1035 Compiler_Error("Property %s not found in class %s\n", propID.string, regClass.fullName);
1037 FreePropertyWatch(def.propertyWatch);
1038 def.propertyWatch = (PropertyWatch)stmt; // Store this here to use it after CreateRegisterModuleBody is done
1040 // ListAdd(statements, stmt);
1045 for(def = definitions.first; def; def = def.next)
1047 if(def.type == functionClassDef)
1049 ProcessClassFunction(regClass, def.function, defs, external.prev, declMode == staticAccess);
1054 // Make the RegisterClass section
1056 if(inCompiler && symbol.id != MAXINT && regClass)
1059 OldList * args = MkList();
1062 char * registerFunction = null;
1063 AccessMode inheritanceAccess = publicAccess;
1065 CreateRegisterModuleBody();
1067 curExternal = registerModuleExternal;
1070 switch(regClass.type)
1072 case structClass: ListAdd(args, MkExpIdentifier(MkIdentifier("structClass"))); break;
1073 case bitClass: ListAdd(args, MkExpIdentifier(MkIdentifier("bitClass"))); break;
1074 case enumClass: ListAdd(args, MkExpIdentifier(MkIdentifier("enumClass"))); break;
1075 case noHeadClass: ListAdd(args, MkExpIdentifier(MkIdentifier("noHeadClass"))); break;
1076 case unitClass: ListAdd(args, MkExpIdentifier(MkIdentifier("unitClass"))); break;
1077 case normalClass: ListAdd(args, MkExpIdentifier(MkIdentifier("normalClass"))); break;
1081 char nameSpace[1024] = "";
1082 char className[1024] = "";
1084 GetNameSpaceString(regClass.nameSpace, nameSpace);
1086 if(declMode == staticAccess)
1088 GetLastDirectory(sourceFile, className);
1089 ChangeCh(className, '.', '_');
1090 strcat(className, "}");
1092 strcat(className, nameSpace);
1093 strcat(className, regClass.name);
1094 string = QMkString(className);
1095 ListAdd(args, MkExpString(string));
1101 char * string = QMkString(regClass.base.name);
1102 ListAdd(args, regClass.base ? MkExpString(string) :
1103 MkExpConstant("0"));
1108 if(baseSpecs != null)
1110 Type baseType = ProcessType(baseSpecs, null);
1111 if(baseType.kind != structType && baseType.kind != unionType)
1113 char baseName[1024] = "";
1115 if(baseType.kind == TypeKind::classType && baseType._class && baseType._class.isStatic)
1117 // TODO: Handle static classes and complex declarators...
1118 GetLastDirectory(sourceFile, baseName);
1119 ChangeCh(baseName, '.', '_');
1120 strcat(baseName, "}");
1121 strcat(baseName, baseType._class.string);
1124 PrintType(baseType, baseName, false, true);
1126 string = QMkString(baseName);
1127 ListAdd(args, MkExpString(string));
1131 ListAdd(args, MkExpConstant("0"));
1133 if(((Specifier)baseSpecs.first).type == baseSpecifier && ((Specifier)baseSpecs.first).specifier == PRIVATE)
1134 inheritanceAccess = privateAccess;
1137 ListAdd(args, MkExpConstant("0"));
1139 //ListAdd(args, class.declaredStruct ? MkExpTypeSize(MkTypeName(MkListOne(
1140 //MkSpecifierName(class.structName)), null)) : MkExpConstant("0"));
1142 if(regClass.type == structClass || regClass.type == normalClass || regClass.type == noHeadClass)
1144 // Check if we have a data member in this class
1145 DataMember member = null;
1148 for(base = regClass.base; base && base.type != systemClass; base = base.next)
1150 for(member = base.membersAndProperties.first; member; member = member.next)
1151 if(!member.isProperty)
1158 if(regClass.type == structClass && symbol.declaredStruct && member)
1160 char baseStructName[1024];
1161 baseStructName[0] = 0;
1162 // TESTING THIS HERE
1163 // FullClassNameCat(baseStructName, regClass.base.fullName, false);
1164 strcpy(baseStructName, (regClass.base.templateClass ? regClass.base.templateClass : regClass.base).fullName);
1166 ListAdd(args, MkExpOp(
1167 MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(structSpecifier, MkIdentifier(symbol.structName), null)), null)), '-',
1168 MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(structSpecifier, MkIdentifier(baseStructName), null)), null))));
1171 ListAdd(args, symbol.declaredStruct ? MkExpTypeSize(MkTypeName(MkListOne(
1172 MkStructOrUnion(structSpecifier, MkIdentifier(symbol.structName), null)), null)) : MkExpConstant("0"));
1176 ListAdd(args, MkExpConstant("0"));
1179 //if(regClass.type == normalClass)
1181 char classDataStructName[1024];
1182 strcpy(classDataStructName, "__ecereClassData_");
1183 FullClassNameCat(classDataStructName, symbol.string, false);
1185 ListAdd(args, symbol.classData ? MkExpTypeSize(MkTypeName(MkListOne(
1186 MkStructOrUnion(structSpecifier, MkIdentifier(classDataStructName), null)), null)) : MkExpConstant("0"));
1189 // TODO: Support Class Data for all other types of classes
1190 ListAdd(args, MkExpConstant("0"));
1193 if(regClass.type == normalClass || regClass.type == noHeadClass)
1196 ListAdd(args, symbol.needConstructor ?
1197 MkExpIdentifier(MkIdentifier(symbol.constructorName)) :
1198 MkExpConstant("0"));
1200 ListAdd(args, symbol.needDestructor ?
1201 MkExpIdentifier(MkIdentifier(symbol.destructorName)) :
1202 MkExpConstant("0"));
1206 // TODO: Support Constructors / Destructors for structs
1209 ListAdd(args, MkExpConstant("0"));
1211 ListAdd(args, MkExpConstant("0"));
1215 ListAdd(args, MkExpIdentifier(MkIdentifier("module")));
1221 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1224 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1228 ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess")));
1233 switch(inheritanceAccess)
1236 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1240 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1244 registerFunction = "eSystem_RegisterClass";
1246 stmt = MkExpressionStmt(MkListOne(
1247 MkExpOp(MkExpIdentifier(MkIdentifier("class")), '=',
1248 MkExpCall((exp = MkExpIdentifier(MkIdentifier(registerFunction))), args))));
1250 ListAdd(registerModuleBody.compound.statements, stmt);
1253 stmt = MkIfStmt(MkListOne(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(symbol.className)))),
1254 MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol.className)), '=',
1255 MkExpIdentifier(MkIdentifier("class"))))), null);
1258 stmt = MkIfStmt(MkListOne(
1260 MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP,
1261 MkExpMember(MkExpIdentifier(MkIdentifier("__thisModule")), MkIdentifier("application"))), AND_OP, MkExpIdentifier(MkIdentifier("class")))),
1262 MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol.className)), '=',
1263 MkExpIdentifier(MkIdentifier("class"))))), null);
1265 stmt = MkIfStmt(MkListOne(
1266 MkExpOp(MkExpOp(null, '!', MkExpIdentifier(MkIdentifier(symbol.className))), AND_OP, MkExpIdentifier(MkIdentifier("class")))),
1267 MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol.className)), '=',
1268 MkExpIdentifier(MkIdentifier("class"))))), null);
1271 ListAdd(registerModuleBody.compound.statements, stmt);
1273 if(external && external.type == classExternal && external._class.deleteWatchable)
1275 args = MkListOne(MkExpIdentifier(MkIdentifier("class")));
1276 stmt = MkExpressionStmt(MkListOne(
1277 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_DestructionWatchable")), args)));
1278 ListAdd(registerModuleBody.compound.statements, stmt);
1281 // Add Virtual Methods
1284 Class base = regClass.base;
1286 for(c = 0; c<base.vTblSize; c++)
1288 Symbol method = (Symbol)regClass._vTbl[c];
1289 if((void *) method != DummyMethod && base._vTbl[c] != (void *)method ) // TOLOOKAT: Module check here?
1291 External external = method.methodExternal;
1292 OldList * args = MkList();
1293 Identifier id = external.function ? GetDeclId(external.function.declarator) : null;
1296 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1299 //char * string = QMkString(method.string);
1301 char * string = QMkString(method.method.name);
1302 ListAdd(args, MkExpString(string));
1306 ListAdd(args, MkExpConstant("0"));
1308 ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(
1312 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1314 exp.expType = Type { refCount = 1 };
1315 stmt = MkExpressionStmt(MkListOne(
1316 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMethod")), args)));
1317 ListAdd(registerModuleBody.compound.statements, stmt);
1322 // Add Virtual Methods in order
1325 for(c = regClass.base ? regClass.base.vTblSize : 0; c < regClass.vTblSize; c++)
1327 for(method = (Method)regClass.methods.first; method; method = (Method)((BTNode)method).next)
1329 if(method.type == virtualMethod && method._class == regClass && method.vid == c)
1334 //External external = method->symbol ? ((Symbol)method.symbol).methodExternal : null;
1335 External external = method.symbol ? ((Symbol)method.symbol).methodCodeExternal : null;
1336 OldList * args = MkList();
1337 Identifier id = (external && external.function) ? GetDeclId(external.function.declarator) : null;
1340 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1343 char * string = QMkString(method.name);
1344 ListAdd(args, MkExpString(string));
1349 char * string = QMkString(method.dataTypeString);
1350 ListAdd(args, MkExpString(string));
1354 if(id && external.function.body)
1356 ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(id.string))));
1357 exp.expType = Type { refCount = 1 };
1361 ListAdd(args, (exp = MkExpConstant("0")));
1365 switch(method.memberAccess)
1368 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1371 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1375 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1379 //sprintf(name, "__ecereVMethodID_%s_%s", method._class.fullName, method.name);
1380 strcpy(name, "__ecereVMethodID_");
1381 FullClassNameCat(name, method._class.fullName, false);
1383 strcat(name, method.name);
1385 exp = /*MkExpPointer(*/MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddVirtualMethod")), args)/*, MkIdentifier("vid"))*/;
1387 exp->expType = eSystem_New(sizeof(Type));
1388 exp->expType->refCount++;
1389 exp->expType->isSigned = true;
1390 exp->expType->kind = TypeInt;
1393 stmt = MkExpressionStmt(MkListOne(/*
1394 MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=', */exp/*)*/));
1396 DeclareMethod(method, name);
1398 ListAdd(registerModuleBody.compound.statements, stmt);
1405 // Add Public Methods (all for now)
1406 for(method = (Method)regClass.methods.first; method; method = (Method)((BTNode)method).next)
1408 if(method.type == virtualMethod && method._class == regClass);
1409 else if(method.memberAccess == publicAccess || !method.dataTypeString)
1411 //External external = method.symbol ? ((Symbol )method.symbol).methodExternal : null;
1412 External external = method.symbol ? ((Symbol )method.symbol).methodCodeExternal : null;
1413 OldList * args = MkList();
1414 Identifier id = (external && external.function) ? GetDeclId(external.function.declarator) : null;
1417 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1420 char * string = QMkString(method.name);
1421 ListAdd(args, MkExpString(string));
1426 char * string = QMkString(method.dataTypeString);
1427 ListAdd(args, MkExpString(string));
1431 if(id && external.function.body)
1433 ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(
1435 exp.expType = Type { refCount = 1 };
1439 ListAdd(args, (exp = MkExpConstant("0")));
1443 switch(method.memberAccess)
1446 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1449 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1453 ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess")));
1457 stmt = MkExpressionStmt(MkListOne(
1458 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMethod")), args)));
1459 ListAdd(registerModuleBody.compound.statements, stmt);
1463 RegisterMembersAndProperties(regClass, false, "class", registerModuleBody);
1465 // Add Enumeration Values
1466 if(classType == enumClass)
1469 Class enumClass = eSystem_FindClass(privateModule, "enum");
1470 EnumClassData e = ACCESS_CLASSDATA(regClass, enumClass);
1472 for(value = e.values.first; value; value = value.next)
1474 OldList * args = MkList();
1477 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1480 char * string = QMkString(value.name);
1481 ListAdd(args, MkExpString(string));
1487 sprintf(temp, "%d", value.data);
1488 ListAdd(args, MkExpConstant(temp));
1491 stmt = MkExpressionStmt(MkListOne(
1492 MkExpCall(MkExpIdentifier(MkIdentifier("eEnum_AddFixedValue")), args)));
1493 ListAdd(registerModuleBody.compound.statements, stmt);
1497 // Add Template Parameters
1498 if(symbol.templateParams)
1500 TemplateParameter param;
1501 for(param = symbol.templateParams->first; param; param = param.next)
1503 OldList * args = MkList();
1506 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1510 char * string = QMkString(param.identifier.string);
1511 ListAdd(args, MkExpString(string));
1516 ListAdd(args, MkExpIdentifier(MkIdentifier((param.type == type) ? "type" : ((param.type == identifier) ? "identifier" : "expression"))));
1524 char * typeString = param.dataType ? StringFromSpecDecl(param.dataType.specifiers, param.dataType.decl) : null;
1525 char * string = QMkString(typeString);
1526 ListAdd(args, MkExpString(string));
1533 char memberTypeString[132] = "TemplateMemberType::";
1534 bool needClass = true;
1536 param.memberType.OnGetString(memberTypeString + strlen(memberTypeString), null, &needClass);
1538 MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer(null, null), null)),
1539 MkExpIdentifier(MkIdentifier(memberTypeString))));
1545 if(param.defaultArgument)
1547 OldList * members = MkList();
1552 char * typeString = param.defaultArgument.templateDatatype ?
1553 StringFromSpecDecl(param.defaultArgument.templateDatatype.specifiers, param.defaultArgument.templateDatatype.decl) : null;
1554 char * string = QMkString(typeString);
1556 members->Add(MkMemberInit(MkListOne(MkIdentifier("dataTypeString")), MkInitializerAssignment(MkExpString(string))));
1564 char memberString[1024];
1566 memberString[0] = '\0';
1568 if(param.defaultArgument.identifier._class)
1570 if(param.defaultArgument.identifier._class.type == templateTypeSpecifier)
1571 strcpy(memberString, param.defaultArgument.identifier._class.templateParameter.identifier.string);
1572 else if(param.defaultArgument.identifier._class.name)
1573 strcpy(memberString, param.defaultArgument.identifier._class.name);
1576 strcat(memberString, "::");
1578 strcat(memberString, param.defaultArgument.identifier.string);
1580 string = QMkString(memberString);
1582 // TOFIX: UNIONS ARE BROKEN FOR ASSIGNMENTS, USING dataTypeString INSTEAD
1583 // members->Add(MkMemberInit(MkListOne(MkIdentifier("memberString")), MkInitializerAssignment(MkExpString(string))));
1584 members->Add(MkMemberInit(MkListOne(MkIdentifier("dataTypeString")), MkInitializerAssignment(MkExpString(string))));
1592 OldList * ids = MkList();
1594 char * string = null;
1596 //ProcessExpressionType(param.defaultArgument.expression);
1597 //ComputeExpression(param.defaultArgument.expression);
1599 op = GetOperand(param.defaultArgument.expression);
1600 ui64String = PrintUInt64(op.ui64);
1601 ids->Add(MkIdentifier("expression"));
1602 ids->Add(MkIdentifier("ui64"));
1604 //string = QMkString(ui64String);
1605 members->Add(MkMemberInit(ids, MkInitializerAssignment(MkExpConstant(ui64String))));
1612 ListAdd(args, MkExpInstance(MkInstantiation(MkSpecifierName("ClassTemplateArgument"), null,
1613 MkListOne(MkMembersInitList(members)))));
1616 ListAdd(args, MkExpIdentifier(MkIdentifier("null")));
1618 stmt = MkExpressionStmt(MkListOne(
1619 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddTemplateParameter")), args)));
1620 ListAdd(registerModuleBody.compound.statements, stmt);
1622 stmt = MkExpressionStmt(MkListOne(
1623 MkExpCall(MkExpIdentifier(MkIdentifier("eClass_DoneAddingTemplateParameters")),
1624 MkListOne(MkExpIdentifier(MkIdentifier("class"))))));
1625 ListAdd(registerModuleBody.compound.statements, stmt);
1628 if(definitions != null)
1630 for(def = definitions.first; def; def = def.next)
1632 if(def.type == propertyWatchClassDef && def.propertyWatch)
1634 ListAdd(registerModuleBody.compound.statements, (Statement)def.propertyWatch);
1635 def.propertyWatch = null;
1637 else if(def.type == classDesignerClassDef)
1640 char className[1024];
1641 sprintf(className, "__ecereClass_%s", def.designer);
1642 MangleClassName(className);
1644 DeclareClass(FindClass(def.designer), className);
1647 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1648 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("designerClass")), '=',
1649 MkExpString(QMkString(def.designer))))), null);
1650 ListAdd(registerModuleBody.compound.statements, stmt);
1652 else if(def.type == classNoExpansionClassDef)
1654 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1655 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("noExpansion")), '=',
1656 MkExpConstant("1")))), null);
1657 ListAdd(registerModuleBody.compound.statements, stmt);
1659 else if(def.type == classFixedClassDef)
1661 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1662 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("fixed")), '=',
1663 MkExpConstant("1")))), null);
1664 ListAdd(registerModuleBody.compound.statements, stmt);
1666 regClass.fixed = true;
1668 else if(def.type == designerDefaultPropertyClassDef)
1670 stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(
1671 MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("defaultProperty")), '=',
1672 MkExpString(QMkString(def.defaultProperty.string))))), null);
1673 ListAdd(registerModuleBody.compound.statements, stmt);
1675 else if(def.type == classPropertyValueClassDef)
1677 OldList * args = MkList();
1678 ListAdd(args, MkExpIdentifier(MkIdentifier("class")));
1679 ListAdd(args, MkExpString(QMkString(def.id.string)));
1680 ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(INT)), null), def.initializer.exp));
1682 def.initializer.exp = null;
1684 stmt = MkExpressionStmt(MkListOne(
1685 MkExpCall(MkExpIdentifier(MkIdentifier("ecere::com::eClass_SetProperty")), args)));
1687 ListAdd(registerModuleBody.compound.statements, stmt);
1695 public void ProcessClassDefinitions()
1697 External external, next;
1699 CreateRegisterModuleBody();
1702 // (Need to do those things after in case something is not yet defined)
1703 for(external = ast->first; external; external = next)
1705 next = external.next;
1706 curExternal = external;
1707 if(external.type == classExternal)
1709 ClassDefinition _class = external._class;
1710 if(_class.definitions)
1712 ProcessClass(normalClass, _class.definitions, _class.symbol, _class.baseSpecs, null, ast, external, _class.declMode);
1716 ast->Remove(external);
1717 FreeExternal(external);
1720 else if(external.type == functionExternal)
1723 if(external.symbol && !external.symbol.type.thisClass)
1724 external.symbol.type.staticMethod = true;
1728 FunctionDefinition function = external.function;
1732 if(!strcmp(function.declarator.symbol.string, "__on_register_module"))
1734 ListAdd(registerModuleBody.compound.statements, function.body);
1735 function.body.compound.context.parent = registerModuleBody.compound.context;
1736 ast->Remove(external);
1737 function.body = null;
1738 FreeExternal(external);
1742 if(function.declMode != privateAccess && function.declMode != publicAccess) continue;
1746 CreateRegisterModuleBody();
1750 char * string = QMkString(function.declarator.symbol.string);
1751 ListAdd(args, MkExpString(string));
1758 char type[1024] = "";
1759 PrintType(function.declarator.symbol.type, type, true, true);
1760 string = QMkString(type);
1761 ListAdd(args, MkExpString(string));
1767 ListAdd(args, MkExpIdentifier(MkIdentifier(function.declarator.symbol.string)));
1771 ListAdd(args, MkExpIdentifier(MkIdentifier("module")));
1774 switch(function.declMode)
1777 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1780 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1784 ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess")));
1788 stmt = MkExpressionStmt(MkListOne(
1789 MkExpCall((MkExpIdentifier(MkIdentifier("eSystem_RegisterFunction"))), args)));
1791 ListAdd(registerModuleBody.compound.statements, stmt);
1794 else if(external.type == declarationExternal)
1796 Declaration declaration = external.declaration;
1800 if(external.symbol.type && external.symbol.type.kind == functionType && !external.symbol.type.thisClass)
1801 external.symbol.type.staticMethod = true;
1804 if(external.symbol && declaration.type == initDeclaration)
1806 if(declaration.specifiers)
1808 Specifier specifier;
1809 bool removeExternal = false;
1811 for(specifier = declaration.specifiers->first; specifier; specifier = specifier.next)
1813 if((specifier.type == enumSpecifier || specifier.type == structSpecifier || specifier.type == unionSpecifier) && specifier.id && specifier.id.string &&
1814 (declaration.declMode || specifier.baseSpecs || (specifier.type == enumSpecifier && specifier.definitions)))
1816 Symbol symbol = FindClass(specifier.id.string);
1819 ClassType classType;
1820 if(specifier.type == enumSpecifier)
1821 classType = enumClass;
1823 classType = structClass;
1825 removeExternal = true;
1826 // Transfer Context over to Symbol
1827 symbol.ctx = specifier.ctx;
1828 specifier.ctx = null;
1830 ProcessClass(classType, specifier.definitions, symbol, specifier.baseSpecs, specifier.list,ast, external, declaration.declMode);
1834 if(inCompiler && removeExternal)
1836 ast->Remove(external);
1837 FreeExternal(external);
1841 else if(declaration.type == defineDeclaration)
1843 if(inCompiler && declaration.declMode != staticAccess)
1846 OldList * args = MkList();
1848 CreateRegisterModuleBody();
1852 char * string = QMkString(declaration.id.string);
1853 ListAdd(args, MkExpString(string));
1860 char type[1024] = "";
1861 PrintExpression(declaration.exp, type);
1862 string = QMkString(type);
1863 ListAdd(args, MkExpString(string));
1868 ListAdd(args, MkExpIdentifier(MkIdentifier("module")));
1871 switch(declaration.declMode)
1874 ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess")));
1877 ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess")));
1881 ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess")));
1885 stmt = MkExpressionStmt(MkListOne(
1886 MkExpCall((MkExpIdentifier(MkIdentifier("eSystem_RegisterDefine"))), args)));
1888 ListAdd(registerModuleBody.compound.statements, stmt);