[pypy-commit] lang-smalltalk default: (tfel, lwassermann): first iteration of working, exposed functions
lwassermann
noreply at buildbot.pypy.org
Sat Jun 1 11:48:17 CEST 2013
Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch:
Changeset: r430:554141f002ff
Date: 2013-05-31 17:48 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/554141f002ff/
Log: (tfel, lwassermann): first iteration of working, exposed functions
diff --git a/spyvm/interpreter_proxy.py b/spyvm/interpreter_proxy.py
new file mode 100644
--- /dev/null
+++ b/spyvm/interpreter_proxy.py
@@ -0,0 +1,54 @@
+# struct VirtualMachine* sqGetInterpreterProxy(void);
+
+# typedef struct VirtualMachine {
+# sqInt (*minorVersion)(void);
+# } VirtualMachine;
+
+# Loading a Plugin:
+# plugin setInterpreter: proxy.
+# (plugin respondsTo: #initialiseModule) ifTrue:[plugin initialiseModule].
+# plugin perform: primitiveName asSymbol.
+from spyvm import error
+
+from rpython.rlib.entrypoint import entrypoint
+from rpython.rtyper.annlowlevel import llhelper
+from rpython.rlib.exports import export_struct
+from rpython.rtyper.lltypesystem.lltype import FuncType, Struct, Ptr
+from rpython.rtyper.lltypesystem import lltype
+
+sqInt = lltype.Signed
+sqLong = lltype.SignedLongLong
+
+minorVFTP = Ptr(FuncType([], sqInt))
+
+VirtualMachine = Struct("VirtualMachine",
+ ("minorVersion", minorVFTP)
+ )
+VMPtr = Ptr(VirtualMachine)
+# export_struct("VirtualMachine", VirtualMachine)
+
+ at entrypoint('main', [], c_name='sqGetInterpreterProxy')
+def sqGetInterpreterProxy():
+ if not InterpreterProxy.vm_initialized:
+ vm_proxy = lltype.malloc(VirtualMachine, flavor='raw')
+ vm_proxy.minorVersion = llhelper(minorVFTP, minorVersion)
+ InterpreterProxy.vm_proxy = vm_proxy
+ InterpreterProxy.vm_initialized = True
+ return InterpreterProxy.vm_proxy
+
+def minorVersion():
+ return 1
+
+
+class _InterpreterProxy(object):
+ _immutable_fields_ = ['vm_initialized?']
+
+ def __init__(self):
+ self.vm_proxy = lltype.nullptr(VMPtr.TO)
+ self.vm_initialized = False
+
+ def call(self, signature, interp, s_frame, argcount, s_method):
+ print "Hello World..."
+ raise error.Exit("External Call")
+
+InterpreterProxy = _InterpreterProxy()
More information about the pypy-commit
mailing list