Author: Wim Lavrijsen <wlavrij...@lbl.gov> Branch: reflex-support Changeset: r46963:2b8e6b34a9d3 Date: 2011-08-31 14:11 -0700 http://bitbucket.org/pypy/pypy/changeset/2b8e6b34a9d3/
Log: fragile tests now work with CINT backend diff --git a/pypy/module/cppyy/capi/cint_capi.py b/pypy/module/cppyy/capi/cint_capi.py --- a/pypy/module/cppyy/capi/cint_capi.py +++ b/pypy/module/cppyy/capi/cint_capi.py @@ -2,7 +2,7 @@ from pypy.translator.tool.cbuild import ExternalCompilationInfo from pypy.rpython.lltypesystem import rffi -from pypy.rlib import rdynload +from pypy.rlib import libffi, rdynload __all__ = ['eci', 'c_load_dictionary'] @@ -34,7 +34,14 @@ use_cpp_linker=True, ) -c_load_dictionary = rffi.llexternal( +_c_load_dictionary = rffi.llexternal( "cppyy_load_dictionary", [rffi.CCHARP], rdynload.DLLHANDLE, compilation_info=eci) + +def c_load_dictionary(name): + result = _c_load_dictionary(name) + if not result: + err = rdynload.dlerror() + raise rdynload.DLOpenError(err) + return libffi.CDLL(name) # should return handle to already open file 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 @@ -27,7 +27,8 @@ /* CINT internals (won't work on Windwos) ------------------------------- */ extern long G__store_struct_offset; -extern "C" void* G__GetShlHandle(); +extern "C" void* G__SetShlHandle(char*); + /* data for life time management ------------------------------------------ */ typedef std::vector<TClassRef> ClassRefs_t; @@ -103,6 +104,9 @@ if (!cr.GetClass()) return (cppyy_typehandle_t)NULL; + if (!cr->GetClassInfo()) + return (cppyy_typehandle_t)NULL; + if (!G__TypeInfo(class_name).IsValid()) return (cppyy_typehandle_t)NULL; @@ -463,7 +467,7 @@ } void* cppyy_load_dictionary(const char* lib_name) { - if (gSystem->Load(lib_name)) - return (void*)G__GetShlHandle(); - return (void*)0; + if (0 <= gSystem->Load(lib_name)) + return (void*)1; + return (void*)0; } diff --git a/pypy/module/cppyy/test/Makefile b/pypy/module/cppyy/test/Makefile --- a/pypy/module/cppyy/test/Makefile +++ b/pypy/module/cppyy/test/Makefile @@ -41,6 +41,12 @@ # # rootcint -f advancedcpp_cint.cxx -c advancedcpp.h advancedcpp_LinkDef.h # g++ -I$ROOTSYS/include advancedcpp_cint.cxx advancedcpp.cxx -shared -o advancedcppDict.so -rdynamic +# +# rootcint -f fragile_cint.cxx -c fragile.h fragile_LinkDef.h +# g++ -I$ROOTSYS/include fragile_cint.cxx fragile.cxx -shared -o fragileDict.so -rdynamic +# +# rootcint -f stltypes_cint.cxx -c stltypes.h stltypes_LinkDef.h +# g++ -I$ROOTSYS/include stltypes_cint.cxx stltypes.cxx -shared -o stltypesDict.so -rdynamic # TODO: methptrgetter causes these tests to crash, so don't use it for now stltypesDict.so: stltypes.cxx stltypes.h stltypes.xml diff --git a/pypy/module/cppyy/test/fragile_LinkDef.h b/pypy/module/cppyy/test/fragile_LinkDef.h new file mode 100644 --- /dev/null +++ b/pypy/module/cppyy/test/fragile_LinkDef.h @@ -0,0 +1,16 @@ +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ namespace fragile; + +#pragma link C++ class fragile::A; +#pragma link C++ class fragile::B; +#pragma link C++ class fragile::C; +#pragma link C++ class fragile::D; +#pragma link C++ class fragile::E; +#pragma link C++ class fragile::F; + +#endif _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit