Created
February 24, 2013 22:04
-
-
Save neuro-sys/5025903 to your computer and use it in GitHub Desktop.
pycall
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| char * py_call_module(char * name, struct irc_t * irc) | |
| { | |
| struct py_module_t * mod = g_hash_table_lookup(mod_hash_map, name); | |
| PyObject * p_args = PyTuple_New(2); | |
| PyObject * p_val; | |
| p_val = PyString_FromString(irc->from); | |
| PyTuple_SetItem(p_args, 0, p_val); | |
| p_val = PyString_FromString(irc->request); | |
| PyTuple_SetItem(p_args, 1, p_val); | |
| p_val = PyObject_CallObject(mod->pFunc, p_args); | |
| return strdup(PyString_AsString(p_val)); | |
| } | |
| /////////////////////////////////////////////////////// | |
| $ cat modules/mod_test.py | |
| def mod_test(a, b): | |
| return "python test: " % a % " and " % b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment