[pypy-commit] pypy cling-support: from Aditi (edited): initial enum support

wlav pypy.commits at gmail.com
Mon Jul 11 18:55:36 EDT 2016


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: cling-support
Changeset: r85665:66ca03bf6d3c
Date: 2016-07-11 15:52 -0700
http://bitbucket.org/pypy/pypy/changeset/66ca03bf6d3c/

Log:	from Aditi (edited): initial enum support

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
@@ -719,8 +719,8 @@
     "NOT_RPYTHON"
     # signed types (use strtoll in setting of default in __init__)
     type_info = (
-        (rffi.SHORT,      ("short", "short int"),      'h'),
-        (rffi.INT,        ("int",),                    'i'),
+        (rffi.SHORT,      ("short", "short int"),          'h'),
+        (rffi.INT,        ("int", "internal_enum_type_t"), 'i'),
     )
 
     # constref converters exist only b/c the stubs take constref by value, whereas
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
@@ -314,7 +314,7 @@
         (bool,            capi.c_call_b,   ("bool",)),
         (rffi.CHAR,       capi.c_call_c,   ("char", "unsigned char")),
         (rffi.SHORT,      capi.c_call_h,   ("short", "short int", "unsigned short", "unsigned short int")),
-        (rffi.INT,        capi.c_call_i,   ("int",)),
+        (rffi.INT,        capi.c_call_i,   ("int", "internal_enum_type_t")),
         (rffi.UINT,       capi.c_call_l,   ("unsigned", "unsigned int")),
         (rffi.LONG,       capi.c_call_l,   ("long", "long int")),
         (rffi.ULONG,      capi.c_call_l,   ("unsigned long", "unsigned long int")),
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
@@ -446,7 +446,7 @@
     # install a type for enums to refer to
     # TODO: this is correct for C++98, not for C++11 and in general there will
     # be the same issue for all typedef'd builtin types
-    setattr(gbl, 'unsigned int', int)
+    setattr(gbl, 'internal_enum_type_t', int)
 
     # install nullptr as a unique reference
     setattr(gbl, 'nullptr', cppyy._get_nullptr())
diff --git a/pypy/module/cppyy/src/clingcwrapper.cxx b/pypy/module/cppyy/src/clingcwrapper.cxx
--- a/pypy/module/cppyy/src/clingcwrapper.cxx
+++ b/pypy/module/cppyy/src/clingcwrapper.cxx
@@ -558,6 +558,7 @@
 }
 
 Bool_t Cppyy::IsEnum( const std::string& type_name ) {
+   if ( type_name.empty() ) return kFALSE;
    return gInterpreter->ClassInfo_IsEnum( type_name.c_str() );
 }
 
@@ -1068,7 +1069,10 @@
 }
 
 char* cppyy_resolve_name(const char* cppitem_name) {
-    return cppstring_to_cstring(Cppyy::ResolveName(cppitem_name));
+    std::string str = cppstring_to_cstring(Cppyy::ResolveName(cppitem_name));
+    if (Cppyy::IsEnum(str))
+        return cppstring_to_cstring("internal_enum_type_t");
+    return cppstring_to_cstring(str);
 }
 
 cppyy_scope_t cppyy_get_scope(const char* scope_name) {


More information about the pypy-commit mailing list