[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/bindings/gobject-consume
From:       Norbert Frese <nf2 () scheinwelt ! at>
Date:       2009-04-05 22:34:37
Message-ID: 1238970877.960196.838.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 949798 by nfrese:

gobject-consume - fix bug in gir-xml parser - returning a reference to a local var

 M  +25 -0     girparser/girparser.cpp  
 M  +4 -2      girparser/girparser.h  
 M  +4 -0      go-consume.cpp  
 M  +34 -12    renderers/qt4/qt4-utils.cpp  


--- trunk/playground/bindings/gobject-consume/girparser/girparser.cpp #949797:949798
@@ -101,5 +101,30 @@
 	delete girXML;
 }
 
+void Gir::dump()
+{
+	for (map<string, GirXML>::iterator fileIt = girFiles.begin(); fileIt != \
girFiles.end(); ++fileIt) +	{
+		GirXML girXML = fileIt->second;
+		cout << "file: " << girXML.getName() << endl;
+		for (map<string, GirNamespace>::iterator namespaceInXMLIt = \
girXML.girNamespaces.begin(); namespaceInXMLIt != girXML.girNamespaces.end(); \
++namespaceInXMLIt) +		{
+			GirNamespace girNamespace = namespaceInXMLIt->second;
+			cout << namespaceInXMLIt->first << ": " << girNamespace.getName() << endl;
+			for (map<string, GirBitfield>::iterator itemIt = girNamespace.bitfields.begin(); \
itemIt != girNamespace.bitfields.end(); ++itemIt) +			{
+				GirBitfield bitfield = itemIt->second;
+				cout << "bitfield: " << itemIt->first << " ctype=" << bitfield.cType << endl;
+			}
 
+		}
 
+	}
+
+
+
+
+
+}
+
+
--- trunk/playground/bindings/gobject-consume/girparser/girparser.h #949797:949798
@@ -184,7 +184,7 @@
 
 
 
-class GirNamespace : public GirRecord
+class GirNamespace : public GirXMLTreeItem
 {
 public:
 	string version;
@@ -252,11 +252,13 @@
 
 	bool loadAndParseGir(string _namespace, string version);
 
+	void dump();
+
 	GirNamespace & findNamespace(string name)
 	{
 		for (map<string, GirXML>::iterator it = girFiles.begin(); it != girFiles.end(); \
++it)  {
-			GirXML girXML = it->second;
+			GirXML & girXML = it->second;
 			if (girXML.girNamespaces.count(name)>0) return girXML.girNamespaces[name];
 		}
 		cerr << "Namespace " << name << " not found";
--- trunk/playground/bindings/gobject-consume/go-consume.cpp #949797:949798
@@ -129,6 +129,10 @@
     	qt4_render_impl(envir, implFile, nodeRegistry);
     	implFile.close();
     }
+    else if (command == "--dump-gir")
+    {
+    	envir.gir.dump();
+    }
     else
     {
     	cerr << "unknown command: " << command << "\n";
--- trunk/playground/bindings/gobject-consume/renderers/qt4/qt4-utils.cpp \
#949797:949798 @@ -114,14 +114,29 @@
 
 string Qt4RenderUtils::renderUnwrapSruct(GIBaseInfo * target, string argName)
 {
-	string oname;
+	string cType;
 	if (g_struct_info_is_gtype_struct ((GIStructInfo *)target))
 	{
-		oname = g_registered_type_info_get_type_name((GIRegisteredTypeInfo *)target);
+		cType = g_registered_type_info_get_type_name((GIRegisteredTypeInfo *)target);
 	}
 	else
 	{
-		oname = string("G") + g_base_info_get_name(target);
+		string typeName = g_base_info_get_name(target);
+		string origNamespace = g_base_info_get_namespace(target);
+
+		GirNamespace & girNameSpace = envir.gir.findNamespace(origNamespace);
+
+		if (girNameSpace.records.count(typeName)>0)
+		{
+			cType = girNameSpace.records[typeName].cType;
+		}
+		else
+		{
+			cerr << "record (struct): " << origNamespace << "::" << typeName << " not found!" \
<< endl; +		}
+
+		if (cType.empty() || cType.size() == 0 || cType == "")
+			cerr << "empty ctype for: " << typeName  << endl;
 	}
 
 	//string oname = string("G") + g_base_info_get_name(target);
@@ -130,7 +145,7 @@
 
 	string s;
 	s += "WO::unwrap<";
-	s += oname;
+	s += cType;
 	s += ">(";
 	s += argName;
 	s += ")";
@@ -139,22 +154,29 @@
 
 string Qt4RenderUtils::renderCastEnum(GIBaseInfo * target, string argName, bool \
isOutArg)  {
-	string oname = g_base_info_get_name(target);
+	string typeName = g_base_info_get_name(target);
+	typeName += "";
 	string origNamespace = g_base_info_get_namespace(target);
 
-	GirNamespace& girNameSpace = envir.gir.findNamespace(origNamespace);
+	GirNamespace & girNameSpace = envir.gir.findNamespace(origNamespace);
 
 	string cType;
 
-	if (girNameSpace.enumerations.count(oname)>0)
-		cType = girNameSpace.enumerations[oname].cType;
-	else if (girNameSpace.bitfields.count(oname)>0)
-		cType = girNameSpace.bitfields[oname].cType;
+	if (girNameSpace.enumerations.count(typeName)>0)
+	{
+		cType = girNameSpace.enumerations[typeName].cType;
+	}
+	else if (girNameSpace.bitfields.count(typeName)>0)
+	{
+		cType = girNameSpace.bitfields[typeName].cType;
+	}
 	else
-		cerr << "enum or bitfield:" << oname << " not found!" << endl;
+	{
+		cerr << "enum or bitfield: " << origNamespace << "::" << typeName << " not found!" \
<< endl; +	}
 
 	if (cType.empty() || cType.size() == 0 || cType == "")
-		cerr << "empty ctype: " << oname  << endl;
+		cerr << "empty ctype: " << typeName  << endl;
 
 	string s;
 	s += "(";


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic