The answer is - you should not. You cannot safely cast rpython object to pointer, because it can move at any point in time. The way to do it is to store in external array an index to internal array, which really stores an object.
On Tue, May 19, 2009 at 6:43 PM, LvQi <[email protected]> wrote: > Hi all, > > I'm learning how to use rffi and lltype system to access external C > library in RPython. And in some case, I need to store RPython object in > external C array. For example: > > class RPythonObj: > def test(): return 1 > .... .... > c_source=py.code.Source(" > void*store=NULL; > > void c_call_set(???){ > store=???; > } > ??? c_call_get(){ > return store; > }") > > _c_call_set=llexternal("c_call_set", [???], lltype.Void, ...) > _c_call_get=llexternal("c_call_get", [], ???, ...) > > def test(): > o=RPythonObj() > _c_call_set(o) > o2=_c_call_get() > o2.test() > > Is that possible? If so, what should I put in ??? > Thanks very much~ > > -- > Lv Qi > Ph.D Candidate > CS Department > Nanjing University > Nanjing 210093 > China > Tel: 86-138-5228-2381 > > _______________________________________________ > [email protected] > http://codespeak.net/mailman/listinfo/pypy-dev > _______________________________________________ [email protected] http://codespeak.net/mailman/listinfo/pypy-dev
