Version 1.0b1 API Documentation generated by Endo 2006-08-14
Rules for building C/API module with f2py2e.
Here is a skeleton of a new wrapper function (13Dec2001):
wrapper_function(args)
declarations
get_python_arguments, say, `a' and `b'
get_a_from_python
if (successful) {
get_b_from_python
if (successful) {
callfortran
if (succesful) {
put_a_to_python
if (succesful) {
put_b_to_python
if (succesful) {
buildvalue = ...
}
}
}
}
cleanup_b
}
cleanup_a
return buildvalue
arg_rules = [ { Const('separatorsfor') : Name('sepdict') }, { Const('frompyobj') : List([Const('\t/* Processing variable #varname# */'), Dict([(Name('debugcapi'), Const('\tfprintf(stderr,"#vardebuginfo#\\n");'))])]), Const('cleanupfrompyobj') : Const('\t/* End of cleaning variable #varname# */'), Const('_depend') : Const(''), Const('need') : Name('typedef_need_dict') }, { Const('docstropt') : Dict([(CallFunc(Name('l_and'), [Name('isoptional'), Name('isintent_nothide')], None, None), Const('\t#pydocsign#'))]), Const('docstrreq') : Dict([(CallFunc(Name('l_and'), [Name('isrequired'), Name('isintent_nothide')], None, None), Const('\t#pydocsign#'))]), Const('docstrout') : Dict([(Name('isintent_out'), Const('\t#pydocsignout#'))]), Const('latexdocstropt') : Dict([(CallFunc(Name('l_and'), [Name('isoptional'), Name('isintent_nothide')], None, None), List([Const('\\item[]{{}\\verb@#pydocsign#@{}}'), Dict([(Name('hasnote'), Const('--- #note#'))])]))]), Const('latexdocstrreq') : Dict([(CallFunc(Name('l_and'), [Name('isrequired'), Name('isintent_nothide')], None, None), List([Const('\\item[]{{}\\verb@#pydocsign#@{}}'), Dict([(Name('hasnote'), Const('--- #note#'))])]))]), Const('latexdocstrout') : Dict([(Name('isintent_out'), List([Const('\\item[]{{}\\verb@#pydocsignout#@{}}'), Dict([(CallFunc(Name('l_and'), [Name('hasnote'), Name('isintent_hide')], None, None), Const('--- #note#')), (CallFunc(Name('l_and'), [Name('hasnote'), Name('isintent_nothide')], None, None), Const('--- See above.'))])]))]), Const('depend') : Const('') }, { Const('kwlist') : Const('"#varname#",'), Const('docsign') : Const('#varname#,'), Const('_check') : CallFunc(Name('l_and'), [Name('isintent_nothide'), CallFunc(Name('l_not'), [Name('isoptional')], None, None)], None, None) }, { Const('kwlistopt') : Const('"#varname#",'), Const('docsignopt') : Const('#varname#=#showinit#,'), Const('docsignoptshort') : Const('#varname#,'), Const('_check') : CallFunc(Name('l_and'), [Name('isintent_nothide'), Name('isoptional')], None, None) }, { Const('docreturn') : Const('#outvarname#,'), Const('returnformat') : Const('#varrformat#'), Const('_check') : Name('isintent_out') }, { Const('docsignxa') : Dict([(Name('isintent_nothide'), Const('#varname#_extra_args=(),'))]), Const('docsignxashort') : Dict([(Name('isintent_nothide'), Const('#varname#_extra_args,'))]), Const('docstropt') : Dict([(Name('isintent_nothide'), Const('\t#varname#_extra_args := () input tuple'))]), Const('docstrcbs') : Const('#cbdocstr#'), Const('latexdocstrcbs') : Const('\\item[] #cblatexdocstr#'), Const('latexdocstropt') : Dict([(Name('isintent_nothide'), Const('\\item[]{{}\\verb@#varname#_extra_args := () input tuple@{}} --- Extra arguments for call-back function {{}\\verb@#varname#@{}}.'))]), Const('decl') : List([Const('\tPyObject *#varname#_capi = Py_None;'), Const('\tPyTupleObject *#varname#_xa_capi = NULL;'), Const('\tPyTupleObject *#varname#_args_capi = NULL;'), Const('\tint #varname#_nofargs_capi = 0;'), Dict([(CallFunc(Name('l_not'), [Name('isintent_callback')], None, None), Const('\t#cbname#_typedef #varname#_cptr;'))])]), Const('kwlistxa') : Dict([(Name('isintent_nothide'), Const('"#varname#_extra_args",'))]), Const('argformat') : Dict([(Name('isrequired'), Const('O'))]), Const('keyformat') : Dict([(Name('isoptional'), Const('O'))]), Const('xaformat') : Dict([(Name('isintent_nothide'), Const('O!'))]), Const('args_capi') : Dict([(Name('isrequired'), Const(',varname#_capi'))]), Const('keys_capi') : Dict([(Name('isoptional'), Const(',varname#_capi'))]), Const('keys_xa') : Const(',&PyTuple_Type,varname#_xa_capi'), Const('setjmpbuf') : Const('(setjmp(#cbname#_jmpbuf))'), Const('callfortran') : Dict([(CallFunc(Name('l_not'), [Name('isintent_callback')], None, None), Const('#varname#_cptr,'))]), Const('need') : List([Const('#cbname#'), Const('setjmp.h')]), Const('_check') : Name('isexternal') }, { Const('frompyobj') : List([Dict([(CallFunc(Name('l_not'), [Name('isintent_callback')], None, None), Const('if(PyCObject_Check(#varname#_capi)) {\n #varname#_cptr = PyCObject_AsVoidPtr(#varname#_capi);\n} else {\n #varname#_cptr = #cbname#;\n}\n'))]), Dict([(Name('isintent_callback'), Const('if (#varname#_capi==Py_None) {\n #varname#_capi = PyObject_GetAttrString(#modulename#_module,"#varname#");\n if (#varname#_capi) {\n if (#varname#_xa_capi==NULL) {\n if (PyObject_HasAttrString(#modulename#_module,"#varname#_extra_args")) {\n PyObject* capi_tmp = PyObject_GetAttrString(#modulename#_module,"#varname#_extra_args");\n if (capi_tmp)\n #varname#_xa_capi = (PyTupleObject *)PySequence_Tuple(capi_tmp);\n else\n #varname#_xa_capi = (PyTupleObject *)Py_BuildValue("()");\n if (#varname#_xa_capi==NULL) {\n PyErr_SetString(#modulename#_error,"Failed to convert #modulename#.#varname#_extra_args to tuple.\\n");\n return NULL;\n }\n }\n }\n }\n if (#varname#_capi==NULL) {\n PyErr_SetString(#modulename#_error,"Callback #varname# not defined (as an argument or module #modulename# attribute).\\n");\n return NULL;\n }\n}\n'))]), Const('\t#varname#_nofargs_capi = #cbname#_nofargs;\n\tif (create_cb_arglist(#varname#_capi,#varname#_xa_capi,#maxnofargs#,#nofoptargs#,cbname#_nofargs,varname#_args_capi,"failed in processing argument list for call-back #varname#.")) {\n\t\tjmp_buf #varname#_jmpbuf;'), Dict([(Name('debugcapi'), List([Const('\t\tfprintf(stderr,"debug-capi:Assuming %d arguments; at most #maxnofargs#(-#nofoptargs#) is expected.\\n",#cbname#_nofargs);\n\t\tCFUNCSMESSPY("for #varname#=",#cbname#_capi);'), Dict([(CallFunc(Name('l_not'), [Name('isintent_callback')], None, None), Const('\t\tfprintf(stderr,"#vardebugshowvalue# (call-back in C).\\n",#cbname#);'))])]))]), Const('\t\tCFUNCSMESS("Saving jmpbuf for `#varname#`.\\n");\n\t\tSWAP(#varname#_capi,#cbname#_capi,PyObject);\n\t\tSWAP(#varname#_args_capi,#cbname#_args_capi,PyTupleObject);\n\t\tmemcpy(varname#_jmpbuf,cbname#_jmpbuf,sizeof(jmp_buf));')]), Const('cleanupfrompyobj') : Const('\t\tCFUNCSMESS("Restoring jmpbuf for `#varname#`.\\n");\n\t\t#cbname#_capi = #varname#_capi;\n\t\tPy_DECREF(#cbname#_args_capi);\n\t\t#cbname#_args_capi = #varname#_args_capi;\n\t\t#cbname#_nofargs = #varname#_nofargs_capi;\n\t\tmemcpy(cbname#_jmpbuf,varname#_jmpbuf,sizeof(jmp_buf));\n\t}'), Const('need') : List([Const('SWAP'), Const('create_cb_arglist')]), Const('_check') : Name('isexternal'), Const('_depend') : Const('') }, { Const('decl') : Const('\t#ctype# #varname# = 0;'), Const('pyobjfrom') : Dict([(Name('debugcapi'), Const('\tfprintf(stderr,"#vardebugshowvalue#\\n",#varname#);'))]), Const('callfortran') : Dict([(Name('isintent_c'), Const('#varname#,')), (CallFunc(Name('l_not'), [Name('isintent_c')], None, None), Const('varname#,'))]), Const('return') : Dict([(Name('isintent_out'), Const(',#varname#'))]), Const('_check') : CallFunc(Name('l_and'), [Name('isscalar'), CallFunc(Name('l_not'), [Name('iscomplex')], None, None)], None, None) }, { Const('need') : Dict([(Name('hasinitvalue'), Const('math.h'))]), Const('_check') : CallFunc(Name('l_and'), [Name('isscalar'), CallFunc(Name('l_not'), [Name('iscomplex')], None, None)], None, None) }, { Const('decl') : Const('\tPyObject *#varname#_capi = Py_None;'), Const('argformat') : Dict([(Name('isrequired'), Const('O'))]), Const('keyformat') : Dict([(Name('isoptional'), Const('O'))]), Const('args_capi') : Dict([(Name('isrequired'), Const(',varname#_capi'))]), Const('keys_capi') : Dict([(Name('isoptional'), Const(',varname#_capi'))]), Const('pyobjfrom') : Dict([(Name('isintent_inout'), Const('\tf2py_success = try_pyarr_from_#ctype#(#varname#_capi,varname#);\n\tif (f2py_success) {'))]), Const('closepyobjfrom') : Dict([(Name('isintent_inout'), Const('\t} /*if (f2py_success) of #varname# pyobjfrom*/'))]), Const('need') : Dict([(Name('isintent_inout'), Const('try_pyarr_from_#ctype#'))]), Const('_check') : CallFunc(Name('l_and'), [Name('isscalar'), CallFunc(Name('l_not'), [Name('iscomplex')], None, None), Name('isintent_nothide')], None, None) }, { Const('frompyobj') : List([Dict([(Name('hasinitvalue'), Const('\tif (#varname#_capi == Py_None) #varname# = #init#; else')), (Const('_depend'), Const(''))]), Dict([(CallFunc(Name('l_and'), [Name('isoptional'), CallFunc(Name('l_not'), [Name('hasinitvalue')], None, None)], None, None), Const('\tif (#varname#_capi != Py_None)')), (Const('_depend'), Const(''))]), Dict([(CallFunc(Name('l_not'), [Name('islogical')], None, None), Const('\t\tf2py_success = #ctype#_from_pyobj(varname#,#varname#_capi,"#pyname#() #nth# (#varname#) can\'t be converted to #ctype#");\n\tif (f2py_success) {'))]), Dict([(Name('islogical'), Const('\t\t#varname# = (#ctype#)PyObject_IsTrue(#varname#_capi);\n\t\tf2py_success = 1;\n\tif (f2py_success) {'))])]), Const('cleanupfrompyobj') : Const('\t} /*if (f2py_success) of #varname#*/'), Const('need') : Dict([(CallFunc(Name('l_not'), [Name('islogical')], None, None), Const('#ctype#_from_pyobj'))]), Const('_check') : CallFunc(Name('l_and'), [Name('isscalar'), CallFunc(Name('l_not'), [Name('iscomplex')], None, None), Name('isintent_nothide')], None, None), Const('_depend') : Const('') }, { Const('frompyobj') : Dict([(Name('hasinitvalue'), Const('\t#varname# = #init#;'))]), Const('need') : Name('typedef_need_dict'), Const('_check') : CallFunc(Name('l_and'), [Name('isscalar'), CallFunc(Name('l_not'), [Name('iscomplex')], None, None), Name('isintent_hide')], None, None), Const('_depend') : Const('') }, { Const('frompyobj') : Dict([(Name('debugcapi'), Const('\tfprintf(stderr,"#vardebugshowvalue#\\n",#varname#);'))]), Const('_check') : CallFunc(Name('l_and'), [Name('isscalar'), CallFunc(Name('l_not'), [Name('iscomplex')], None, None)], None, None), Const('_depend') : Const('') }, { Const('decl') : Const('\t#ctype# #varname#;'), Const('callfortran') : Dict([(Name('isintent_c'), Const('#varname#,')), (CallFunc(Name('l_not'), [Name('isintent_c')], None, None), Const('varname#,'))]), Const('pyobjfrom') : Dict([(Name('debugcapi'), Const('\tfprintf(stderr,"#vardebugshowvalue#\\n",#varname#.r,#varname#.i);'))]), Const('return') : Dict([(Name('isintent_out'), Const(',#varname#_capi'))]), Const('_check') : Name('iscomplex') }, { Const('decl') : Const('\tPyObject *#varname#_capi = Py_None;'), Const('argformat') : Dict([(Name('isrequired'), Const('O'))]), Const('keyformat') : Dict([(Name('isoptional'), Const('O'))]), Const('args_capi') : Dict([(Name('isrequired'), Const(',varname#_capi'))]), Const('keys_capi') : Dict([(Name('isoptional'), Const(',varname#_capi'))]), Const('need') : Dict([(Name('isintent_inout'), Const('try_pyarr_from_#ctype#'))]), Const('pyobjfrom') : Dict([(Name('isintent_inout'), Const('\t\tf2py_success = try_pyarr_from_#ctype#(#varname#_capi,varname#);\n\t\tif (f2py_success) {'))]), Const('closepyobjfrom') : Dict([(Name('isintent_inout'), Const('\t\t} /*if (f2py_success) of #varname# pyobjfrom*/'))]), Const('_check') : CallFunc(Name('l_and'), [Name('iscomplex'), Name('isintent_nothide')], None, None) }, { Const('frompyobj') : List([Dict([(Name('hasinitvalue'), Const('\tif (#varname#_capi==Py_None) {#varname#.r = #init.r#, #varname#.i = #init.i#;} else'))]), Dict([(CallFunc(Name('l_and'), [Name('isoptional'), CallFunc(Name('l_not'), [Name('hasinitvalue')], None, None)], None, None), Const('\tif (#varname#_capi != Py_None)'))]), Const('\t\tf2py_success = #ctype#_from_pyobj(varname#,#varname#_capi,"#pyname#() #nth# (#varname#) can\'t be converted to #ctype#");\n\tif (f2py_success) {')]), Const('cleanupfrompyobj') : Const('\t} /*if (f2py_success) of #varname# frompyobj*/'), Const('need') : List([Const('#ctype#_from_pyobj')]), Const('_check') : CallFunc(Name('l_and'), [Name('iscomplex'), Name('isintent_nothide')], None, None), Const('_depend') : Const('') }, { Const('decl') : Dict([(Name('isintent_out'), Const('\tPyObject *#varname#_capi = Py_None;'))]), Const('_check') : CallFunc(Name('l_and'), [Name('iscomplex'), Name('isintent_hide')], None, None) }, { Const('frompyobj') : Dict([(Name('hasinitvalue'), Const('\t#varname#.r = #init.r#, #varname#.i = #init.i#;'))]), Const('_check') : CallFunc(Name('l_and'), [Name('iscomplex'), Name('isintent_hide')], None, None), Const('_depend') : Const('') }, { Const('pyobjfrom') : Dict([(Name('isintent_out'), Const('\t#varname#_capi = pyobj_from_#ctype#1(#varname#);'))]), Const('need') : List([Const('pyobj_from_#ctype#1')]), Const('_check') : Name('iscomplex') }, { Const('frompyobj') : Dict([(Name('debugcapi'), Const('\tfprintf(stderr,"#vardebugshowvalue#\\n",#varname#.r,#varname#.i);'))]), Const('_check') : Name('iscomplex'), Const('_depend') : Const('') }, { Const('decl') : List([Const('\t#ctype# #varname# = NULL;'), Const('\tint slen(#varname#);'), Const('\tPyObject *#varname#_capi = Py_None;')]), Const('callfortran') : Const('#varname#,'), Const('callfortranappend') : Const('slen(#varname#),'), Const('pyobjfrom') : Dict([(Name('debugcapi'), Const('\tfprintf(stderr,"#vardebugshowvalue#\\n",slen(#varname#),#varname#);'))]), Const('return') : Dict([(Name('isintent_out'), Const(',#varname#'))]), Const('need') : List([Const('len..')]), Const('_check') : Name('isstring') }, { Const('frompyobj') : Const('\tslen(#varname#) = #length#;\n\tf2py_success = #ctype#_from_pyobj(varname#,&slen(#varname#),#init#,#varname#_capi,"#ctype#_from_pyobj failed in converting #nth# `#varname#\' of #pyname# to C #ctype#");\n\tif (f2py_success) {'), Const('cleanupfrompyobj') : Const('\t\tSTRINGFREE(#varname#);\n\t} /*if (f2py_success) of #varname#*/'), Const('need') : List([Const('#ctype#_from_pyobj'), Const('len..'), Const('STRINGFREE')]), Const('_check') : Name('isstring'), Const('_depend') : Const('') }, { Const('argformat') : Dict([(Name('isrequired'), Const('O'))]), Const('keyformat') : Dict([(Name('isoptional'), Const('O'))]), Const('args_capi') : Dict([(Name('isrequired'), Const(',varname#_capi'))]), Const('keys_capi') : Dict([(Name('isoptional'), Const(',varname#_capi'))]), Const('pyobjfrom') : Dict([(Name('isintent_inout'), Const('\tf2py_success = try_pyarr_from_#ctype#(#varname#_capi,#varname#);\n\tif (f2py_success) {'))]), Const('closepyobjfrom') : Dict([(Name('isintent_inout'), Const('\t} /*if (f2py_success) of #varname# pyobjfrom*/'))]), Const('need') : Dict([(Name('isintent_inout'), Const('try_pyarr_from_#ctype#'))]), Const('_check') : CallFunc(Name('l_and'), [Name('isstring'), Name('isintent_nothide')], None, None) }, { Const('_check') : CallFunc(Name('l_and'), [Name('isstring'), Name('isintent_hide')], None, None) }, { Const('frompyobj') : Dict([(Name('debugcapi'), Const('\tfprintf(stderr,"#vardebugshowvalue#\\n",slen(#varname#),#varname#);'))]), Const('_check') : Name('isstring'), Const('_depend') : Const('') }, { Const('decl') : List([Const('\t#ctype# *#varname# = NULL;'), Const('\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};'), Const('\tconst int #varname#_Rank = #rank#;'), Const('\tPyArrayObject *capi_#varname#_tmp = NULL;'), Const('\tint capi_#varname#_intent = 0;')]), Const('callfortran') : Const('#varname#,'), Const('return') : Dict([(Name('isintent_out'), Const(',capi_#varname#_tmp'))]), Const('need') : Const('len..'), Const('_check') : Name('isarray') }, { Const('decl') : Const('\tint capi_overwrite_#varname# = 1;'), Const('kwlistxa') : Const('"overwrite_#varname#",'), Const('xaformat') : Const('i'), Const('keys_xa') : Const(',&capi_overwrite_#varname#'), Const('docsignxa') : Const('overwrite_#varname#=1,'), Const('docsignxashort') : Const('overwrite_#varname#,'), Const('docstropt') : Const('\toverwrite_#varname# := 1 input int'), Const('_check') : CallFunc(Name('l_and'), [Name('isarray'), Name('isintent_overwrite')], None, None) }, { Const('frompyobj') : Const('\tcapi_#varname#_intent |= (capi_overwrite_#varname#?0:F2PY_INTENT_COPY);'), Const('_check') : CallFunc(Name('l_and'), [Name('isarray'), Name('isintent_overwrite')], None, None), Const('_depend') : Const('') }, { Const('decl') : Const('\tint capi_overwrite_#varname# = 0;'), Const('kwlistxa') : Const('"overwrite_#varname#",'), Const('xaformat') : Const('i'), Const('keys_xa') : Const(',&capi_overwrite_#varname#'), Const('docsignxa') : Const('overwrite_#varname#=0,'), Const('docsignxashort') : Const('overwrite_#varname#,'), Const('docstropt') : Const('\toverwrite_#varname# := 0 input int'), Const('_check') : CallFunc(Name('l_and'), [Name('isarray'), Name('isintent_copy')], None, None) }, { Const('frompyobj') : Const('\tcapi_#varname#_intent |= (capi_overwrite_#varname#?0:F2PY_INTENT_COPY);'), Const('_check') : CallFunc(Name('l_and'), [Name('isarray'), Name('isintent_copy')], None, None), Const('_depend') : Const('') }, { Const('need') : List([Dict([(Name('hasinitvalue'), Const('forcomb'))]), Dict([(Name('hasinitvalue'), Const('CFUNCSMESS'))])]), Const('_check') : Name('isarray'), Const('_depend') : Const('') }, { Const('decl') : Const('\tPyObject *#varname#_capi = Py_None;'), Const('argformat') : Dict([(Name('isrequired'), Const('O'))]), Const('keyformat') : Dict([(Name('isoptional'), Const('O'))]), Const('args_capi') : Dict([(Name('isrequired'), Const(',varname#_capi'))]), Const('keys_capi') : Dict([(Name('isoptional'), Const(',varname#_capi'))]), Const('_check') : CallFunc(Name('l_and'), [Name('isarray'), Name('isintent_nothide')], None, None) }, { Const('frompyobj') : List([Const('\t#setdims#;'), Const('\tcapi_#varname#_intent |= #intent#;'), Dict([(Name('isintent_hide'), Const('\tcapi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,Py_None);'))]), Dict([(Name('isintent_nothide'), Const('\tcapi_#varname#_tmp = array_from_pyobj(#atype#,#varname#_Dims,#varname#_Rank,capi_#varname#_intent,#varname#_capi);'))]), Const('\tif (capi_#varname#_tmp == NULL) {\n\t\tif (!PyErr_Occurred())\n\t\t\tPyErr_SetString(#modulename#_error,"failed in converting #nth# `#varname#\' of #pyname# to C/Fortran array" );\n\t} else {\n\t\t#varname# = (#ctype# *)(capi_#varname#_tmp->data);\n'), Dict([(Name('hasinitvalue'), List([Dict([(Name('isintent_nothide'), Const('\tif (#varname#_capi == Py_None) {'))]), Dict([(Name('isintent_hide'), Const('\t{'))]), Dict([(Name('iscomplexarray'), Const('\t\t#ctype# capi_c;'))]), Const('\t\tint *_i,capi_i=0;\n\t\tCFUNCSMESS("#name#: Initializing #varname#=#init#\\n");\n\t\tif (initforcomb(capi_#varname#_tmp->dimensions,capi_#varname#_tmp->nd,1)) {\n\t\t\twhile ((_i = nextforcomb()))\n\t\t\t\t#varname#[capi_i++] = #init#; /* fortran way */\n\t\t} else {\n\t\t\tif (!PyErr_Occurred())\n\t\t\t\tPyErr_SetString(#modulename#_error,"Initialization of #nth# #varname# failed (initforcomb).");\n\t\t\tf2py_success = 0;\n\t\t}\n\t}\n\tif (f2py_success) {')]))])]), Const('cleanupfrompyobj') : List([Const('\t} /*if (capi_#varname#_tmp == NULL) ... else of #varname#*/'), Dict([(CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('isintent_out'), Name('isintent_hide')], None, None)], None, None), Const('\tif((PyObject *)capi_#varname#_tmp!=#varname#_capi) {\n\t\tPy_XDECREF(capi_#varname#_tmp); }'))]), Dict([(CallFunc(Name('l_and'), [Name('isintent_hide'), CallFunc(Name('l_not'), [Name('isintent_out')], None, None)], None, None), Const('\t\tPy_XDECREF(capi_#varname#_tmp);'))]), Dict([(Name('hasinitvalue'), Const('\t} /*if (f2py_success) of #varname# init*/'))])]), Const('_check') : Name('isarray'), Const('_depend') : Const('') }, { Const('_check') : CallFunc(Name('l_and'), [Name('isarray'), CallFunc(Name('l_not'), [Name('iscomplexarray')], None, None)], None, None) }, { Const('_check') : CallFunc(Name('l_and'), [Name('isarray'), CallFunc(Name('l_not'), [Name('iscomplexarray')], None, None), Name('isintent_nothide')], None, None) }, { Const('need') : Const('#ctype#'), Const('_check') : Name('isint1array'), Const('_depend') : Const('') }, { Const('need') : Const('#ctype#'), Const('_check') : Name('isunsigned_chararray'), Const('_depend') : Const('') }, { Const('need') : Const('#ctype#'), Const('_check') : Name('isunsigned_shortarray'), Const('_depend') : Const('') }, { Const('need') : Const('#ctype#'), Const('_check') : Name('isunsigned_long_longarray'), Const('_depend') : Const('') }, { Const('need') : Const('#ctype#'), Const('_check') : Name('iscomplexarray'), Const('_depend') : Const('') }, { Const('callfortranappend') : Dict([(Name('isarrayofstrings'), Const('flen(#varname#),'))]), Const('need') : Const('string'), Const('_check') : Name('isstringarray') } ]
aux_rules = [ { Const('separatorsfor') : Name('sepdict') }, { Const('frompyobj') : List([Const('\t/* Processing auxiliary variable #varname# */'), Dict([(Name('debugcapi'), Const('\tfprintf(stderr,"#vardebuginfo#\\n");'))])]), Const('cleanupfrompyobj') : Const('\t/* End of cleaning variable #varname# */'), Const('need') : Name('typedef_need_dict') }, { Const('decl') : Const('\t#ctype# #varname# = 0;'), Const('need') : Dict([(Name('hasinitvalue'), Const('math.h'))]), Const('frompyobj') : Dict([(Name('hasinitvalue'), Const('\t#varname# = #init#;'))]), Const('_check') : CallFunc(Name('l_and'), [Name('isscalar'), CallFunc(Name('l_not'), [Name('iscomplex')], None, None)], None, None) }, { Const('return') : Const(',#varname#'), Const('docstrout') : Const('\t#pydocsignout#'), Const('docreturn') : Const('#outvarname#,'), Const('returnformat') : Const('#varrformat#'), Const('_check') : CallFunc(Name('l_and'), [Name('isscalar'), CallFunc(Name('l_not'), [Name('iscomplex')], None, None), Name('isintent_out')], None, None) }, { Const('decl') : Const('\t#ctype# #varname#;'), Const('frompyobj') : Dict([(Name('hasinitvalue'), Const('\t#varname#.r = #init.r#, #varname#.i = #init.i#;'))]), Const('_check') : Name('iscomplex') }, { Const('decl') : List([Const('\t#ctype# #varname# = NULL;'), Const('\tint slen(#varname#);')]), Const('need') : List([Const('len..')]), Const('_check') : Name('isstring') }, { Const('decl') : List([Const('\t#ctype# *#varname# = NULL;'), Const('\tintp #varname#_Dims[#rank#] = {#rank*[-1]#};'), Const('\tconst int #varname#_Rank = #rank#;')]), Const('need') : List([Const('len..'), Dict([(Name('hasinitvalue'), Const('forcomb'))]), Dict([(Name('hasinitvalue'), Const('CFUNCSMESS'))])]), Const('_check') : Name('isarray') }, { Const('_check') : CallFunc(Name('l_and'), [Name('isarray'), CallFunc(Name('l_not'), [Name('iscomplexarray')], None, None)], None, None) }, { Const('_check') : CallFunc(Name('l_and'), [Name('isarray'), CallFunc(Name('l_not'), [Name('iscomplexarray')], None, None), Name('isintent_nothide')], None, None) }, { Const('need') : Const('#ctype#'), Const('_check') : Name('isint1array'), Const('_depend') : Const('') }, { Const('need') : Const('#ctype#'), Const('_check') : Name('isunsigned_chararray'), Const('_depend') : Const('') }, { Const('need') : Const('#ctype#'), Const('_check') : Name('isunsigned_shortarray'), Const('_depend') : Const('') }, { Const('need') : Const('#ctype#'), Const('_check') : Name('isunsigned_long_longarray'), Const('_depend') : Const('') }, { Const('need') : Const('#ctype#'), Const('_check') : Name('iscomplexarray'), Const('_depend') : Const('') }, { Const('callfortranappend') : Dict([(Name('isarrayofstrings'), Const('flen(#varname#),'))]), Const('need') : Const('string'), Const('_check') : Name('isstringarray') } ]
check_rules = [ { Const('frompyobj') : Dict([(Name('debugcapi'), Const('\tfprintf(stderr,"debug-capi:Checking `#check#\'\\n");'))]), Const('need') : Const('len..') }, { Const('frompyobj') : Const('\tCHECKSCALAR(#check#,"#check#","#nth# #varname#","#varshowvalue#",#varname#) {'), Const('cleanupfrompyobj') : Const('\t} /*CHECKSCALAR(#check#)*/'), Const('need') : Const('CHECKSCALAR'), Const('_check') : CallFunc(Name('l_and'), [Name('isscalar'), CallFunc(Name('l_not'), [Name('iscomplex')], None, None)], None, None), Const('_break') : Const('') }, { Const('frompyobj') : Const('\tCHECKSTRING(#check#,"#check#","#nth# #varname#","#varshowvalue#",#varname#) {'), Const('cleanupfrompyobj') : Const('\t} /*CHECKSTRING(#check#)*/'), Const('need') : Const('CHECKSTRING'), Const('_check') : Name('isstring'), Const('_break') : Const('') }, { Const('need') : Const('CHECKARRAY'), Const('frompyobj') : Const('\tCHECKARRAY(#check#,"#check#","#nth# #varname#") {'), Const('cleanupfrompyobj') : Const('\t} /*CHECKARRAY(#check#)*/'), Const('_check') : Name('isarray'), Const('_break') : Const('') }, { Const('need') : Const('CHECKGENERIC'), Const('frompyobj') : Const('\tCHECKGENERIC(#check#,"#check#","#nth# #varname#") {'), Const('cleanupfrompyobj') : Const('\t} /*CHECKGENERIC(#check#)*/') } ]
defmod_rules = [ { Const('body') : Const('/*eof body*/'), Const('method') : Const('/*eof method*/'), Const('externroutines') : Const('/*eof externroutines*/'), Const('routine_defs') : Const('/*eof routine_defs*/'), Const('initf90modhooks') : Const('/*eof initf90modhooks*/'), Const('initf2pywraphooks') : Const('/*eof initf2pywraphooks*/'), Const('initcommonhooks') : Const('/*eof initcommonhooks*/'), Const('latexdoc') : Const(''), Const('restdoc') : Const(''), Const('modnote') : Dict([(Name('hasnote'), Const('#note#')), (CallFunc(Name('l_not'), [Name('hasnote')], None, None), Const(''))]) } ]
errmess = sys.stderr.write
f2py_version = __version__.version
module_rules = { Const('modulebody') : Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Add((Const('/* File: #modulename#module.c\n * This file is auto-generated with f2py (version:#f2py_version#).\n * f2py is a Fortran to Python Interface Generator (FPIG), Second Edition,\n * written by Pearu Peterson .\n * See http://cens.ioc.ee/projects/f2py2e/\n * Generation date: '), CallFunc(Getattr(Name('time'), 'asctime'), [CallFunc(Getattr(Name('time'), 'localtime'), [CallFunc(Getattr(Name('time'), 'time'), [], None, None)], None, None)], None, None))), Const('\n * $R'))), Const('evision:$\n * $D'))), Const('ate:$\n * Do not edit this file directly unless you know what you are doing!!!\n */\n#ifdef __cplusplus\nextern "C" {\n#endif\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/cfuncs.py: includes')], None, None))), Const('\n#includes#\n#includes0#\n\n'))), CallFunc(Name('gentitle'), [Const("See f2py2e/rules.py: mod_rules['modulebody']")], None, None))), Const('\nstatic PyObject *#modulename#_error;\nstatic PyObject *#modulename#_module;\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/cfuncs.py: typedefs')], None, None))), Const('\n#typedefs#\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/cfuncs.py: typedefs_generated')], None, None))), Const('\n#typedefs_generated#\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/cfuncs.py: cppmacros')], None, None))), Const('\n#cppmacros#\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/cfuncs.py: cfuncs')], None, None))), Const('\n#cfuncs#\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/cfuncs.py: userincludes')], None, None))), Const('\n#userincludes#\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/capi_rules.py: usercode')], None, None))), Const('\n#usercode#\n\n/* See f2py2e/rules.py */\n#externroutines#\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/capi_rules.py: usercode1')], None, None))), Const('\n#usercode1#\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/cb_rules.py: buildcallback')], None, None))), Const('\n#callbacks#\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/rules.py: buildapi')], None, None))), Const('\n#body#\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/f90mod_rules.py: buildhooks')], None, None))), Const('\n#f90modhooks#\n\n'))), CallFunc(Name('gentitle'), [Const("See f2py2e/rules.py: module_rules['modulebody']")], None, None))), Const('\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/common_rules.py: buildhooks')], None, None))), Const('\n#commonhooks#\n\n'))), CallFunc(Name('gentitle'), [Const('See f2py2e/rules.py')], None, None))), Const('\n\nstatic FortranDataDef f2py_routine_defs[] = {\n#routine_defs#\n\t{NULL}\n};\n\nstatic PyMethodDef f2py_module_methods[] = {\n#pymethoddef#\n\t{NULL,NULL}\n};\n\nPyMODINIT_FUNC init#modulename#(void) {\n\tint i;\n\tPyObject *m,*d, *s;\n\tm = #modulename#_module = Py_InitModule("#modulename#", f2py_module_methods);\n\tPyFortran_Type.ob_type = &PyType_Type;\n\timport_array();\n\tif (PyErr_Occurred())\n\t\tPy_FatalError("can\'t initialize module #modulename# (failed to import numpy)");\n\td = PyModule_GetDict(m);\n\ts = PyString_FromString("$R'))), Const('evision: $");\n\tPyDict_SetItemString(d, "__version__", s);\n\ts = PyString_FromString("This module \'#modulename#\' is auto-generated with f2py (version:#f2py_version#).\\nFunctions:\\n"\n#docs#".");\n\tPyDict_SetItemString(d, "__doc__", s);\n\t#modulename#_error = PyErr_NewException ("#modulename#.error", NULL, NULL);\n\tPy_DECREF(s);\n\tfor(i=0;f2py_routine_defs[i].name!=NULL;i++)\n\t\tPyDict_SetItemString(d, f2py_routine_defs[i].name,PyFortranObject_NewAsAttr(&f2py_routine_defs[i]));\n#initf2pywraphooks#\n#initf90modhooks#\n#initcommonhooks#\n#interface_usercode#\n\n#ifdef F2PY_REPORT_ATEXIT\n\tif (! PyErr_Occurred())\n\t\ton_exit(f2py_report_on_exit,(void*)"#modulename#");\n#endif\n\n}\n#ifdef __cplusplus\n}\n#endif\n'))), Const('separatorsfor') : Dict([(Const('latexdoc'), Const('\n\n')), (Const('restdoc'), Const('\n\n'))]), Const('latexdoc') : List([Const('\\section{Module \\texttt{#texmodulename#}}\n'), Const('#modnote#\n'), Const('#latexdoc#')]), Const('restdoc') : List([Add((Const('Module #modulename#\n'), Mul((Const('='), Const(80))))), Const('\n#restdoc#')]) }
options = { }
outmess = sys.stdout.write
rout_rules = [ { Const('separatorsfor') : Dict([(Const('callfortranroutine'), Const('\n')), (Const('routdebugenter'), Const('\n')), (Const('decl'), Const('\n')), (Const('routdebugleave'), Const('\n')), (Const('routdebugfailure'), Const('\n')), (Const('setjmpbuf'), Const(' || ')), (Const('docstrreq'), Const('\n')), (Const('docstropt'), Const('\n')), (Const('docstrout'), Const('\n')), (Const('docstrcbs'), Const('\n')), (Const('docstrsigns'), Const('\\n"\n"')), (Const('latexdocstrsigns'), Const('\n')), (Const('latexdocstrreq'), Const('\n')), (Const('latexdocstropt'), Const('\n')), (Const('latexdocstrout'), Const('\n')), (Const('latexdocstrcbs'), Const('\n'))]), Const('kwlist') : Const(''), Const('kwlistopt') : Const(''), Const('callfortran') : Const(''), Const('callfortranappend') : Const(''), Const('docsign') : Const(''), Const('docsignopt') : Const(''), Const('decl') : Const('/*decl*/'), Const('freemem') : Const('/*freemem*/'), Const('docsignshort') : Const(''), Const('docsignoptshort') : Const(''), Const('docstrsigns') : Const(''), Const('latexdocstrsigns') : Const(''), Const('docstrreq') : Const('Required arguments:'), Const('docstropt') : Const('Optional arguments:'), Const('docstrout') : Const('Return objects:'), Const('docstrcbs') : Const('Call-back functions:'), Const('latexdocstrreq') : Const('\\noindent Required arguments:'), Const('latexdocstropt') : Const('\\noindent Optional arguments:'), Const('latexdocstrout') : Const('\\noindent Return objects:'), Const('latexdocstrcbs') : Const('\\noindent Call-back functions:'), Const('args_capi') : Const(''), Const('keys_capi') : Const(''), Const('functype') : Const(''), Const('frompyobj') : Const('/*frompyobj*/'), Const('cleanupfrompyobj') : List([Const('/*end of cleanupfrompyobj*/')]), Const('pyobjfrom') : Const('/*pyobjfrom*/'), Const('closepyobjfrom') : List([Const('/*end of closepyobjfrom*/')]), Const('topyarr') : Const('/*topyarr*/'), Const('routdebugleave') : Const('/*routdebugleave*/'), Const('routdebugenter') : Const('/*routdebugenter*/'), Const('routdebugfailure') : Const('/*routdebugfailure*/'), Const('callfortranroutine') : Const('/*callfortranroutine*/'), Const('argformat') : Const(''), Const('keyformat') : Const(''), Const('need_cfuncs') : Const(''), Const('docreturn') : Const(''), Const('return') : Const(''), Const('returnformat') : Const(''), Const('rformat') : Const(''), Const('kwlistxa') : Const(''), Const('keys_xa') : Const(''), Const('xaformat') : Const(''), Const('docsignxa') : Const(''), Const('docsignxashort') : Const(''), Const('initf2pywraphook') : Const(''), Const('routnote') : Dict([(Name('hasnote'), Const('--- #note#')), (CallFunc(Name('l_not'), [Name('hasnote')], None, None), Const(''))]) }, { Const('apiname') : Const('f2py_rout_#modulename#_#name#'), Const('pyname') : Const('#modulename#.#name#'), Const('decl') : Const(''), Const('_check') : CallFunc(Name('l_not'), [Name('ismoduleroutine')], None, None) }, { Const('apiname') : Const('f2py_rout_#modulename#_#f90modulename#_#name#'), Const('pyname') : Const('#modulename#.#f90modulename#.#name#'), Const('decl') : Const(''), Const('_check') : Name('ismoduleroutine') }, { Const('functype') : Const('void'), Const('declfortranroutine') : Dict([(CallFunc(Name('l_and'), [CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('ismoduleroutine'), Name('isintent_c')], None, None)], None, None), CallFunc(Name('l_not'), [Name('isdummyroutine')], None, None)], None, None), Const('extern void #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);')), (CallFunc(Name('l_and'), [CallFunc(Name('l_not'), [Name('ismoduleroutine')], None, None), Name('isintent_c'), CallFunc(Name('l_not'), [Name('isdummyroutine')], None, None)], None, None), Const('extern void #fortranname#(#callprotoargument#);')), (Name('ismoduleroutine'), Const('')), (Name('isdummyroutine'), Const(''))]), Const('routine_def') : Dict([(CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('ismoduleroutine'), Name('isintent_c'), Name('isdummyroutine')], None, None)], None, None), Const('\t{"#name#",-1,{{-1}},0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},')), (CallFunc(Name('l_and'), [CallFunc(Name('l_not'), [Name('ismoduleroutine')], None, None), Name('isintent_c'), CallFunc(Name('l_not'), [Name('isdummyroutine')], None, None)], None, None), Const('\t{"#name#",-1,{{-1}},0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},')), (CallFunc(Name('l_and'), [CallFunc(Name('l_not'), [Name('ismoduleroutine')], None, None), Name('isdummyroutine')], None, None), Const('\t{"#name#",-1,{{-1}},0,NULL,(f2py_init_func)#apiname#,doc_#apiname#},'))]), Const('need') : Dict([(CallFunc(Name('l_and'), [CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('ismoduleroutine'), Name('isintent_c')], None, None)], None, None), CallFunc(Name('l_not'), [Name('isdummyroutine')], None, None)], None, None), Const('F_FUNC'))]), Const('callfortranroutine') : List([Dict([(Name('debugcapi'), List([Const('\tfprintf(stderr,"debug-capi:Fortran subroutine `#fortranname#(#callfortran#)\'\\n");')]))]), Dict([(Name('hasexternals'), Const('\t\tif (#setjmpbuf#) {\n\t\t\tf2py_success = 0;\n\t\t} else {'))]), Dict([(Name('isthreadsafe'), Const('\t\t\tPy_BEGIN_ALLOW_THREADS'))]), Dict([(Name('hascallstatement'), Const('\t\t\t\t#callstatement#;\n\t\t\t\t/*(*f2py_func)(#callfortran#);*/'))]), Dict([(CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('hascallstatement'), Name('isdummyroutine')], None, None)], None, None), Const('\t\t\t\t(*f2py_func)(#callfortran#);'))]), Dict([(Name('isthreadsafe'), Const('\t\t\tPy_END_ALLOW_THREADS'))]), Dict([(Name('hasexternals'), Const('\t\t}'))])]), Const('_check') : Name('issubroutine') }, { Const('functype') : Const('void'), Const('declfortranroutine') : Dict([(CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('ismoduleroutine'), Name('isdummyroutine')], None, None)], None, None), Const('extern void #F_WRAPPEDFUNC#(#name_lower#,#NAME#)(#callprotoargument#);')), (Name('isdummyroutine'), Const(''))]), Const('routine_def') : Dict([(CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('ismoduleroutine'), Name('isdummyroutine')], None, None)], None, None), Const('\t{"#name#",-1,{{-1}},0,(char *)#F_WRAPPEDFUNC#(#name_lower#,#NAME#),(f2py_init_func)#apiname#,doc_#apiname#},')), (Name('isdummyroutine'), Const('\t{"#name#",-1,{{-1}},0,NULL,(f2py_init_func)#apiname#,doc_#apiname#},'))]), Const('initf2pywraphook') : Dict([(CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('ismoduleroutine'), Name('isdummyroutine')], None, None)], None, None), Const('\n {\n extern #ctype# #F_FUNC#(#name_lower#,#NAME#)(void);\n PyObject* o = PyDict_GetItemString(d,"#name#");\n PyObject_SetAttrString(o,"_cpointer", PyCObject_FromVoidPtr((void*)#F_FUNC#(#name_lower#,#NAME#),NULL));\n }\n '))]), Const('need') : Dict([(CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('ismoduleroutine'), Name('isdummyroutine')], None, None)], None, None), List([Const('F_WRAPPEDFUNC'), Const('F_FUNC')]))]), Const('callfortranroutine') : List([Dict([(Name('debugcapi'), List([Const('\tfprintf(stderr,"debug-capi:Fortran subroutine `f2pywrap#name_lower#(#callfortran#)\'\\n");')]))]), Dict([(Name('hasexternals'), Const('\tif (#setjmpbuf#) {\n\t\tf2py_success = 0;\n\t} else {'))]), Dict([(Name('isthreadsafe'), Const('\tPy_BEGIN_ALLOW_THREADS'))]), Dict([(CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('hascallstatement'), Name('isdummyroutine')], None, None)], None, None), Const('\t(*f2py_func)(#callfortran#);'))]), Dict([(Name('hascallstatement'), Const('\t#callstatement#;\n\t/*(*f2py_func)(#callfortran#);*/'))]), Dict([(Name('isthreadsafe'), Const('\tPy_END_ALLOW_THREADS'))]), Dict([(Name('hasexternals'), Const('\t}'))])]), Const('_check') : Name('isfunction_wrap') }, { Const('functype') : Const('#ctype#'), Const('docreturn') : Dict([(CallFunc(Name('l_not'), [Name('isintent_hide')], None, None), Const('#rname#,'))]), Const('docstrout') : Const('\t#pydocsignout#'), Const('latexdocstrout') : List([Const('\\item[]{{}\\verb@#pydocsignout#@{}}'), Dict([(Name('hasresultnote'), Const('--- #resultnote#'))])]), Const('callfortranroutine') : List([Dict([(CallFunc(Name('l_and'), [Name('debugcapi'), Name('isstringfunction')], None, None), Const('#ifdef USESCOMPAQFORTRAN\n\tfprintf(stderr,"debug-capi:Fortran function #ctype# #fortranname#(#callcompaqfortran#)\\n");\n#else\n\tfprintf(stderr,"debug-capi:Fortran function #ctype# #fortranname#(#callfortran#)\\n");\n#endif\n'))]), Dict([(CallFunc(Name('l_and'), [Name('debugcapi'), CallFunc(Name('l_not'), [Name('isstringfunction')], None, None)], None, None), Const('\tfprintf(stderr,"debug-capi:Fortran function #ctype# #fortranname#(#callfortran#)\\n");\n'))])]), Const('_check') : CallFunc(Name('l_and'), [Name('isfunction'), CallFunc(Name('l_not'), [Name('isfunction_wrap')], None, None)], None, None) }, { Const('declfortranroutine') : Dict([(CallFunc(Name('l_and'), [CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('ismoduleroutine'), Name('isintent_c')], None, None)], None, None), CallFunc(Name('l_not'), [Name('isdummyroutine')], None, None)], None, None), Const('extern #ctype# #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);')), (CallFunc(Name('l_and'), [CallFunc(Name('l_not'), [Name('ismoduleroutine')], None, None), Name('isintent_c'), CallFunc(Name('l_not'), [Name('isdummyroutine')], None, None)], None, None), Const('extern #ctype# #fortranname#(#callprotoargument#);')), (Name('isdummyroutine'), Const(''))]), Const('routine_def') : Dict([(CallFunc(Name('l_and'), [CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('ismoduleroutine'), Name('isintent_c')], None, None)], None, None), CallFunc(Name('l_not'), [Name('isdummyroutine')], None, None)], None, None), Const('\t{"#name#",-1,{{-1}},0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},')), (CallFunc(Name('l_and'), [CallFunc(Name('l_not'), [Name('ismoduleroutine')], None, None), Name('isintent_c'), CallFunc(Name('l_not'), [Name('isdummyroutine')], None, None)], None, None), Const('\t{"#name#",-1,{{-1}},0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},')), (Name('isdummyroutine'), Const('\t{"#name#",-1,{{-1}},0,NULL,(f2py_init_func)#apiname#,doc_#apiname#},'))]), Const('decl') : List([Dict([(Name('iscomplexfunction_warn'), Const('\t#ctype# #name#_return_value={0,0};')), (CallFunc(Name('l_not'), [Name('iscomplexfunction')], None, None), Const('\t#ctype# #name#_return_value=0;'))]), Dict([(Name('iscomplexfunction'), Const('\tPyObject *#name#_return_value_capi = Py_None;'))])]), Const('callfortranroutine') : List([Dict([(Name('hasexternals'), Const('\tif (#setjmpbuf#) {\n\t\tf2py_success = 0;\n\t} else {'))]), Dict([(Name('isthreadsafe'), Const('\tPy_BEGIN_ALLOW_THREADS'))]), Dict([(Name('hascallstatement'), Const('\t#callstatement#;\n/*\t#name#_return_value = (*f2py_func)(#callfortran#);*/\n'))]), Dict([(CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('hascallstatement'), Name('isdummyroutine')], None, None)], None, None), Const('\t#name#_return_value = (*f2py_func)(#callfortran#);'))]), Dict([(Name('isthreadsafe'), Const('\tPy_END_ALLOW_THREADS'))]), Dict([(Name('hasexternals'), Const('\t}'))]), Dict([(CallFunc(Name('l_and'), [Name('debugcapi'), Name('iscomplexfunction')], None, None), Const('\tfprintf(stderr,"#routdebugshowvalue#\\n",#name#_return_value.r,#name#_return_value.i);'))]), Dict([(CallFunc(Name('l_and'), [Name('debugcapi'), CallFunc(Name('l_not'), [Name('iscomplexfunction')], None, None)], None, None), Const('\tfprintf(stderr,"#routdebugshowvalue#\\n",#name#_return_value);'))])]), Const('pyobjfrom') : Dict([(Name('iscomplexfunction'), Const('\t#name#_return_value_capi = pyobj_from_#ctype#1(#name#_return_value);'))]), Const('need') : List([Dict([(CallFunc(Name('l_not'), [Name('isdummyroutine')], None, None), Const('F_FUNC'))]), Dict([(Name('iscomplexfunction'), Const('pyobj_from_#ctype#1'))]), Dict([(Name('islong_longfunction'), Const('long_long'))]), Dict([(Name('islong_doublefunction'), Const('long_double'))])]), Const('returnformat') : Dict([(CallFunc(Name('l_not'), [Name('isintent_hide')], None, None), Const('#rformat#'))]), Const('return') : Dict([(Name('iscomplexfunction'), Const(',#name#_return_value_capi')), (CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('iscomplexfunction'), Name('isintent_hide')], None, None)], None, None), Const(',#name#_return_value'))]), Const('_check') : CallFunc(Name('l_and'), [Name('isfunction'), CallFunc(Name('l_not'), [Name('isstringfunction')], None, None), CallFunc(Name('l_not'), [Name('isfunction_wrap')], None, None)], None, None) }, { Const('declfortranroutine') : Const('extern void #F_FUNC#(#fortranname#,#FORTRANNAME#)(#callprotoargument#);'), Const('routine_def') : Dict([(CallFunc(Name('l_not'), [CallFunc(Name('l_or'), [Name('ismoduleroutine'), Name('isintent_c')], None, None)], None, None), Const('\t{"#name#",-1,{{-1}},0,(char *)#F_FUNC#(#fortranname#,#FORTRANNAME#),(f2py_init_func)#apiname#,doc_#apiname#},')), (CallFunc(Name('l_and'), [CallFunc(Name('l_not'), [Name('ismoduleroutine')], None, None), Name('isintent_c')], None, None), Const('\t{"#name#",-1,{{-1}},0,(char *)#fortranname#,(f2py_init_func)#apiname#,doc_#apiname#},'))]), Const('decl') : List([Const('\t#ctype# #name#_return_value = NULL;'), Const('\tint #name#_return_value_len = 0;')]), Const('callfortran') : Const('#name#_return_value,#name#_return_value_len,'), Const('callfortranroutine') : List([Const('\t#name#_return_value_len = #rlength#;'), Const('\tif ((#name#_return_value = (string)malloc(sizeof(char)*(#name#_return_value_len+1))) == NULL) {'), Const('\t\tPyErr_SetString(PyExc_MemoryError, "out of memory");'), Const('\t\tf2py_success = 0;'), Const('\t} else {'), Const("\t\t(#name#_return_value)[#name#_return_value_len] = '\\0';"), Const('\t}'), Const('\tif (f2py_success) {'), Dict([(Name('hasexternals'), Const('\t\tif (#setjmpbuf#) {\n\t\t\tf2py_success = 0;\n\t\t} else {'))]), Dict([(Name('isthreadsafe'), Const('\t\tPy_BEGIN_ALLOW_THREADS'))]), Const('#ifdef USESCOMPAQFORTRAN\n\t\t(*f2py_func)(#callcompaqfortran#);\n#else\n\t\t(*f2py_func)(#callfortran#);\n#endif\n'), Dict([(Name('isthreadsafe'), Const('\t\tPy_END_ALLOW_THREADS'))]), Dict([(Name('hasexternals'), Const('\t\t}'))]), Dict([(Name('debugcapi'), Const('\t\tfprintf(stderr,"#routdebugshowvalue#\\n",#name#_return_value_len,#name#_return_value);'))]), Const('\t} /* if (f2py_success) after (string)malloc */')]), Const('returnformat') : Const('#rformat#'), Const('return') : Const(',#name#_return_value'), Const('freemem') : Const('\tSTRINGFREE(#name#_return_value);'), Const('need') : List([Const('F_FUNC'), Const('#ctype#'), Const('STRINGFREE')]), Const('_check') : CallFunc(Name('l_and'), [Name('isstringfunction'), CallFunc(Name('l_not'), [Name('isfunction_wrap')], None, None)], None, None) }, { Const('routdebugenter') : Const('\tfprintf(stderr,"debug-capi:Python C/API function #modulename#.#name#(#docsignature#)\\n");'), Const('routdebugleave') : Const('\tfprintf(stderr,"debug-capi:Python C/API function #modulename#.#name#: successful.\\n");'), Const('routdebugfailure') : Const('\tfprintf(stderr,"debug-capi:Python C/API function #modulename#.#name#: failure.\\n");'), Const('_check') : Name('debugcapi') } ]
routine_rules = { Const('separatorsfor') : Name('sepdict'), Const('body') : Const('\n#begintitle#\nstatic char doc_#apiname#[] = "\\\nFunction signature:\\n\\\n\t#docreturn##name#(#docsignatureshort#)\\n\\\n#docstrsigns#";\n/* #declfortranroutine# */\nstatic PyObject *#apiname#(const PyObject *capi_self,\n PyObject *capi_args,\n PyObject *capi_keywds,\n #functype# (*f2py_func)(#callprotoargument#)) {\n\tPyObject * volatile capi_buildvalue = NULL;\n\tvolatile int f2py_success = 1;\n#decl#\n\tstatic char *capi_kwlist[] = {#kwlist##kwlistopt##kwlistxa#NULL};\n#usercode#\n#routdebugenter#\n#ifdef F2PY_REPORT_ATEXIT\nf2py_start_clock();\n#endif\n\tif (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\\\n\t\t"#argformat#|#keyformat##xaformat#:#pyname#",\\\n\t\tcapi_kwlist#args_capi##keys_capi##keys_xa#))\n\t\treturn NULL;\n#frompyobj#\n/*end of frompyobj*/\n#ifdef F2PY_REPORT_ATEXIT\nf2py_start_call_clock();\n#endif\n#callfortranroutine#\nif (PyErr_Occurred())\n f2py_success = 0;\n#ifdef F2PY_REPORT_ATEXIT\nf2py_stop_call_clock();\n#endif\n/*end of callfortranroutine*/\n\t\tif (f2py_success) {\n#pyobjfrom#\n/*end of pyobjfrom*/\n\t\tCFUNCSMESS("Building return value.\\n");\n\t\tcapi_buildvalue = Py_BuildValue("#returnformat#"#return#);\n/*closepyobjfrom*/\n#closepyobjfrom#\n\t\t} /*if (f2py_success) after callfortranroutine*/\n/*cleanupfrompyobj*/\n#cleanupfrompyobj#\n\tif (capi_buildvalue == NULL) {\n#routdebugfailure#\n\t} else {\n#routdebugleave#\n\t}\n\tCFUNCSMESS("Freeing memory.\\n");\n#freemem#\n#ifdef F2PY_REPORT_ATEXIT\nf2py_stop_clock();\n#endif\n\treturn capi_buildvalue;\n}\n#endtitle#\n'), Const('routine_defs') : Const('#routine_def#'), Const('initf2pywraphooks') : Const('#initf2pywraphook#'), Const('externroutines') : Const('#declfortranroutine#'), Const('doc') : Const('#docreturn##name#(#docsignature#)'), Const('docshort') : Const('#docreturn##name#(#docsignatureshort#)'), Const('docs') : Const('"\t#docreturn##name#(#docsignature#)\\n"\n'), Const('need') : List([Const('arrayobject.h'), Const('CFUNCSMESS'), Const('MINMAX')]), Const('cppmacros') : Dict([(Name('debugcapi'), Const('#define DEBUGCFUNCS'))]), Const('latexdoc') : List([Const('\\subsection{Wrapper function \\texttt{#texname#}}\n'), Const('\n\\noindent{{}\\verb@#docreturn##name#@{}}\\texttt{(#latexdocsignatureshort#)}\n#routnote#\n\n#latexdocstrsigns#\n')]), Const('restdoc') : List([Add((Const('Wrapped function ``#name#``\n'), Mul((Const('-'), Const(80)))))]) }
sepdict = { }
show = pprint.pprint
stnd = { Const(1) : Const('st'), Const(2) : Const('nd'), Const(3) : Const('rd'), Const(4) : Const('th'), Const(5) : Const('th'), Const(6) : Const('th'), Const(7) : Const('th'), Const(8) : Const('th'), Const(9) : Const('th'), Const(0) : Const('th') }
typedef_need_dict = { Name('islong_long') : Const('long_long'), Name('islong_double') : Const('long_double'), Name('islong_complex') : Const('complex_long_double'), Name('isunsigned_char') : Const('unsigned_char'), Name('isunsigned_short') : Const('unsigned_short'), Name('isunsigned') : Const('unsigned'), Name('isunsigned_long_long') : Const('unsigned_long_long') }
Return