Revision: 519
http://svn.sourceforge.net/pygccxml/?rev=519&view=rev
Author: mbaas
Date: 2006-09-04 02:50:33 -0700 (Mon, 04 Sep 2006)
Log Message:
-----------
Renamed attributes and variables so that individual words are separated by underscores.
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py
pyplusplus_dev/pyplusplus/function_transformers/code_manager.py
pyplusplus_dev/pyplusplus/function_transformers/substitution_manager.py
Modified: pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py
===================================================================
--- pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py 2006-09-04 08:16:39 UTC (rev 518)
+++ pyplusplus_dev/pyplusplus/function_transformers/arg_policies.py 2006-09-04 09:50:33 UTC (rev 519)
@@ -29,7 +29,7 @@
@type idx: int
"""
self.idx = idx
- self.localvar = "<not initialized>"
+ self.local_var = "<not initialized>"
def __str__(self):
return "Output(%d)"%(self.idx)
@@ -46,25 +46,25 @@
raise ValueError, 'Output variable %d ("%s") must be a reference or a pointer (got %s)'%(self.idx, arg.name, arg.type)
# Declare a local variable that will receive the output value
- self.localvar = sm.wrapperfunc.declare_local(arg.name, str(reftype.base))
+ self.local_var = sm.wrapper_func.declare_local(arg.name, str(reftype.base))
# Append the output to the result tuple
- sm.wrapperfunc.resultexprs.append(self.localvar)
+ sm.wrapper_func.result_exprs.append(self.local_var)
# Replace the expression in the C++ function call
if isinstance(reftype, declarations.pointer_t):
- sm.wrapperfunc.inputparams[self.idx-1] = "&%s"%self.localvar
+ sm.wrapper_func.input_params[self.idx-1] = "&%s"%self.local_var
else:
- sm.wrapperfunc.inputparams[self.idx-1] = self.localvar
+ sm.wrapper_func.input_params[self.idx-1] = self.local_var
def virtual_post_call(self, sm):
"""Extract the C++ value after the call to the Python function.
"""
- arg = sm.virtualfunc.arglist[self.idx-1]
+ arg = sm.virtual_func.arg_list[self.idx-1]
res = "// Extract the C++ value for output argument '%s' (index: %d)\n"%(arg.name, self.idx)
if isinstance(arg.type, declarations.pointer_t):
res += "*"
- res += "%s = boost::python::extract<%s>(%s[%d]);"%(arg.name, arg.type.base, sm.virtualfunc.resultvar, sm.wrapperfunc.resultexprs.index(self.localvar))
+ res += "%s = boost::python::extract<%s>(%s[%d]);"%(arg.name, arg.type.base, sm.virtual_func.result_var, sm.wrapper_func.result_exprs.index(self.local_var))
return res
Modified: pyplusplus_dev/pyplusplus/function_transformers/code_manager.py
===================================================================
--- pyplusplus_dev/pyplusplus/function_transformers/code_manager.py 2006-09-04 08:16:39 UTC (rev 518)
+++ pyplusplus_dev/pyplusplus/function_transformers/code_manager.py 2006-09-04 09:50:33 UTC (rev 519)
@@ -22,26 +22,26 @@
A code block can declare a local variable using L{declare_local()}
and it can manipulate one of the attributes that are used to
initialize the final variables (see the documentation of the
- instance variables below). The final variables (such as RETTYPE,
- FUNCNAME, ARGLIST, etc.) are stored as regular attributes of the
+ instance variables below). The final variables (such as RET_TYPE,
+ FUNC_NAME, ARG_LIST, etc.) are stored as regular attributes of the
object.
The functionality to perform a text substitution (using the
substitution() method) is inherited
from the class L{subst_t}.
- @ivar classname: The name of the class of which the generated function is a member. A value of None or an empty string is used for free functions. This attribute is used for creating the CLASSSPEC variable.
- @type classname: str
- @ivar rettype: Return type. The value may be any object where str(obj) is valid C++ code. The value None corresponds to void. This will be the value of the variable RETTYPE.
- @type rettype: str
- @ivar arglist: The argument list. The items are pygccxml argument_t objects. This list will appear in the variables ARGLIST, ARGLISTDEF and ARGLISTTYPES.
- @type arglist: list of argument_t
- @ivar inputparams: A list of strings that contain the input parameter for the function call. This list is used for the INPUTPARAMS variable.
- @type inputparams: list of str
- @ivar resultvar: The name of the variable that will receive the result of the function call. If None, the return value is ignored. This attribute will be used for the variable RESULTVARASSIGNMENT.
- @type resultvar: str
- @ivar resultexpr: A string containing the expression that will be put after the "return" statement. This expression is used for the variable RETURNSTMT.
- @type resultexpr: str
+ @ivar class_name: The name of the class of which the generated function is a member. A value of None or an empty string is used for free functions. This attribute is used for creating the CLASS_SPEC variable.
+ @type class_name: str
+ @ivar ret_type: Return type. The value may be any object where str(obj) is valid C++ code. The value None corresponds to void. This will be the value of the variable RET_TYPE.
+ @type ret_type: str
+ @ivar arg_list: The argument list. The items are pygccxml argument_t objects. This list will appear in the variables ARG_LIST, ARG_LIST_DEF and ARG_LIST_TYPES.
+ @type arg_list: list of argument_t
+ @ivar input_params: A list of strings that contain the input parameter for the function call. This list is used for the INPUT_PARAMS variable.
+ @type input_params: list of str
+ @ivar result_var: The name of the variable that will receive the result of the function call. If None, the return value is ignored. This attribute will be used for the variable RESULT_VAR_ASSIGNMENT.
+ @type result_var: str
+ @ivar result_expr: A string containing the expression that will be put after the "return" statement. This expression is used for the variable RETURN_STMT.
+ @type result_expr: str
@author: Matthias Baas
"""
@@ -50,30 +50,30 @@
"""Constructor.
"""
subst_t.__init__(self, blockvars=["DECLARATIONS",
- "PRECALL",
- "POSTCALL"])
+ "PRE_CALL",
+ "POST_CALL"])
# The name of the class of which the generated function is a member
# (pass None or an empty string if the function is a free function)
- self.classname = None
+ self.class_name = None
# Return type (the value may be any object where str(obj) is valid
# C++ code. The value None corresponds to "void").
- self.rettype = None
+ self.ret_type = None
# The argument list. The items are argument_t objects.
- self.arglist = []
+ self.arg_list = []
# A list of strings that contain the input parameter for the
# function call
- self.inputparams = []
+ self.input_params = []
# The name of the variable that will receive the result of the
# function call. If None, the return value is ignored.
- self.resultvar = None
+ self.result_var = None
# A string containing the expression that will be put after
# the "return" statement.
- self.resultexpr = None
+ self.result_expr = None
# Key:Variable name / Value:(type,size,default)
self._declared_vars = {}
@@ -110,7 +110,7 @@
"""
if name in self._declared_vars:
return True
- if filter(lambda a: a.name==name, self.arglist):
+ if filter(lambda a: a.name==name, self.arg_list):
return True
return False
@@ -140,29 +140,29 @@
attributes.
"""
- # CLASSSPEC
- if (self.classname in [None, ""]):
- self.CLASSSPEC = ""
+ # CLASS_SPEC
+ if (self.class_name in [None, ""]):
+ self.CLASS_SPEC = ""
else:
- self.CLASSSPEC = "%s::"%self.classname
+ self.CLASS_SPEC = "%s::"%self.class_name
- # RETTYPE
- if self.rettype==None:
- self.RETTYPE = "void"
+ # RET_TYPE
+ if self.ret_type==None:
+ self.RET_TYPE = "void"
else:
- self.RETTYPE = str(self.rettype)
+ self.RET_TYPE = str(self.ret_type)
- # ARGLISTDEF
- args = map(lambda a: str(a), self.arglist)
- self.ARGLISTDEF = ", ".join(args)
+ # ARG_LIST_DEF
+ args = map(lambda a: str(a), self.arg_list)
+ self.ARG_LIST_DEF = ", ".join(args)
- # ARGLIST
+ # ARG_LIST
args = map(lambda s: s.split("=")[0], args)
- self.ARGLIST = ", ".join(args)
+ self.ARG_LIST = ", ".join(args)
- # ARGLISTTYPES
- args = map(lambda a: str(a.type), self.arglist)
- self.ARGLISTTYPES = ", ".join(args)
+ # ARG_LIST_TYPES
+ args = map(lambda a: str(a.type), self.arg_list)
+ self.ARG_LIST_TYPES = ", ".join(args)
# Create the declaration block -> DECLARATIONS
vardecls = []
@@ -176,16 +176,16 @@
vardecls.append(vd+";")
self.DECLARATIONS = "\n".join(vardecls)
- # RESULTVARASSIGNMENT
- if self.resultvar!=None:
- self.RESULTVARASSIGNMENT = "%s = "%self.resultvar
+ # RESULT_VAR_ASSIGNMENT
+ if self.result_var!=None:
+ self.RESULT_VAR_ASSIGNMENT = "%s = "%self.result_var
- # INPUTPARAMS
- self.INPUTPARAMS = ", ".join(self.inputparams)
+ # INPUT_PARAMS
+ self.INPUT_PARAMS = ", ".join(self.input_params)
- # RETURNSTMT
- if self.resultexpr!=None:
- self.RETURNSTMT = "return %s;"%self.resultexpr
+ # RETURN_STMT
+ if self.result_expr!=None:
+ self.RETURN_STMT = "return %s;"%self.result_expr
# _make_name_unique
def _make_name_unique(self, name):
@@ -212,12 +212,12 @@
"""The CodeManager class for the wrapper function.
In contrast to a regular C++ function a Python function can return
- several values, so this class provides the extra attribute "resultexprs"
+ several values, so this class provides the extra attribute "result_exprs"
which is a list of individual expressions. Apart from that this
class is identical to L{code_manager_t}.
- @ivar resultexprs: Similar to resultexpr but this list variable can contain more than just one result. The items can be either strings containing the variable names (or expressions) that should be returned or it can be an argument_t object (usually from the argument list of the virtual function) whose name attribute will be used. This attribute only exists on the code manager for the wrapper function (the virtual function cannot return several values, use resultexpr instead).
- @type resultexprs: list of str or argument_t
+ @ivar result_exprs: Similar to result_expr but this list variable can contain more than just one result. The items can be either strings containing the variable names (or expressions) that should be returned or it can be an argument_t object (usually from the argument list of the virtual function) whose name attribute will be used. This attribute only exists on the code manager for the wrapper function (the virtual function cannot return several values, use result_expr instead).
+ @type result_exprs: list of str or argument_t
"""
def __init__(self):
@@ -225,41 +225,41 @@
"""
code_manager_t.__init__(self)
- # Similar to resultexpr but now there can be more than just one result
+ # Similar to result_expr but now there can be more than just one result
# The items can be either strings containing the variable names (or
# expressions) that should be returned or it can be an argument_t
# object (usually from the argument list of the virtual function)
# whose name attribute will be used.
- self.resultexprs = []
+ self.result_exprs = []
def init_variables(self):
"""Initialize the substitution variables.
"""
- # Prepare the variables for RETTYPE and RETURNSTMT...
+ # Prepare the variables for RET_TYPE and RETURN_STMT...
# Convert all items into strings
- resultexprs = []
- for re in self.resultexprs:
+ result_exprs = []
+ for re in self.result_exprs:
# String?
if isinstance(re, types.StringTypes):
- resultexprs.append(re)
+ result_exprs.append(re)
# argument_t
else:
- resultexprs.append(re.name)
+ result_exprs.append(re.name)
# No output values?
- if len(resultexprs)==0:
- self.rettype = None
- self.resultexpr = None
+ if len(result_exprs)==0:
+ self.ret_type = None
+ self.result_expr = None
# Exactly one output value?
- elif len(resultexprs)==1:
- self.rettype = "boost::python::object"
- self.resultexpr = "boost::python::object(%s)"%resultexprs[0]
+ elif len(result_exprs)==1:
+ self.ret_type = "boost::python::object"
+ self.result_expr = "boost::python::object(%s)"%result_exprs[0]
# More than one output value...
else:
- self.rettype = "boost::python::object"
- self.resultexpr = "boost::python::make_tuple(%s)"%(", ".join(resultexprs))
+ self.ret_type = "boost::python::object"
+ self.result_expr = "boost::python::make_tuple(%s)"%(", ".join(result_exprs))
# Invoke the inherited method that sets the actual variables
code_manager_t.init_variables(self)
Modified: pyplusplus_dev/pyplusplus/function_transformers/substitution_manager.py
===================================================================
--- pyplusplus_dev/pyplusplus/function_transformers/substitution_manager.py 2006-09-04 08:16:39 UTC (rev 518)
+++ pyplusplus_dev/pyplusplus/function_transformers/substitution_manager.py 2006-09-04 09:50:33 UTC (rev 519)
@@ -29,17 +29,17 @@
entire wrapper function. Such a template string may look like
this::
- $RETTYPE $CLASSSPEC$FUNCNAME($ARGLIST)
+ $RET_TYPE $CLASS_SPEC$FUNC_NAME($ARG_LIST)
{
$DECLARATIONS
- $PRECALL
+ $PRE_CALL
- $RESULTVARASSIGNMENT$CALLFUNCNAME($INPUTPARAMS);
+ $RESULT_VAR_ASSIGNMENT$CALL_FUNC_NAME($INPUT_PARAMS);
- $POSTCALL
+ $POST_CALL
- $RETURNSTMT
+ $RETURN_STMT
}
Any part of the function that is not fixed, i.e. that can be
@@ -65,17 +65,17 @@
In this example, the individual variables have the following values:
- - RETTYPE = C{boost::python::object}
- - CLASSSPEC = C{Spam_wrapper::}
- - FUNCNAME = C{foo_wrapper}
- - ARGLIST = C{Spam& self, int mode}
+ - RET_TYPE = C{boost::python::object}
+ - CLASS_SPEC = C{Spam_wrapper::}
+ - FUNC_NAME = C{foo_wrapper}
+ - ARG_LIST = C{Spam& self, int mode}
- DECLARATIONS = C{int result;\\nint w;\\nint h;}
- - PRECALL = <empty>
- - RESULTVARASSIGNMENT = C{result =}
- - CALLFUNCNAME = C{self.foo}
- - INPUTPARAMS = C{w, &h, mode}
- - POSTCALL = <empty>
- - RETURNSTMT = C{return boost::python::make_tuple(result, w, h);}
+ - PRE_CALL = <empty>
+ - RESULT_VAR_ASSIGNMENT = C{result =}
+ - CALL_FUNC_NAME = C{self.foo}
+ - INPUT_PARAMS = C{w, &h, mode}
+ - POST_CALL = <empty>
+ - RETURN_STMT = C{return boost::python::make_tuple(result, w, h);}
Modifying the variables
@@ -84,11 +84,11 @@
In addition to the actual user of the class (who wants to do text
substitutions), the class is also used by the arg policies (code blocks)
to modify the variables.
- There are two attributes L{wrapperfunc} and L{virtualfunc} that are
+ There are two attributes L{wrapper_func} and L{virtual_func} that are
used to modify either the wrapper or the virtual function. If the
signature of the wrapper needs modification this should be done via
the methods L{remove_arg()} and L{insert_arg()} and not via the
- wrapperfunc or virtualfunc attributes because this affects the
+ wrapper_func or virtual_func attributes because this affects the
virtual function as well (because the virtual function makes a call
to the Python function).
@@ -96,21 +96,21 @@
=========
- - RETTYPE: The return type (e.g. "void", "int", "boost::python::object")
+ - RET_TYPE: The return type (e.g. "void", "int", "boost::python::object")
- - CLASSSPEC: "<classname>::" or empty
+ - CLASS_SPEC: "<classname>::" or empty
- - FUNCNAME: The name of the wrapper or virtual function.
+ - FUNC_NAME: The name of the wrapper or virtual function.
- - ARGLIST: The parameters for $FUNCNAME (including self if required)
+ - ARG_LIST: The parameters for $FUNC_NAME (including self if required)
- - ARGLISTDEF: Like ARGLIST, but including default values (if there are any)
+ - ARG_LIST_DEF: Like ARG_LIST, but including default values (if there are any)
- - ARGLISTTYPES: Like ARGLIST but the variable names are left out and only the types are listed (this can identify a particular signature).
+ - ARG_LIST_TYPES: Like ARG_LIST but the variable names are left out and only the types are listed (this can identify a particular signature).
- DECLARATIONS: The declaration block
- - PRECALL::
+ - PRE_CALL::
+--------------------------+
| [try {] |
@@ -124,14 +124,14 @@
| Pre-call code block n |
+--------------------------+
- - RESULTVARASSIGNMENT: "<varname> = " or empty
+ - RESULT_VAR_ASSIGNMENT: "<varname> = " or empty
- - CALLFUNCNAME: The name of the function that should be invoked (self?).
+ - CALL_FUNC_NAME: The name of the function that should be invoked (self?).
- - INPUTPARAMS: The values or variables that will be passed to $FUNCNAME,
+ - INPUT_PARAMS: The values or variables that will be passed to $FUNC_NAME,
e.g. "a, b" or "0.5, 1.5" etc
- - POSTCALL::
+ - POST_CALL::
+--------------------------+
| Post-call code block n |
@@ -145,13 +145,13 @@
| [} catch(...) {...}] |
+--------------------------+
- - RETURNSTMT: "return <varname>" or "return boost::python::make_tuple(...)"
+ - RETURN_STMT: "return <varname>" or "return boost::python::make_tuple(...)"
- @ivar wrapperfunc: The L{code manager<code_manager_t>} object that manages the wrapper function. This is used by the arg policies to modify the wrapper function.
- @type wrapperfunc: L{wrapper_code_manager_t}
- @ivar virtualfunc: The L{code manager<code_manager_t>} object that manages the virtual function. This is used by the arg policies to modify the virtual function.
- @type virtualfunc: L{code_manager_t}
+ @ivar wrapper_func: The L{code manager<code_manager_t>} object that manages the wrapper function. This is used by the arg policies to modify the wrapper function.
+ @type wrapper_func: L{wrapper_code_manager_t}
+ @ivar virtual_func: The L{code manager<code_manager_t>} object that manages the virtual function. This is used by the arg policies to modify the virtual function.
+ @type virtual_func: L{code_manager_t}
@group Methods called by the user of the class: append_code_block, subst_wrapper, subst_virtual, get_includes
@group Methods called by the arg policies: remove_arg, insert_arg, require_include
@@ -159,21 +159,21 @@
@author: Matthias Baas
"""
- def __init__(self, decl, wrapperclass=None, transformers=None):
+ def __init__(self, decl, wrapper_class=None, transformers=None):
"""Constructor.
@param decl: calldef declaration
@type decl: calldef_t
- @param wrapperclass: The name of the class the generated function should belong to (or None if the generated function should be a free function)
- @type wrapperclass: str
+ @param wrapper_class: The name of the class the generated function should belong to (or None if the generated function should be a free function)
+ @type wrapper_class: str
@param transformers: Function transformer objects
@type transformers: list of function_transformer_t
"""
# Code manager for the virtual function
- self.virtualfunc = code_manager_t()
+ self.virtual_func = code_manager_t()
# Code manager for the wrapper function
- self.wrapperfunc = wrapper_code_manager_t()
+ self.wrapper_func = wrapper_code_manager_t()
# The declaration that represents the original C++ function
self.decl = decl
@@ -183,7 +183,7 @@
transformers = []
self.transformers = transformers
- self.wrapperclass = wrapperclass
+ self.wrapper_class = wrapper_class
# A list of required include files
self._virtual_includes = []
@@ -192,33 +192,33 @@
# Initialize the code managers...
if str(decl.return_type)=="void":
- rettype = None
+ ret_type = None
else:
- rettype = decl.return_type
- self.wrapperfunc.resultvar = self.wrapperfunc.declare_local("result", str(rettype))
- self.wrapperfunc.resultexprs = [self.wrapperfunc.resultvar]
+ ret_type = decl.return_type
+ self.wrapper_func.result_var = self.wrapper_func.declare_local("result", str(ret_type))
+ self.wrapper_func.result_exprs = [self.wrapper_func.result_var]
- self.virtualfunc.rettype = rettype
- self.virtualfunc.arglist = decl.arguments[:]
- self.virtualfunc.classname = wrapperclass
- self.virtualfunc.FUNCNAME = decl.name
- self.virtualfunc.CALLFUNCNAME = decl.name
- self.virtualfunc.inputparams = map(lambda a: a.name, decl.arguments)
+ self.virtual_func.ret_type = ret_type
+ self.virtual_func.arg_list = decl.arguments[:]
+ self.virtual_func.class_name = wrapper_class
+ self.virtual_func.FUNC_NAME = decl.name
+ self.virtual_func.CALL_FUNC_NAME = decl.name
+ self.virtual_func.input_params = map(lambda a: a.name, decl.arguments)
- self.wrapperfunc.rettype = rettype
- self.wrapperfunc.arglist = decl.arguments[:]
- self.wrapperfunc.classname = wrapperclass
- self.wrapperfunc.FUNCNAME = "%s_wrapper"%decl.alias
- self.wrapperfunc.CALLFUNCNAME = decl.name
- self.wrapperfunc.inputparams = map(lambda a: a.name, decl.arguments)
+ self.wrapper_func.ret_type = ret_type
+ self.wrapper_func.arg_list = decl.arguments[:]
+ self.wrapper_func.class_name = wrapper_class
+ self.wrapper_func.FUNC_NAME = "%s_wrapper"%decl.alias
+ self.wrapper_func.CALL_FUNC_NAME = decl.name
+ self.wrapper_func.input_params = map(lambda a: a.name, decl.arguments)
# Check if we're dealing with a member function...
- clsdecl = self._classDecl(decl)
+ clsdecl = self._class_decl(decl)
if clsdecl!=None:
- selfname = self.wrapperfunc._make_name_unique("self")
+ selfname = self.wrapper_func._make_name_unique("self")
selfarg = declarations.argument_t(selfname, "%s&"%clsdecl.name)
- self.wrapperfunc.arglist.insert(0, selfarg)
- self.wrapperfunc.CALLFUNCNAME = "%s.%s"%(selfname, self.wrapperfunc.CALLFUNCNAME)
+ self.wrapper_func.arg_list.insert(0, selfarg)
+ self.wrapper_func.CALL_FUNC_NAME = "%s.%s"%(selfname, self.wrapper_func.CALL_FUNC_NAME)
# Argument index map
# Original argument index ---> Input arg index (indices are 0-based!)
@@ -257,12 +257,12 @@
# Create a variable that will hold the result of the Python call
# inside the virtual function.
- if len(self.wrapperfunc.resultexprs)>0:
- self.virtualfunc.resultvar = self.virtualfunc.declare_local("pyresult", "boost::python::object")
-# self.virtualfunc.resultexpr = self.virtualfunc.resultvar
+ if len(self.wrapper_func.result_exprs)>0:
+ self.virtual_func.result_var = self.virtual_func.declare_local("pyresult", "boost::python::object")
+# self.virtual_func.result_expr = self.virtual_func.result_var
- self.wrapperfunc.init_variables()
- self.virtualfunc.init_variables()
+ self.wrapper_func.init_variables()
+ self.virtual_func.init_variables()
self._funcs_initialized = True
@@ -273,27 +273,27 @@
src = map(lambda cb: getattr(cb, "wrapper_pre_call", defmeth)(self), transformers)
src = filter(lambda x: x!=None, src)
precall = "\n\n".join(src)
- self.wrapperfunc.PRECALL = precall
+ self.wrapper_func.PRE_CALL = precall
# Create the wrapper function post-call block...
src = map(lambda cb: getattr(cb, "wrapper_post_call", defmeth)(self), transformers)
src = filter(lambda x: x!=None, src)
src.reverse()
postcall = "\n\n".join(src)
- self.wrapperfunc.POSTCALL = postcall
+ self.wrapper_func.POST_CALL = postcall
# Create the virtual function pre-call block...
src = map(lambda cb: getattr(cb, "virtual_pre_call", defmeth)(self), transformers)
src = filter(lambda x: x!=None, src)
precall = "\n\n".join(src)
- self.virtualfunc.PRECALL = precall
+ self.virtual_func.PRE_CALL = precall
# Create the virtual function post-call block...
src = map(lambda cb: getattr(cb, "virtual_post_call", defmeth)(self), transformers)
src = filter(lambda x: x!=None, src)
src.reverse()
postcall = "\n\n".join(src)
- self.virtualfunc.POSTCALL = postcall
+ self.virtual_func.POST_CALL = postcall
# remove_arg
@@ -317,23 +317,23 @@
if self._funcs_initialized:
raise ValueError, "remove_arg() may only be called before function initialization."
if idx<0:
- idx += len(self.virtualfunc.arglist)+1
- if idx>=len(self.virtualfunc.arglist)+1:
+ idx += len(self.virtual_func.arg_list)+1
+ if idx>=len(self.virtual_func.arg_list)+1:
raise IndexError, "Index (%d) out of range."%idx
# Remove original return type?
if idx==0:
- if id(self.wrapperfunc.rettype)==id(self.wrapperfunc.rettype):
- self.wrapperfunc.rettype = None
+ if id(self.wrapper_func.ret_type)==id(self.wrapper_func.ret_type):
+ self.wrapper_func.ret_type = None
else:
raise ValueError, 'Argument %d not found on the wrapper function'%(idx)
# Remove argument...
else:
# Get the original argument...
- arg = self.virtualfunc.arglist[idx-1]
+ arg = self.virtual_func.arg_list[idx-1]
# ...and remove it from the wrapper
try:
- self.wrapperfunc.arglist.remove(arg)
+ self.wrapper_func.arg_list.remove(arg)
except ValueError:
raise ValueError, 'Argument %d ("%s") not found on the wrapper function'%(idx, arg.name)
@@ -342,7 +342,7 @@
paramidx = self.argidxmap[idx-1]
if paramidx==None:
raise ValueError, "Argument was already removed"
- del self.virtualfunc.inputparams[paramidx]
+ del self.virtual_func.input_params[paramidx]
self.argidxmap[idx-1] = None
for i in range(idx,len(self.argidxmap)):
if self.argidxmap[i]!=None:
@@ -368,11 +368,11 @@
pass
else:
if idx<0:
- idx += len(self.wrapperfunc.arglist)+2
- self.wrapperfunc.arglist.insert(idx-1, arg)
+ idx += len(self.wrapper_func.arg_list)+2
+ self.wrapper_func.arg_list.insert(idx-1, arg)
# What to insert?
- self.virtualfunc.inputparams.insert(idx-1, "???")
+ self.virtual_func.input_params.insert(idx-1, "???")
# Adjust the argument index map
for i in range(idx-1,len(self.argidxmap)):
if self.argidxmap[i]!=None:
@@ -447,7 +447,7 @@
"""
if not self._funcs_initialized:
self.init_funcs()
- return self.virtualfunc.substitute(template)
+ return self.virtual_func.substitute(template)
# subst_wrapper
def subst_wrapper(self, template):
@@ -458,10 +458,10 @@
"""
if not self._funcs_initialized:
self.init_funcs()
- return self.wrapperfunc.substitute(template)
+ return self.wrapper_func.substitute(template)
- # _classDecl
- def _classDecl(self, decl):
+ # _class_decl
+ def _class_decl(self, decl):
"""Return the class declaration that belongs to a member declaration.
"""
while decl.parent!=None:
@@ -482,22 +482,22 @@
def __init__(self):
function_transformer_t.__init__(self)
- self.resultvar = "<not initialized>"
+ self.result_var = "<not initialized>"
def __str__(self):
return "ReturnVirtualResult()"%(self.idx)
def init_funcs(self, sm):
- if sm.virtualfunc.rettype==None:
+ if sm.virtual_func.ret_type==None:
return
# Declare the local variable that will hold the return value
# for the virtual function
- self.resultvar = sm.virtualfunc.declare_local("result", sm.virtualfunc.rettype)
+ self.result_var = sm.virtual_func.declare_local("result", sm.virtual_func.ret_type)
# Replace the result expression if there is still the default
# result expression (which will not work anyway)
- if sm.virtualfunc.resultexpr==sm.virtualfunc.resultvar:
- sm.virtualfunc.resultexpr = self.resultvar
+ if sm.virtual_func.result_expr==sm.virtual_func.result_var:
+ sm.virtual_func.result_expr = self.result_var
def virtual_post_call(self, sm):
# Search the result tuple of the wrapper function for the return
@@ -505,12 +505,12 @@
# from the Python result tuple, converted to C++ and returned from
# the virtual function. If it does not exist, do nothing.
try:
- resultidx = sm.wrapperfunc.resultexprs.index(sm.wrapperfunc.resultvar)
+ resultidx = sm.wrapper_func.result_exprs.index(sm.wrapper_func.result_var)
except ValueError:
return
res = "// Extract the C++ return value\n"
- res += "%s = boost::python::extract<%s>(%s[%d]);"%(self.resultvar, sm.virtualfunc.rettype, sm.virtualfunc.resultvar, resultidx)
+ res += "%s = boost::python::extract<%s>(%s[%d]);"%(self.result_var, sm.virtual_func.ret_type, sm.virtual_func.result_var, resultidx)
return res
@@ -532,19 +532,19 @@
spam = root[0].class_("Spam")
foo = spam.member_function("foo")
- wm = substitution_manager_t(foo, transformers=[Output(1), Output(2)], wrapperclass="Spam_wrapper")
+ wm = substitution_manager_t(foo, transformers=[Output(1), Output(2)], wrapper_class="Spam_wrapper")
- template = '''$RETTYPE $CLASSSPEC$FUNCNAME($ARGLIST)
+ template = '''$RET_TYPE $CLASS_SPEC$FUNC_NAME($ARG_LIST)
{
$DECLARATIONS
- $PRECALL
+ $PRE_CALL
- $RESULTVARASSIGNMENT$CALLFUNCNAME($INPUTPARAMS);
+ $RESULT_VAR_ASSIGNMENT$CALL_FUNC_NAME($INPUT_PARAMS);
- $POSTCALL
+ $POST_CALL
- $RETURNSTMT
+ $RETURN_STMT
}
'''
print wm.subst_virtual(template)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|