python: setattr wrapping

db4
Björn Lindqvist 2014-01-30 15:06:30 +01:00 committed by John Benediktsson
parent 981c26596c
commit d5c0e84fe2
3 changed files with 14 additions and 1 deletions

View File

@ -72,8 +72,13 @@ FUNCTION: PyObject* PyObject_CallObject ( PyObject* callable,
FUNCTION: PyObject* PyObject_Call ( PyObject* callable,
PyObject* args,
PyObject* kw ) ;
FUNCTION: PyObject* PyObject_GetAttrString ( PyObject* callable,
! New reference
FUNCTION: PyObject* PyObject_GetAttrString ( PyObject* o,
c-string attr_name ) ;
FUNCTION: int PyObject_SetAttrString ( PyObject* o,
c-string attr_name,
PyObject *v ) ;
FUNCTION: PyObject* PyObject_Str ( PyObject* o ) ;
FUNCTION: int PyObject_IsTrue ( PyObject* o ) ;

View File

@ -20,6 +20,11 @@ py-initialize
[ "kolobi" import ] [ [ type>> ] [ message>> ] bi 2array ] recover
] py-test
! setattr
[ 73 ] [
"sys" import "testit" [ 73 >py setattr ] [ getattr >factor ] 2bi
] py-test
! Tuples
[ 2 ] [ 2 <py-tuple> py-tuple-size ] py-test

View File

@ -37,6 +37,9 @@ ERROR: python-error type message ;
: getattr ( obj str -- value )
PyObject_GetAttrString check-return ;
: setattr ( obj str value -- )
PyObject_SetAttrString check-return-code ;
: call-object ( obj args -- value )
PyObject_CallObject check-return ;