[pypy-commit] pypy reflex-support: another stab at getting the bootstrapping right ...
wlav
noreply at buildbot.pypy.org
Sat Mar 3 08:46:02 CET 2012
Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r53136:fad46404508b
Date: 2012-03-02 23:00 -0800
http://bitbucket.org/pypy/pypy/changeset/fad46404508b/
Log: another stab at getting the bootstrapping right ...
diff --git a/pypy/module/cppyy/interp_cppyy.py b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -51,12 +51,6 @@
r_cppscope = W_CPPType(space, final_name, cppscope)
state.r_cppscope_cache[name] = r_cppscope
- # prevent getting reflection info that may be linked in through the
- # back-end libs or that may be available through an auto-loader, during
- # translation time (else it will get translated, too)
- if space.config.translating and not objectmodel.we_are_translated():
- return r_cppscope
-
r_cppscope._find_methods()
r_cppscope._find_data_members()
return r_cppscope
@@ -432,8 +426,6 @@
self.data_members[data_member_name] = data_member
def update(self):
- if self.space.config.translating and not objectmodel.we_are_translated():
- return cpptype
self._find_methods()
self._find_data_members()
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
@@ -92,11 +92,22 @@
def make_cppnamespace(namespace_name, cppns, build_in_full=True):
- nsdct = {"_cpp_proxy" : cppns }
+ # build up a representation of a C++ namespace (namespaces are classes)
# create a meta class to allow properties (for static data write access)
metans = type(CppyyNamespaceMeta)(namespace_name+'_meta', (CppyyNamespaceMeta,), {})
+ if cppns:
+ nsdct = {"_cpp_proxy" : cppns }
+ else:
+ nsdct = dict()
+ def cpp_proxy_loader(cls):
+ cpp_proxy = cppyy._type_byname(cls.__name__ != '::' and cls.__name__ or '')
+ del cls.__class__._cpp_proxy
+ cls._cpp_proxy = cpp_proxy
+ return cpp_proxy
+ metans._cpp_proxy = property(cpp_proxy_loader)
+
if build_in_full: # if False, rely on lazy build-up
# insert static methods into the "namespace" dictionary
for func_name in cppns.get_method_names():
@@ -207,8 +218,6 @@
if isinstance(scope, CppyyNamespaceMeta):
global _loaded_dictionaries_isdirty
if _loaded_dictionaries_isdirty: # TODO: this should be per namespace
- if not scope._cpp_proxy:
- scope._cpp_proxy = cppyy._type_byname(scope.__name__)
scope._cpp_proxy.update() # TODO: this is currently quadratic
_loaded_dictionaries_isdirty = False
@@ -295,7 +304,7 @@
_loaded_dictionaries = {}
-_loaded_dictionaries_isdirty = False # should be per namespace
+_loaded_dictionaries_isdirty = True # should be per namespace
def load_reflection_info(name):
try:
return _loaded_dictionaries[name]
@@ -307,10 +316,10 @@
return dct
-# user interface objects (note the two-step: creation of global functions may
-# cause the creation of classes in the global namespace, so gbl must exist at
-# that point to cache them)
-gbl = make_cppnamespace("::", cppyy._type_byname(""), False) # global C++ namespace
+# user interface objects (note the two-step of not calling type_byname here:
+# creation of global functions may cause the creation of classes in the global
+# namespace, so gbl must exist at that point to cache them)
+gbl = make_cppnamespace("::", None, False) # global C++ namespace
-# mostly for the benefit of CINT, which treats std as special
-gbl.std = make_cppnamespace("std", cppyy._type_byname("std"), False)
+# mostly for the benefit of the CINT backend, which treats std as special
+gbl.std = make_cppnamespace("std", None, False)
More information about the pypy-commit
mailing list