Calling Pike Code
Calling pike functions from within C/CMOD codeHere's some code for calling (whether they're written in c or pike) functions from your C language module code. Remember that you can create objects this way because create is called implicitly, just ask for the class name you want to instantiate: // this code works for a function that takes one argument. // you'll have to modify it to get it to understand multiple args. // args are at top of stack // look up the function push_text( "Sql.sql_result"); SAFE_APPLY_MASTER("resolv", 1 ); // method is at top of the stack, we want the arg on top stack_swap(); // arg is at top, function is 1 down from the top apply_svalue( Pike_sp-2, 1 ); // result is at top of the stack, function is still one down // and we want to pop it. stack_swap(); pop_stack(); // get the identifier for the member we want to call int i; i=find_identifier("query", Pike_fp->current_object->prog); // now call the method with the context of the current object. apply_low(Pike_fp->current_object, i, 1); /* push arguments on stack */ apply(Pike_fp->current_object, "the method", number_of_args); Powered by PikeWiki2 |
|||
gotpike.org | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University |