wlav avatar wlav committed cc3b0fc

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

Comments (0)

Files changed (5)

pypy/module/cppyy/converter.py

 _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

pypy/module/cppyy/executor.py

 _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>"]

pypy/module/cppyy/pythonify.py

             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()

pypy/module/cppyy/src/cintcwrapper.cxx

 
 
 /* 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())

pypy/module/cppyy/test/example01_LinkDef.h

 #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_;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.