Mercurial > projects > qtd
comparison generator/dgenerator.cpp @ 293:8627891e4556 signals
QList updates
author | eldar |
---|---|
date | Fri, 13 Nov 2009 19:09:28 +0000 |
parents | 19498f420252 |
children | bb37b0ed94c9 |
comparison
equal
deleted
inserted
replaced
292:19498f420252 | 293:8627891e4556 |
---|---|
1714 | 1714 |
1715 s << "// signal handlers" << endl; | 1715 s << "// signal handlers" << endl; |
1716 foreach(AbstractMetaFunction *signal, signal_funcs) { | 1716 foreach(AbstractMetaFunction *signal, signal_funcs) { |
1717 QString sigExternName = signalExternName(d_class, signal); | 1717 QString sigExternName = signalExternName(d_class, signal); |
1718 | 1718 |
1719 s << "private " << attr << "extern(C) void " << sigExternName << "_connect(void* native_id);" << endl; | |
1720 s << "private " << attr << "extern(C) void " << sigExternName << "_disconnect(void* native_id);" << endl; | |
1721 /* | 1719 /* |
1722 QString extra_args; | 1720 QString extra_args; |
1723 | 1721 |
1724 foreach (AbstractMetaArgument *argument, arguments) { | 1722 foreach (AbstractMetaArgument *argument, arguments) { |
1725 if(argument->type()->isContainer()) { | 1723 if(argument->type()->isContainer()) { |
1730 } | 1728 } |
1731 } | 1729 } |
1732 */ | 1730 */ |
1733 AbstractMetaArgumentList arguments = signal->arguments(); | 1731 AbstractMetaArgumentList arguments = signal->arguments(); |
1734 | 1732 |
1735 s << "private extern(C) void " << sigExternName << "_handle(void* d_entity, void** args) {" << endl; | 1733 s << "/*private extern(C) void " << sigExternName << "_handle(void* d_entity, void** args) {" << endl; |
1736 { | 1734 { |
1737 Indentation indent(INDENT); | 1735 Indentation indent(INDENT); |
1738 s << INDENT << "auto d_object = cast(" << d_class->name() << ") d_entity;" << endl; | 1736 s << INDENT << "auto d_object = cast(" << d_class->name() << ") d_entity;" << endl; |
1739 int sz = arguments.count(); | 1737 int sz = arguments.count(); |
1740 | 1738 |
1779 s << arg_name; | 1777 s << arg_name; |
1780 } | 1778 } |
1781 | 1779 |
1782 s << ");" << endl; | 1780 s << ");" << endl; |
1783 } | 1781 } |
1784 s << "}" << endl; | 1782 s << "}*/" << endl; |
1785 } | 1783 } |
1786 } | 1784 } |
1787 | 1785 |
1788 AbstractMetaFunctionList DGenerator::generatedClassFunctions(const AbstractMetaClass *d_class) | 1786 AbstractMetaFunctionList DGenerator::generatedClassFunctions(const AbstractMetaClass *d_class) |
1789 { | 1787 { |
2165 s << INDENT << " " << d_class->package() << ".QtJambi_LibraryInitializer.init();" << endl | 2163 s << INDENT << " " << d_class->package() << ".QtJambi_LibraryInitializer.init();" << endl |
2166 << INDENT << "}" << endl; | 2164 << INDENT << "}" << endl; |
2167 } | 2165 } |
2168 */ | 2166 */ |
2169 | 2167 |
2170 // Enums aliaases | 2168 // Enums aliases |
2171 foreach (AbstractMetaEnum *d_enum, d_class->enums()) | 2169 foreach (AbstractMetaEnum *d_enum, d_class->enums()) |
2172 writeEnumAlias(s, d_enum); | 2170 writeEnumAlias(s, d_enum); |
2173 | 2171 |
2174 // Signals | 2172 // Signals |
2175 if (d_class->isQObject()) | 2173 if (d_class->isQObject()) |
2222 foreach (const AbstractMetaField *field, fields) { | 2220 foreach (const AbstractMetaField *field, fields) { |
2223 if (field->wasPublic() || (field->wasProtected() && !d_class->isFinal())) | 2221 if (field->wasPublic() || (field->wasProtected() && !d_class->isFinal())) |
2224 writeFieldAccessors(s, field); | 2222 writeFieldAccessors(s, field); |
2225 } | 2223 } |
2226 | 2224 |
2227 /* qtd | |
2228 | |
2229 // the static fromNativePointer function... | |
2230 if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) { | |
2231 s << endl | |
2232 << INDENT << "public static native " << d_class->name() << " fromNativePointer(" | |
2233 << "QNativePointer nativePointer);" << endl; | |
2234 } | |
2235 | |
2236 if (d_class->isQObject()) { | |
2237 s << endl; | |
2238 if (TypeDatabase::instance()->includeEclipseWarnings()) | |
2239 s << INDENT << "@SuppressWarnings(\"unused\")" << endl; | |
2240 | |
2241 s << INDENT << "private static native long originalMetaObject();" << endl; | |
2242 } | |
2243 | |
2244 // The __qt_signalInitialization() function | |
2245 if (signal_funcs.size() > 0) { | |
2246 s << endl | |
2247 << INDENT << "@Override" << endl | |
2248 << INDENT << "@QtBlockedSlot protected boolean __qt_signalInitialization(String name) {" << endl | |
2249 << INDENT << " return (__qt_signalInitialization(nativeId(), name)" << endl | |
2250 << INDENT << " || super.__qt_signalInitialization(name));" << endl | |
2251 << INDENT << "}" << endl | |
2252 << endl | |
2253 << INDENT << "@QtBlockedSlot" << endl | |
2254 << INDENT << "private native boolean __qt_signalInitialization(long ptr, String name);" << endl; | |
2255 } | |
2256 */ | |
2257 if (d_class->isQObject()) | 2225 if (d_class->isQObject()) |
2258 writeQObjectFunctions(s, d_class); | 2226 writeQObjectFunctions(s, d_class); |
2227 | |
2228 if (ctype->isObject() && !ctype->isQObject()) // conversion function wrapper to be consistent with QObject | |
2229 { // some code duplication, remove when there is a better mechanism for Object type conversions | |
2230 QString class_name = ctype->name(); | |
2231 QString return_type_name = class_name; | |
2232 if(ctype->designatedInterface()) | |
2233 return_type_name = ctype->designatedInterface()->name(); | |
2234 s << " static " << return_type_name << " __getObject(void* nativeId) {" << endl | |
2235 << " return qtd_" << class_name << "_from_ptr(nativeId);" << endl | |
2236 << " }" << endl << endl; | |
2237 } | |
2259 | 2238 |
2260 // flag to mark the type of class (to use in templates to convert arguments) | 2239 // flag to mark the type of class (to use in templates to convert arguments) |
2261 if (d_class->baseClassName().isEmpty()) | 2240 if (d_class->baseClassName().isEmpty()) |
2262 { | 2241 { |
2263 if (d_class->typeEntry()->isQObject()) | 2242 if (d_class->typeEntry()->isQObject()) |
2267 else if (d_class->typeEntry()->isValue()) | 2246 else if (d_class->typeEntry()->isValue()) |
2268 s << INDENT << "public alias void __isValueType;" << endl << endl; | 2247 s << INDENT << "public alias void __isValueType;" << endl << endl; |
2269 } | 2248 } |
2270 | 2249 |
2271 s << INDENT << "public alias void __isQtType_" << d_class->name() << ";" << endl << endl; | 2250 s << INDENT << "public alias void __isQtType_" << d_class->name() << ";" << endl << endl; |
2251 | |
2252 // construction of a native copy of a Value | |
2253 if (d_class->typeEntry()->isValue() && d_class->hasCloneOperator()) | |
2254 { | |
2255 AbstractMetaFunction *copyCtor = d_class->copyConstructor(); | |
2256 if(copyCtor) | |
2257 s << INDENT << "static void* __constructNativeCopy(const void* orig) {" << endl | |
2258 << INDENT << " return " << copyCtor->marshalledName() << "(cast(void*)orig);" << endl | |
2259 << INDENT << "}" << endl << endl | |
2260 | |
2261 << INDENT << "static void* __constructPlacedNativeCopy(const void* orig, void* place) {" << endl | |
2262 << INDENT << " return qtd_" << d_class->name() << "_placed_copy(orig, place);" << endl | |
2263 << INDENT << "}" << endl << endl; | |
2264 } | |
2272 | 2265 |
2273 // Add dummy constructor for use when constructing subclasses | 2266 // Add dummy constructor for use when constructing subclasses |
2274 if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) { | 2267 if (!d_class->isNamespace() && !d_class->isInterface() && !fakeClass) { |
2275 s << endl | 2268 s << endl |
2276 << INDENT << "public " | 2269 << INDENT << "public " |
2529 if (d_class->hasVirtualFunctions() | 2522 if (d_class->hasVirtualFunctions() |
2530 && (d_class->typeEntry()->isObject() && !d_class->typeEntry()->isQObject()) ) | 2523 && (d_class->typeEntry()->isObject() && !d_class->typeEntry()->isQObject()) ) |
2531 s << endl << "extern (C) void *__" << d_class->name() << "_entity(void *q_ptr);" << endl << endl; | 2524 s << endl << "extern (C) void *__" << d_class->name() << "_entity(void *q_ptr);" << endl << endl; |
2532 } | 2525 } |
2533 | 2526 |
2527 if (d_class->typeEntry()->isValue() && d_class->hasCloneOperator()) | |
2528 { | |
2529 AbstractMetaFunction *copyCtor = d_class->copyConstructor(); | |
2530 if(copyCtor) | |
2531 s << "private extern(C) void* qtd_" << d_class->name() << "_placed_copy(const void* orig, void* place);" << endl << endl; | |
2532 } | |
2534 | 2533 |
2535 // if (d_class->needsConversionFunc) | 2534 // if (d_class->needsConversionFunc) |
2536 writeConversionFunction(s, d_class); | 2535 writeConversionFunction(s, d_class); |
2537 | 2536 |
2538 if (d_class->hasConstructors() && !d_class->isQObject()) | 2537 if (d_class->hasConstructors() && !d_class->isQObject()) |