[pypy-commit] pypy reflex-support: typedefs for CINT (includes special handling of string/basic_string<char>)

wlav noreply at buildbot.pypy.org
Thu Mar 8 01:44:42 CET 2012


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r53266:cc3b0fc4cfd1
Date: 2012-03-07 15:46 -0800
http://bitbucket.org/pypy/pypy/changeset/cc3b0fc4cfd1/

Log:	typedefs for CINT (includes special handling of
	string/basic_string<char>)

diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py
--- a/pypy/module/cppyy/converter.py
+++ b/pypy/module/cppyy/converter.py
@@ -665,13 +665,13 @@
 _converters["void**"]                   = VoidPtrPtrConverter
 _converters["void*&"]                   = VoidPtrRefConverter
 
-# special cases
+# special cases (note: CINT backend requires the simple name 'string')
 _converters["std::basic_string<char>"]           = StdStringConverter
-_converters["basic_string<char>"]                = _converters["std::basic_string<char>"]
+_converters["string"]                            = _converters["std::basic_string<char>"]
 _converters["const std::basic_string<char>&"]    = StdStringConverter     # TODO: shouldn't copy
-_converters["const basic_string<char>&"]         = _converters["const std::basic_string<char>&"]
+_converters["const string&"]                     = _converters["const std::basic_string<char>&"]
 _converters["std::basic_string<char>&"]          = StdStringRefConverter
-_converters["basic_string<char>&"]               = _converters["std::basic_string<char>&"]
+_converters["string&"]                           = _converters["std::basic_string<char>&"]
 
 # it should be possible to generate these:
 _a_converters["short int*"]               = ShortPtrConverter
diff --git a/pypy/module/cppyy/executor.py b/pypy/module/cppyy/executor.py
--- a/pypy/module/cppyy/executor.py
+++ b/pypy/module/cppyy/executor.py
@@ -372,5 +372,6 @@
 _executors["double"]              = DoubleExecutor
 _executors["double*"]             = DoublePtrExecutor
 
-# special cases
+# special cases (note: CINT backend requires the simple name 'string')
 _executors["std::basic_string<char>"]        = StdStringExecutor
+_executors["string"]                         = _executors["std::basic_string<char>"]
diff --git a/pypy/module/cppyy/pythonify.py b/pypy/module/cppyy/pythonify.py
--- a/pypy/module/cppyy/pythonify.py
+++ b/pypy/module/cppyy/pythonify.py
@@ -299,8 +299,8 @@
             raise StopIteration
         pyclass.__iter__ = __iter__
 
-    # string comparisons
-    if pyclass.__name__ == 'std::basic_string<char>':
+    # string comparisons (note: CINT backend requires the simple name 'string')
+    if pyclass.__name__ == 'std::basic_string<char>' or pyclass.__name__ == 'string':
         def eq(self, other):
             if type(other) == pyclass:
                 return self.c_str() == other.c_str()
diff --git a/pypy/module/cppyy/src/cintcwrapper.cxx b/pypy/module/cppyy/src/cintcwrapper.cxx
--- a/pypy/module/cppyy/src/cintcwrapper.cxx
+++ b/pypy/module/cppyy/src/cintcwrapper.cxx
@@ -157,6 +157,15 @@
 
 
 /* name to opaque C++ scope representation -------------------------------- */
+char* cppyy_resolve_name(const char* cppitem_name) {
+    if (strcmp(cppitem_name, "") == 0)
+        return cppstring_to_cstring(cppitem_name);
+    G__TypeInfo ti(cppitem_name);
+    if (ti.IsValid())
+        return cppstring_to_cstring(ti.TrueName());
+    return cppstring_to_cstring(cppitem_name);
+}
+
 cppyy_scope_t cppyy_get_scope(const char* scope_name) {
     ClassRefIndices_t::iterator icr = g_classref_indices.find(scope_name);
     if (icr != g_classref_indices.end())
diff --git a/pypy/module/cppyy/test/example01_LinkDef.h b/pypy/module/cppyy/test/example01_LinkDef.h
--- a/pypy/module/cppyy/test/example01_LinkDef.h
+++ b/pypy/module/cppyy/test/example01_LinkDef.h
@@ -5,6 +5,7 @@
 #pragma link off all functions;
 
 #pragma link C++ class example01;
+#pragma link C++ typedef example01_t;
 #pragma link C++ class payload;
 #pragma link C++ class ArgPasser;
 #pragma link C++ class z_;


More information about the pypy-commit mailing list