Mercurial > projects > qtd
comparison generator/dgenerator.cpp @ 342:c887282e1590 qtd.0.5
removed enum experiment leftover
author | maxter <spambox@d-coding.com> |
---|---|
date | Thu, 13 May 2010 17:11:04 +0300 |
parents | 4920ef9206fe |
children | 96a75b1e5b26 |
comparison
equal
deleted
inserted
replaced
341:4920ef9206fe | 342:c887282e1590 |
---|---|
286 s << " } // end of enum " << d_enum->name() << endl << endl; | 286 s << " } // end of enum " << d_enum->name() << endl << endl; |
287 } | 287 } |
288 | 288 |
289 void DGenerator::writeEnumAliases(QTextStream &s, const AbstractMetaEnum *d_enum) | 289 void DGenerator::writeEnumAliases(QTextStream &s, const AbstractMetaEnum *d_enum) |
290 { | 290 { |
291 FlagsTypeEntry *flags = d_enum->typeEntry()->flags(); | |
292 if (flags) | |
293 s << INDENT << "alias " << d_enum->name() << " " << flags->targetLangName() << ";" << endl << endl; | |
294 | |
295 const AbstractMetaEnumValueList &values = d_enum->values(); | 291 const AbstractMetaEnumValueList &values = d_enum->values(); |
296 for (int i=0; i<values.size(); ++i) { | 292 for (int i=0; i<values.size(); ++i) { |
297 AbstractMetaEnumValue *enum_value = values.at(i); | 293 AbstractMetaEnumValue *enum_value = values.at(i); |
298 | 294 |
299 if (!d_enum->typeEntry()->isEnumValueRejected(enum_value->name())) | 295 if (!d_enum->typeEntry()->isEnumValueRejected(enum_value->name())) |
485 s << ";" << endl; | 481 s << ";" << endl; |
486 } | 482 } |
487 } | 483 } |
488 | 484 |
489 static QString function_call_for_ownership(TypeSystem::Ownership owner) | 485 static QString function_call_for_ownership(TypeSystem::Ownership owner) |
490 { | 486 { |
491 if (owner == TypeSystem::CppOwnership) { | 487 if (owner == TypeSystem::CppOwnership) { |
492 return "__setFlags(QtdObjectFlags.nativeOwnership, true)"; | 488 return "__setFlags(QtdObjectFlags.nativeOwnership, true)"; |
493 } else /* qtd 2 if (owner == TypeSystem::TargetLangOwnership) */ { | 489 } else /* qtd 2 if (owner == TypeSystem::TargetLangOwnership) */ { |
494 return "__setFlags(QtdObjectFlags.nativeOwnership, false)"; | 490 return "__setFlags(QtdObjectFlags.nativeOwnership, false)"; |
495 }/* else if (owner == TypeSystem::DefaultOwnership) { | 491 }/* else if (owner == TypeSystem::DefaultOwnership) { |
2210 // Signals | 2206 // Signals |
2211 if (d_class->isQObject()) | 2207 if (d_class->isQObject()) |
2212 { | 2208 { |
2213 AbstractMetaFunctionList signal_funcs = signalFunctions(d_class, false); | 2209 AbstractMetaFunctionList signal_funcs = signalFunctions(d_class, false); |
2214 writeSignalSignatures(s, d_class, signal_funcs); | 2210 writeSignalSignatures(s, d_class, signal_funcs); |
2215 | 2211 |
2216 foreach (AbstractMetaFunction *signal, signal_funcs) | 2212 foreach (AbstractMetaFunction *signal, signal_funcs) |
2217 { | 2213 { |
2218 writeSignal(s, signal); | 2214 writeSignal(s, signal); |
2219 if(!signal->isPrivate()) | 2215 if(!signal->isPrivate()) |
2220 writeFunction(s, signal); | 2216 writeFunction(s, signal); |
2399 writeCloneFunction(s, d_class); | 2395 writeCloneFunction(s, d_class); |
2400 } | 2396 } |
2401 */ | 2397 */ |
2402 s << "}" << endl; // end of class scope | 2398 s << "}" << endl; // end of class scope |
2403 | 2399 |
2404 /* ---------------- injected free code ----------------*/ | 2400 /* ---------------- injected free code ----------------*/ |
2405 const ComplexTypeEntry *class_type = d_class->typeEntry(); | 2401 const ComplexTypeEntry *class_type = d_class->typeEntry(); |
2406 Q_ASSERT(class_type); | 2402 Q_ASSERT(class_type); |
2407 | 2403 |
2408 CodeSnipList code_snips = class_type->codeSnips(); | 2404 CodeSnipList code_snips = class_type->codeSnips(); |
2409 foreach (const CodeSnip &snip, code_snips) { | 2405 foreach (const CodeSnip &snip, code_snips) { |
2410 if (!d_class->isInterface() && snip.language == TypeSystem::TargetLangFreeCode) { | 2406 if (!d_class->isInterface() && snip.language == TypeSystem::TargetLangFreeCode) { |
2411 s << endl; | 2407 s << endl; |
2412 snip.formattedCode(s, INDENT); | 2408 snip.formattedCode(s, INDENT); |
2413 } | 2409 } |
2414 } | 2410 } |
2415 /* --------------------------------------------------- */ | 2411 /* --------------------------------------------------- */ |
2416 | 2412 |
2417 interfaces = d_class->interfaces(); | 2413 interfaces = d_class->interfaces(); |
2418 if (!interfaces.isEmpty()) { | 2414 if (!interfaces.isEmpty()) { |
2419 for (int i=0; i<interfaces.size(); ++i) { | 2415 for (int i=0; i<interfaces.size(); ++i) { |
2432 { | 2428 { |
2433 Indentation indent(INDENT); | 2429 Indentation indent(INDENT); |
2434 QString hasShellFlag = d_class->generateShellClass() ? " | QtdObjectFlags.hasShell" : ""; | 2430 QString hasShellFlag = d_class->generateShellClass() ? " | QtdObjectFlags.hasShell" : ""; |
2435 s << INDENT << "public this(void* native_id, QtdObjectFlags flags = QtdObjectFlags.nativeOwnership) {" << endl | 2431 s << INDENT << "public this(void* native_id, QtdObjectFlags flags = QtdObjectFlags.nativeOwnership) {" << endl |
2436 << INDENT << " super(native_id, flags);" << endl << endl; | 2432 << INDENT << " super(native_id, flags);" << endl << endl; |
2437 | 2433 |
2438 s << INDENT << "}" << endl << endl; | 2434 s << INDENT << "}" << endl << endl; |
2439 | 2435 |
2440 uint exclude_attributes = AbstractMetaAttributes::Native | AbstractMetaAttributes::Abstract; | 2436 uint exclude_attributes = AbstractMetaAttributes::Native | AbstractMetaAttributes::Abstract; |
2441 uint include_attributes = 0; | 2437 uint include_attributes = 0; |
2442 AbstractMetaFunctionList functions = d_class->queryFunctions(AbstractMetaClass::NormalFunctions | AbstractMetaClass::AbstractFunctions | AbstractMetaClass::NonEmptyFunctions | AbstractMetaClass::NotRemovedFromTargetLang); | 2438 AbstractMetaFunctionList functions = d_class->queryFunctions(AbstractMetaClass::NormalFunctions | AbstractMetaClass::AbstractFunctions | AbstractMetaClass::NonEmptyFunctions | AbstractMetaClass::NotRemovedFromTargetLang); |
2900 writeMetaMethodSignatures(s, "__signalSignatures", signal_funcs); | 2896 writeMetaMethodSignatures(s, "__signalSignatures", signal_funcs); |
2901 | 2897 |
2902 s << INDENT << "int signalSignature(int signalId, ref stringz signature) {" << endl; | 2898 s << INDENT << "int signalSignature(int signalId, ref stringz signature) {" << endl; |
2903 { | 2899 { |
2904 Indentation indent(INDENT); | 2900 Indentation indent(INDENT); |
2905 | 2901 |
2906 if (d_class->name() != "QObject") | 2902 if (d_class->name() != "QObject") |
2907 { | 2903 { |
2908 s << INDENT << "signalId = super.signalSignature(signalId, signature);" << endl | 2904 s << INDENT << "signalId = super.signalSignature(signalId, signature);" << endl |
2909 << INDENT << "if (signature)" << endl | 2905 << INDENT << "if (signature)" << endl |
2910 << INDENT << " return signalId;" << endl; | 2906 << INDENT << " return signalId;" << endl; |
2911 } | 2907 } |
2912 | 2908 |
2913 s << INDENT << "if (signalId < __signalSignatures.length)" << endl | 2909 s << INDENT << "if (signalId < __signalSignatures.length)" << endl |
2914 << INDENT << " signature = __signalSignatures[signalId].ptr;" << endl | 2910 << INDENT << " signature = __signalSignatures[signalId].ptr;" << endl |
2915 << INDENT << "else" << endl | 2911 << INDENT << "else" << endl |
2916 << INDENT << " signalId -= __signalSignatures.length;" << endl | 2912 << INDENT << " signalId -= __signalSignatures.length;" << endl |
2917 << INDENT << "return signalId;" << endl; | 2913 << INDENT << "return signalId;" << endl; |