Commit 4b284d55 authored by Maciej Fijalkowski's avatar Maciej Fijalkowski

Implement another hack

parent 3cb8339d
......@@ -46,6 +46,12 @@ void pypy_thread_attach(void);
*/
int pypy_execute_source(char *source);
/* a similar function, but inside Python code it'll register
a magic argument c_argument as int, which will be passed as void* from C.
Useful for passing pointers to arbitrary structs that contain callbacks
to register */
int pypy_execute_source_ptr(char *source, void* ptr);
#ifdef __cplusplus
}
......
......@@ -129,6 +129,19 @@ def create_entry_point(space, w_dict):
if before: before()
return rffi.cast(rffi.INT, res)
@entrypoint('main', [rffi.CCHARP, lltype.Signed],
c_name='pypy_execute_source_ptr')
def pypy_execute_source_ptr(ll_source, ll_ptr):
after = rffi.aroundstate.after
if after: after()
source = rffi.charp2str(ll_source)
space.setitem(w_globals, space.wrap('c_argument'),
space.wrap(ll_ptr))
res = _pypy_execute_source(source)
before = rffi.aroundstate.before
if before: before()
return rffi.cast(rffi.INT, res)
@entrypoint('main', [], c_name='pypy_init_threads')
def pypy_init_threads():
if not space.config.objspace.usemodules.thread:
......@@ -166,6 +179,7 @@ def create_entry_point(space, w_dict):
return 0
return entry_point, {'pypy_execute_source': pypy_execute_source,
'pypy_execute_source_ptr': pypy_execute_source_ptr,
'pypy_init_threads': pypy_init_threads,
'pypy_thread_attach': pypy_thread_attach,
'pypy_setup_home': pypy_setup_home}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment