[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-bindings
Subject: [Kde-bindings] SMOKE: Patch v3 - remove repeating in each module static functions of their core depe
From: Dimitar Dobrev <dpldobrev () yahoo ! com>
Date: 2012-12-12 17:44:13
Message-ID: 1355334253.71332.YahooMailNeo () web122404 ! mail ! ne1 ! yahoo ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
[Attachment #5 (text/html)]
<html><body><div style="color:#000; background-color:#fff; font-family:times new \
roman, new york, times, \
serif;font-size:12pt"><div></div></div></body></html>
--1869880960-735532025-1355334253=:71332--
["0001-Removed-repeating-in-each-module-static-functions-of.patch" (application/octet-stream)]
From 149aabea1fab932855a4812ba57e3a271a386450 Mon Sep 17 00:00:00 2001
From: Dimitar Dobrev <dpldobrev@yahoo.com>
Date: Tue, 11 Dec 2012 23:01:22 +0200
Subject: [PATCH] Removed repeating in each module static functions of their
core dependency.
Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
---
generators/smoke/CMakeLists.txt | 2 +-
generators/smoke/helpers.cpp | 80 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/generators/smoke/CMakeLists.txt b/generators/smoke/CMakeLists.txt
index a49573a..b83628f 100644
--- a/generators/smoke/CMakeLists.txt
+++ b/generators/smoke/CMakeLists.txt
@@ -7,7 +7,7 @@ set(generator_smoke_SRC
helpers.cpp)
add_library(generator_smoke MODULE ${generator_smoke_SRC})
-target_link_libraries(generator_smoke ${QT_QTCORE_LIBRARY} ${QT_QTXML_LIBRARY} \
smokegen) +target_link_libraries(generator_smoke smokebase ${QT_QTCORE_LIBRARY} \
${QT_QTXML_LIBRARY} smokegen) set_target_properties(generator_smoke PROPERTIES \
PREFIX "")
if (WIN32)
diff --git a/generators/smoke/helpers.cpp b/generators/smoke/helpers.cpp
index 43c6844..90d73fc 100644
--- a/generators/smoke/helpers.cpp
+++ b/generators/smoke/helpers.cpp
@@ -17,15 +17,20 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <QFileInfo>
#include <QHash>
#include <QList>
+#include <QLibrary>
#include <QStack>
#include <type.h>
+#include <smoke.h>
#include "globals.h"
#include "../../options.h"
+typedef void (*InitSmokeFn)();
+
QHash<QString, QString> Util::typeMap;
QHash<const Method*, const Function*> Util::globalFunctionMap;
QHash<const Method*, const Field*> Util::fieldAccessors;
@@ -92,13 +97,79 @@ bool operator==(const EnumMember& lhs, const EnumMember& rhs)
return (lhs.name() == rhs.name() && lhs.declaringType() == rhs.declaringType() \
&& lhs.type() == rhs.type()); }
+static Smoke* loadSmokeModule(QString moduleName) {
+#if defined(Q_OS_WIN32)
+ QFileInfo file(QString("smoke") + moduleName);
+#else
+ QFileInfo file(QString("libsmoke") + moduleName);
+#endif
+ QLibrary lib(file.filePath());
+
+ QString init_name = "init_" + moduleName + "_Smoke";
+ InitSmokeFn init = (InitSmokeFn) lib.resolve(init_name.toLatin1());
+
+ if (!init)
+ qFatal("Couldn't resolve %s: %s", qPrintable(init_name), \
qPrintable(lib.errorString())); +
+ (*init)();
+
+ QString smoke_name = moduleName + "_Smoke";
+ Smoke** smoke = (Smoke**) lib.resolve(smoke_name.toLatin1());
+ if (!smoke)
+ qFatal("Couldn't resolve %s: %s", qPrintable(smoke_name), \
qPrintable(lib.errorString())); +
+ return *smoke;
+}
+
+static bool compareArgs(const Method& method, const Smoke::Method& smokeMethod, \
Smoke* smoke) { + if (method.parameters().count() != smokeMethod.numArgs) {
+ return false;
+ }
+ for (int i = 0; i < method.parameters().count(); i++) {
+ Parameter p = method.parameters()[i];
+ if (p.type()->toString() != \
smoke->types[smoke->argumentList[smokeMethod.args + i]].name) { + return \
false; + }
+ }
+ return true;
+}
+
+static bool isRepeating(const QList<Smoke*>& parentModules, const char* className, \
const Method& method) { + const char* mungedName = \
Util::mungedName(method).toLatin1(); + foreach (Smoke* smoke, parentModules) {
+ Smoke::ModuleIndex methodIndex = smoke->findMethod(className, mungedName);
+ if (methodIndex.index) {
+ Smoke::Index index = smoke->methodMaps[methodIndex.index].method;
+ if (index >= 0) {
+ if (compareArgs(method, smoke->methods[index], smoke)) {
+ return true;
+ }
+ continue;
+ }
+ index = -index;
+ Smoke::Index i;
+ while ((i = smoke->ambiguousMethodList[index++]) != 0) {
+ if (compareArgs(method, smoke->methods[i], smoke)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
void Util::preparse(QSet<Type*> *usedTypes, QSet<const Class*> *superClasses, const \
QList<QString>& keys) {
Class& globalSpace = classes["QGlobalSpace"];
globalSpace.setName("QGlobalSpace");
globalSpace.setKind(Class::Kind_Class);
globalSpace.setIsNameSpace(true);
-
+
+ QList<Smoke*> parentModules;
+ foreach (QString module, Options::parentModules) {
+ parentModules << loadSmokeModule(module);
+ }
+
// add all functions as methods to a class called 'QGlobalSpace' or a class that \
represents a namespace
for (QHash<QString, Function>::const_iterator it = functions.constBegin(); it != \
functions.constEnd(); it++) { const Function& fn = it.value();
@@ -127,6 +198,9 @@ void Util::preparse(QSet<Type*> *usedTypes, QSet<const Class*> \
*superClasses, co
Method meth = Method(parent, fn.name(), fn.type(), Access_public, \
fn.parameters()); meth.setFlag(Method::Static);
+ if (isRepeating(parentModules, parent->name().toLatin1(), meth)) {
+ continue;
+ }
parent->appendMethod(meth);
// map this method to the function, so we can later retrieve the header it \
was defined in globalFunctionMap[&parent->methods().last()] = &fn;
@@ -141,6 +215,10 @@ void Util::preparse(QSet<Type*> *usedTypes, QSet<const Class*> \
*superClasses, co foreach (const Parameter& param, meth.parameters())
(*usedTypes) << param.type();
}
+
+ foreach (Smoke* smoke, parentModules) {
+ delete smoke;
+ }
// all enums that don't have a parent are put under QGlobalSpace, too
for (QHash<QString, Enum>::iterator it = enums.begin(); it != enums.end(); it++) \
{
--
1.7.11.msysgit.0
_______________________________________________
Kde-bindings mailing list
Kde-bindings@kde.org
https://mail.kde.org/mailman/listinfo/kde-bindings
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic