[pypy-svn] r64690 - in pypy/branch/pypycpp/reflex-binding: . poc poc/one poc/one/pypy poc/one/pypy/test
igorto at codespeak.net
igorto at codespeak.net
Sun Apr 26 15:17:14 CEST 2009
Author: igorto
Date: Sun Apr 26 15:17:13 2009
New Revision: 64690
Added:
pypy/branch/pypycpp/reflex-binding/
pypy/branch/pypycpp/reflex-binding/poc/
pypy/branch/pypycpp/reflex-binding/poc/one/
pypy/branch/pypycpp/reflex-binding/poc/one/myClass.cpp
pypy/branch/pypycpp/reflex-binding/poc/one/myClass.h
pypy/branch/pypycpp/reflex-binding/poc/one/poc.cpp
pypy/branch/pypycpp/reflex-binding/poc/one/poc.h
pypy/branch/pypycpp/reflex-binding/poc/one/pypy/
pypy/branch/pypycpp/reflex-binding/poc/one/pypy/__init__.py
pypy/branch/pypycpp/reflex-binding/poc/one/pypy/interp_test.py
pypy/branch/pypycpp/reflex-binding/poc/one/pypy/test/
pypy/branch/pypycpp/reflex-binding/poc/one/pypy/test/test_test.py
Log:
a simple example using reflex and pypy(i still need to create a Makefile)
Added: pypy/branch/pypycpp/reflex-binding/poc/one/myClass.cpp
==============================================================================
--- (empty file)
+++ pypy/branch/pypycpp/reflex-binding/poc/one/myClass.cpp Sun Apr 26 15:17:13 2009
@@ -0,0 +1,18 @@
+#include <iostream>
+
+#include "myClass.h"
+
+using namespace std;
+
+MyClass::MyClass()
+{}
+
+void MyClass::testOne()
+{
+ cout <<"test one\n";
+}
+
+void MyClass::testTwo(int i)
+{
+ cout <<"test two:"<<i;
+}
Added: pypy/branch/pypycpp/reflex-binding/poc/one/myClass.h
==============================================================================
--- (empty file)
+++ pypy/branch/pypycpp/reflex-binding/poc/one/myClass.h Sun Apr 26 15:17:13 2009
@@ -0,0 +1,12 @@
+#ifndef MYCLASS_H
+#define MYCLASS_H
+
+class MyClass
+{
+ public:
+ MyClass();
+ void testOne();
+ void testTwo(int i);
+};
+
+#endif
Added: pypy/branch/pypycpp/reflex-binding/poc/one/poc.cpp
==============================================================================
--- (empty file)
+++ pypy/branch/pypycpp/reflex-binding/poc/one/poc.cpp Sun Apr 26 15:17:13 2009
@@ -0,0 +1,24 @@
+#include <Reflex/Reflex.h>
+
+#include <iostream>
+#include <dlfcn.h>
+
+#include "poc.h"
+
+using namespace ROOT::Reflex;
+
+void invokeMethod(const char *method)
+{
+ void * s_libInstance = s_libInstance = dlopen("libMyClass.so", RTLD_NOW);
+ Type t = Type::ByName("MyClass");
+
+ if ( t ) {
+ if ( t.IsClass() ) {
+ Object o = t.Construct();
+ Member m = t.MemberByName(method);
+ if ( m ) {
+ m.Invoke(o);
+ }
+ }
+ }
+}
Added: pypy/branch/pypycpp/reflex-binding/poc/one/poc.h
==============================================================================
--- (empty file)
+++ pypy/branch/pypycpp/reflex-binding/poc/one/poc.h Sun Apr 26 15:17:13 2009
@@ -0,0 +1,10 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void invokeMethod(const char *method);
+
+#ifdef __cplusplus
+}
+#endif
+
Added: pypy/branch/pypycpp/reflex-binding/poc/one/pypy/__init__.py
==============================================================================
--- (empty file)
+++ pypy/branch/pypycpp/reflex-binding/poc/one/pypy/__init__.py Sun Apr 26 15:17:13 2009
@@ -0,0 +1,10 @@
+from pypy.interpreter.mixedmodule import MixedModule
+
+class Module(MixedModule):
+ interpleveldefs = {
+ 'invokeMethod' : 'interp_test.invokeMethod',
+ }
+
+ appleveldefs = {
+ }
+
Added: pypy/branch/pypycpp/reflex-binding/poc/one/pypy/interp_test.py
==============================================================================
--- (empty file)
+++ pypy/branch/pypycpp/reflex-binding/poc/one/pypy/interp_test.py Sun Apr 26 15:17:13 2009
@@ -0,0 +1,14 @@
+from pypy.interpreter.error import OperationError
+from pypy.interpreter.baseobjspace import ObjSpace, W_Root
+from pypy.rpython.lltypesystem import rffi, lltype
+from pypy.translator.tool.cbuild import ExternalCompilationInfo
+import sys
+
+eci = ExternalCompilationInfo(libraries=['Poc'])
+c_invokeMethod = rffi.llexternal('invokeMethod', [rffi.CCHARP], lltype.Void,
+ compilation_info=eci, threadsafe=False)
+
+def invokeMethod(space, method_name):
+ res = c_invokeMethod(method_name)
+
+invokeMethod.unwrap_spec = [ObjSpace, str]
Added: pypy/branch/pypycpp/reflex-binding/poc/one/pypy/test/test_test.py
==============================================================================
--- (empty file)
+++ pypy/branch/pypycpp/reflex-binding/poc/one/pypy/test/test_test.py Sun Apr 26 15:17:13 2009
@@ -0,0 +1,8 @@
+from pypy.conftest import gettestobjspace
+
+class AppTestCrypt:
+ def setup_class(cls):
+ cls.space = gettestobjspace(usemodules=['test'])
+ def test_crypt(self):
+ import test
+ res = test.invokeMethod("testOne")
More information about the Pypy-commit
mailing list