1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
<%
import SwigTypeParser
import Helper
Helper.setup(null,
[ 'void': 'Py_INCREF(Py_None); ${result} = Py_None;' ],
null,
[ 'p.q(const).char':'${api} = convertSlString(${slarg});',
'int':'${api} = convertSlInt(${slarg});'],
null)
%>
Module Name: ${module.@name}
<%
module.function.each { functionNode ->
%>
function: ${functionNode.@name}
<%
functionNode.parm.eachWithIndex { param, index ->
%>
parameter ${index}= name:${param.@name}, type:${param.@type}<% if (param.@value) { %>, default value: ${param.@value} <% } %>
lvalue:${SwigTypeParser.SwigType_lstr(param.@type)}
rvalue:${SwigTypeParser.SwigType_str(param.@type)}
code to handle parameter ${index} {
// declare and set the value that came in from the scripting language
ScriptingLanguageType sl_${param.@name} = /* set the value from the scripting language */;
// declare and set the variable that will contain the api parameter
${SwigTypeParser.SwigType_lstr(param.@type)} p_${param.@name};
${Helper.getInConversion(param.@type,'p_' + param.@name,'sl_' + param.@name, functionNode)}
}
<%
}
%>
code to invoke the api method {
${Helper.callingName(functionNode)}( <%
functionNode.parm.eachWithIndex { param, i ->
%> p_${param.@name}${i < functionNode.parm.size() - 1 ? "," : ""} <% } %> );
}
code to handle return value {
// This is an example of how Python handles return values
Py_Object* result;
${Helper.getOutConversion(Helper.getReturnSwigType(functionNode),'result',functionNode)}
return result;
}
<%
}
%>
|