diff --git a/pybindgen/container.py b/pybindgen/container.py index da9f0a7..0b37c86 100644 --- a/pybindgen/container.py +++ b/pybindgen/container.py @@ -95,20 +95,20 @@ container_traits_list = { class Container(object): def __init__(self, name, value_type, container_type, outer_class=None, custom_name=None): """ - @param name: C++ type name of the container, e.g. std::vector or MyIntList + :param name: C++ type name of the container, e.g. std::vector or MyIntList - @param value_type: a ReturnValue of the element type: note, + :param value_type: a ReturnValue of the element type: note, for mapping containers, value_type is a tuple with two ReturnValue's: (key, element). - @param container_type: a string with the type of container, + :param container_type: a string with the type of container, one of 'list', 'deque', 'queue', 'priority_queue', 'vector', 'stack', 'set', 'multiset', 'hash_set', 'hash_multiset', 'map' - @param outer_class: if the type is defined inside a class, must be a reference to the outer class - @type outer_class: None or L{CppClass} + :param outer_class: if the type is defined inside a class, must be a reference to the outer class + :type outer_class: None or L{CppClass} - @param custom_name: alternative name to register with in the Python module + :param custom_name: alternative name to register with in the Python module """ if '<' in name or '::' in name: diff --git a/pybindgen/cppattribute.py b/pybindgen/cppattribute.py index d54660b..1299763 100644 --- a/pybindgen/cppattribute.py +++ b/pybindgen/cppattribute.py @@ -243,12 +243,12 @@ class PyMetaclass(object): """ def __init__(self, name, parent_metaclass_expr, getsets=None): """ - @param name: name of the metaclass (should normally end with Meta) - @param parent_metaclass_expr: C expression that should give a + :param name: name of the metaclass (should normally end with Meta) + :param parent_metaclass_expr: C expression that should give a pointer to the parent metaclass (should have a C type of PyTypeObject*) - @param getsets: name of a PyGetSetDef C array variable, or None + :param getsets: name of a PyGetSetDef C array variable, or None """ assert getsets is None or isinstance(getsets, PyGetSetDef) assert isinstance(name, basestring) diff --git a/pybindgen/cppclass.py b/pybindgen/cppclass.py index 27810d4..efa1cf9 100644 --- a/pybindgen/cppclass.py +++ b/pybindgen/cppclass.py @@ -158,11 +158,11 @@ def default_instance_creation_function(cpp_class, code_block, lvalue, C++ class instance needs to be created; this default implementation uses a standard C++ new allocator. - @param cpp_class: the CppClass object whose instance is to be created - @param code_block: CodeBlock object on which the instance creation code should be generated - @param lvalue: lvalue expression that should hold the result in the end - @param parameters: stringified list of parameters - @param construct_type_name: actual name of type to be constructed (it is + :param cpp_class: the CppClass object whose instance is to be created + :param code_block: CodeBlock object on which the instance creation code should be generated + :param lvalue: lvalue expression that should hold the result in the end + :param parameters: stringified list of parameters + :param construct_type_name: actual name of type to be constructed (it is not always the class name, sometimes it's the python helper class) """ @@ -439,51 +439,51 @@ class CppClass(object): custom_name=None, ): """ - @param name: class name - @param parent: optional parent class wrapper - @param incref_method: (deprecated in favour of memory_policy) if the class supports reference counting, the + :param name: class name + :param parent: optional parent class wrapper + :param incref_method: (deprecated in favour of memory_policy) if the class supports reference counting, the name of the method that increments the reference count (may be inherited from parent if not given) - @param decref_method: (deprecated in favour of memory_policy) if the class supports reference counting, the + :param decref_method: (deprecated in favour of memory_policy) if the class supports reference counting, the name of the method that decrements the reference count (may be inherited from parent if not given) - @param automatic_type_narrowing: if True, automatic return type + :param automatic_type_narrowing: if True, automatic return type narrowing will be done on objects of this class and its descendants when returned by pointer from a function or method. - @param allow_subclassing: if True, generated class wrappers will + :param allow_subclassing: if True, generated class wrappers will allow subclassing in Python. - @param is_singleton: if True, the class is considered a singleton, + :param is_singleton: if True, the class is considered a singleton, and so the python wrapper will never call the C++ class destructor to free the value. - @param peekref_method: (deprecated in favour of memory_policy) if the class supports reference counting, the + :param peekref_method: (deprecated in favour of memory_policy) if the class supports reference counting, the name of the method that returns the current reference count. - @param free_function: (deprecated in favour of memory_policy) name of C function used to deallocate class instances - @param incref_function: (deprecated in favour of memory_policy) same as incref_method, but as a function instead of method - @param decref_function: (deprecated in favour of memory_policy) same as decref_method, but as a function instead of method - @param python_name: name of the class as it will appear from + :param free_function: (deprecated in favour of memory_policy) name of C function used to deallocate class instances + :param incref_function: (deprecated in favour of memory_policy) same as incref_method, but as a function instead of method + :param decref_function: (deprecated in favour of memory_policy) same as decref_method, but as a function instead of method + :param python_name: name of the class as it will appear from Python side. This parameter is DEPRECATED in favour of custom_name. - @param memory_policy: memory management policy; if None, it + :param memory_policy: memory management policy; if None, it inherits from the parent class. Only root classes can have a memory policy defined. - @type memory_policy: L{MemoryPolicy} + :type memory_policy: L{MemoryPolicy} - @param foreign_cpp_namespace: if set, the class is assumed to + :param foreign_cpp_namespace: if set, the class is assumed to belong to the given C++ namespace, regardless of the C++ namespace of the python module it will be added to. For instance, this can be useful to wrap std classes, like std::ofstream, without having to create an extra python submodule. - @param docstring: None or a string containing the docstring + :param docstring: None or a string containing the docstring that will be generated for the class - @param custom_name: an alternative name to give to this class + :param custom_name: an alternative name to give to this class at python-side; if omitted, the name of the class in the python module will be the same name as the class in C++ (minus namespace). @@ -681,7 +681,7 @@ class CppClass(object): The binary operator is assumed to operate with both operands of the type of the class, either by reference or by value. - @param operator: string indicating the name of the operator to + :param operator: string indicating the name of the operator to support, e.g. '==' """ operator = utils.ascii(operator) @@ -696,13 +696,13 @@ class CppClass(object): """ Add support for a C++ binary numeric operator, such as +, -, *, or /. - @param operator: string indicating the name of the operator to + :param operator: string indicating the name of the operator to support, e.g. '==' - @param result_cppclass: the CppClass object of the result type, assumed to be this class if omitted - @param left_cppclass: the CppClass object of the left operand type, assumed to be this class if omitted + :param result_cppclass: the CppClass object of the result type, assumed to be this class if omitted + :param left_cppclass: the CppClass object of the left operand type, assumed to be this class if omitted - @param right: the type of the right parameter. Can be a + :param right: the type of the right parameter. Can be a CppClass, Parameter, or param spec. Assumed to be this class if omitted """ @@ -742,10 +742,10 @@ class CppClass(object): """ Add support for a C++ inplace numeric operator, such as +=, -=, *=, or /=. - @param operator: string indicating the name of the operator to + :param operator: string indicating the name of the operator to support, e.g. '+=' - @param right: the type of the right parameter. Can be a + :param right: the type of the right parameter. Can be a CppClass, Parameter, or param spec. Assumed to be this class if omitted """ @@ -775,11 +775,11 @@ class CppClass(object): """ Add support for a C++ unary numeric operators, currently only -. - @param operator: string indicating the name of the operator to + :param operator: string indicating the name of the operator to support, e.g. '-' - @param result_cppclass: the CppClass object of the result type, assumed to be this class if omitted - @param left_cppclass: the CppClass object of the left operand type, assumed to be this class if omitted + :param result_cppclass: the CppClass object of the result type, assumed to be this class if omitted + :param left_cppclass: the CppClass object of the left operand type, assumed to be this class if omitted """ operator = utils.ascii(operator) if not isinstance(operator, str): @@ -821,7 +821,7 @@ class CppClass(object): """ Get the method resolution order (MRO) of this class. - @return: an iterator that gives CppClass objects, from leaf to root class + :return: an iterator that gives CppClass objects, from leaf to root class """ cls = self while cls is not None: @@ -920,7 +920,7 @@ class CppClass(object): """Set a custom function to be called to create instances of this class and its subclasses. - @param instance_creation_function: instance creation function; see + :param instance_creation_function: instance creation function; see default_instance_creation_function() for signature and example. """ @@ -1206,7 +1206,7 @@ public: """ Add a method object to the class. For internal use. - @param method: a L{CppMethod} or L{Function} instance that can generate the method wrapper + :param method: a L{CppMethod} or L{Function} instance that can generate the method wrapper """ if isinstance(method, CppMethod): name = method.mangled_name @@ -1380,7 +1380,7 @@ public: """ Add a constructor to the class. - @param wrapper: a CppConstructor instance + :param wrapper: a CppConstructor instance """ assert isinstance(wrapper, CppConstructor) wrapper.set_class(self) @@ -1459,9 +1459,9 @@ public: def add_static_attribute(self, name, value_type, is_const=False): """ - @param value_type: a ReturnValue object - @param name: attribute name (i.e. the name of the class member variable) - @param is_const: True if the attribute is const, i.e. cannot be modified + :param value_type: a ReturnValue object + :param name: attribute name (i.e. the name of the class member variable) + :param is_const: True if the attribute is const, i.e. cannot be modified """ ## backward compatibility check @@ -1488,11 +1488,11 @@ public: def add_instance_attribute(self, name, value_type, is_const=False, getter=None, setter=None): """ - @param value_type: a ReturnValue object - @param name: attribute name (i.e. the name of the class member variable) - @param is_const: True if the attribute is const, i.e. cannot be modified - @param getter: None, or name of a method of this class used to get the value - @param setter: None, or name of a method of this class used to set the value + :param value_type: a ReturnValue object + :param name: attribute name (i.e. the name of the class member variable) + :param is_const: True if the attribute is const, i.e. cannot be modified + :param getter: None, or name of a method of this class used to get the value + :param setter: None, or name of a method of this class used to set the value """ ## backward compatibility check diff --git a/pybindgen/cppclass_container.py b/pybindgen/cppclass_container.py index 0c5d0b0..bb4fb95 100644 --- a/pybindgen/cppclass_container.py +++ b/pybindgen/cppclass_container.py @@ -67,9 +67,9 @@ class IterNextWrapper(ForwardWrapperBase): class CppClassContainerTraits(object): def __init__(self, cppclass, value_type, begin_method='begin', end_method='end', iterator_type='iterator', is_mapping=False): """ - @param cppclass: the L{CppClass} object that receives the container traits + :param cppclass: the L{CppClass} object that receives the container traits - @param value_type: a ReturnValue of the element type: note, + :param value_type: a ReturnValue of the element type: note, for mapping containers, value_type is a tuple with two ReturnValue's: (key, element). """ diff --git a/pybindgen/cppclass_typehandlers.py b/pybindgen/cppclass_typehandlers.py index 29e0ff6..ef78b2b 100644 --- a/pybindgen/cppclass_typehandlers.py +++ b/pybindgen/cppclass_typehandlers.py @@ -339,8 +339,8 @@ class CppClassRefParameter(CppClassParameterBase): def __init__(self, ctype, name, direction=Parameter.DIRECTION_IN, is_const=False, default_value=None, default_value_type=None): """ - @param ctype: C type, normally 'MyClass*' - @param name: parameter name + :param ctype: C type, normally 'MyClass*' + :param name: parameter name """ if ctype == self.cpp_class.name: ctype = self.cpp_class.full_name @@ -671,10 +671,10 @@ class CppClassPtrParameter(CppClassParameterBase): """ Type handler for a pointer-to-class parameter (MyClass*) - @param ctype: C type, normally 'MyClass*' - @param name: parameter name + :param ctype: C type, normally 'MyClass*' + :param name: parameter name - @param transfer_ownership: if True, the callee becomes + :param transfer_ownership: if True, the callee becomes responsible for freeing the object. If False, the caller remains responsible for the object. In either case, the original object pointer is passed, @@ -683,7 +683,7 @@ class CppClassPtrParameter(CppClassParameterBase): the call (calling any method will cause a null pointer dereference and crash the program). - @param custodian: if given, points to an object (custodian) + :param custodian: if given, points to an object (custodian) that keeps the python wrapper for the parameter alive. Possible values are: - None: no object is custodian; @@ -695,11 +695,11 @@ class CppClassPtrParameter(CppClassParameterBase): (i.e. not counting the self/this parameter), whose object will be used as custodian. - @param is_const: if true, the parameter has a const attached to the leftmost + :param is_const: if true, the parameter has a const attached to the leftmost - @param null_ok: if true, None is accepted and mapped into a C NULL pointer + :param null_ok: if true, None is accepted and mapped into a C NULL pointer - @param default_value: default parameter value (as C expression + :param default_value: default parameter value (as C expression string); probably, the only default value that makes sense here is probably 'NULL'. @@ -958,11 +958,11 @@ class CppClassPtrReturnValue(CppClassReturnValueBase): is_const=False, reference_existing_object=None, return_internal_reference=None): """ - @param ctype: C type, normally 'MyClass*' - @param caller_owns_return: if true, ownership of the object pointer + :param ctype: C type, normally 'MyClass*' + :param caller_owns_return: if true, ownership of the object pointer is transferred to the caller - @param custodian: bind the life cycle of the python wrapper + :param custodian: bind the life cycle of the python wrapper for the return value object (ward) to that of the object indicated by this parameter (custodian). Possible values are: @@ -974,7 +974,7 @@ class CppClassPtrReturnValue(CppClassReturnValueBase): (i.e. not counting the self/this parameter), whose object will be used as custodian. - @param reference_existing_object: if true, ownership of the + :param reference_existing_object: if true, ownership of the pointed-to object remains to be the caller's, but we do not make a copy. The callee gets a reference to the existing object, but is not responsible for @@ -985,7 +985,7 @@ class CppClassPtrReturnValue(CppClassReturnValueBase): mean time. Calling methods on such an object would lead to a memory error. - @param return_internal_reference: like + :param return_internal_reference: like reference_existing_object, but additionally adds custodian/ward to bind the lifetime of the 'self' object (instance the method is bound to) to the lifetime of the diff --git a/pybindgen/cppexception.py b/pybindgen/cppexception.py index ce79386..7554648 100644 --- a/pybindgen/cppexception.py +++ b/pybindgen/cppexception.py @@ -8,22 +8,22 @@ class CppException(object): def __init__(self, name, parent=None, outer_class=None, custom_name=None, foreign_cpp_namespace=None, message_rvalue=None): """ - @param name: exception class name - @param parent: optional parent class wrapper + :param name: exception class name + :param parent: optional parent class wrapper - @param custom_name: an alternative name to give to this exception class + :param custom_name: an alternative name to give to this exception class at python-side; if omitted, the name of the class in the python module will be the same name as the class in C++ (minus namespace). - @param foreign_cpp_namespace: if set, the class is assumed to + :param foreign_cpp_namespace: if set, the class is assumed to belong to the given C++ namespace, regardless of the C++ namespace of the python module it will be added to. For instance, this can be useful to wrap std classes, like std::ofstream, without having to create an extra python submodule. - @param message_rvalue: if not None, this parameter is a string + :param message_rvalue: if not None, this parameter is a string that contains an rvalue C expression that evaluates to the exception message. The Python % operator will be used to substitute %(EXC)s for the caught exception variable name. The diff --git a/pybindgen/cppmethod.py b/pybindgen/cppmethod.py index cd60c4f..64d9e10 100644 --- a/pybindgen/cppmethod.py +++ b/pybindgen/cppmethod.py @@ -29,48 +29,48 @@ class CppMethod(ForwardWrapperBase): """ Create an object the generates code to wrap a C++ class method. - @param return_value: the method return value - @type return_value: L{ReturnValue} + :param return_value: the method return value + :type return_value: L{ReturnValue} - @param method_name: name of the method + :param method_name: name of the method - @param parameters: the method parameters - @type parameters: list of L{Parameter} + :param parameters: the method parameters + :type parameters: list of L{Parameter} - @param is_static: whether it is a static method + :param is_static: whether it is a static method - @param template_parameters: optional list of template parameters needed to invoke the method - @type template_parameters: list of strings, each element a template parameter expression + :param template_parameters: optional list of template parameters needed to invoke the method + :type template_parameters: list of strings, each element a template parameter expression - @param is_virtual: whether the method is virtual (pure or not) + :param is_virtual: whether the method is virtual (pure or not) - @param is_const: whether the method has a const modifier on it + :param is_const: whether the method has a const modifier on it - @param unblock_threads: whether to release the Python GIL + :param unblock_threads: whether to release the Python GIL around the method call or not. If None or omitted, use global settings. Releasing the GIL has a small performance penalty, but is recommended if the method is expected to take considerable time to complete, because otherwise no other Python thread is allowed to run until the method completes. - @param is_pure_virtual: whether the method is defined as "pure + :param is_pure_virtual: whether the method is defined as "pure virtual", i.e. virtual method with no default implementation in the class being wrapped. - @param custom_name: alternate name to give to the method, in python side. + :param custom_name: alternate name to give to the method, in python side. - @param custom_template_method_name: (deprecated) same as parameter 'custom_name'. + :param custom_template_method_name: (deprecated) same as parameter 'custom_name'. - @param visibility: visibility of the method within the C++ class - @type visibility: a string (allowed values are 'public', 'protected', 'private') + :param visibility: visibility of the method within the C++ class + :type visibility: a string (allowed values are 'public', 'protected', 'private') - @param deprecated: deprecation state for this API: + :param deprecated: deprecation state for this API: - False: Not deprecated - True: Deprecated - "message": Deprecated, and deprecation warning contains the given message - @param throw: list of C++ exceptions that the function may throw - @type throw: list of L{CppException} + :param throw: list of C++ exceptions that the function may throw + :type throw: list of L{CppException} """ self.stack_where_defined = traceback.extract_stack() @@ -148,10 +148,10 @@ class CppMethod(ForwardWrapperBase): - C{0}: the instance of the method (self) - value > 0: the nth parameter of the function, starting at 1 - @parameter custodian: number of the object that assumes the role of custodian - @parameter ward: number of the object that assumes the role of ward + :parameter custodian: number of the object that assumes the role of custodian + :parameter ward: number of the object that assumes the role of ward - @parameter postcall: if True, the relationship is added after + :parameter postcall: if True, the relationship is added after the C function call, if False it is added before the call. If not given, the value False is assumed if the return value is not involved, else postcall=True is used. @@ -479,15 +479,15 @@ class CppConstructor(ForwardWrapperBase): def __init__(self, parameters, unblock_threads=None, visibility='public', deprecated=False, throw=()): """ - @param parameters: the constructor parameters + :param parameters: the constructor parameters - @param deprecated: deprecation state for this API: + :param deprecated: deprecation state for this API: - False: Not deprecated - True: Deprecated - "message": Deprecated, and deprecation warning contains the given message - @param throw: list of C++ exceptions that the constructor may throw - @type throw: list of L{CppException} + :param throw: list of C++ exceptions that the constructor may throw + :type throw: list of L{CppException} """ self.stack_where_defined = traceback.extract_stack() @@ -536,10 +536,10 @@ class CppConstructor(ForwardWrapperBase): - C{0}: the object being constructed (self) - value > 0: the nth parameter of the function, starting at 1 - @parameter custodian: number of the object that assumes the role of custodian - @parameter ward: number of the object that assumes the role of ward + :parameter custodian: number of the object that assumes the role of custodian + :parameter ward: number of the object that assumes the role of ward - @parameter postcall: if True, the relationship is added after + :parameter postcall: if True, the relationship is added after the C function call, if False it is added before the call. If not given, the value False is assumed if the return value is not involved, else postcall=True is used. @@ -690,15 +690,15 @@ class CppFunctionAsConstructor(CppConstructor): """ def __init__(self, c_function_name, return_value, parameters, unblock_threads=None): """ - @param c_function_name: name of the C/C++ function; FIXME: for now it is + :param c_function_name: name of the C/C++ function; FIXME: for now it is implied that this function returns a pointer to the a class instance with caller_owns_return=True semantics. - @param return_value: function return value type - @type return_value: L{ReturnValue} + :param return_value: function return value type + :type return_value: L{ReturnValue} - @param parameters: the function/constructor parameters - @type parameters: list of L{Parameter} + :param parameters: the function/constructor parameters + :type parameters: list of L{Parameter} """ self.stack_where_defined = traceback.extract_stack() @@ -754,8 +754,8 @@ class CppNoConstructor(ForwardWrapperBase): def generate(self, code_sink, class_): """ Generates the wrapper code - code_sink -- a CodeSink instance that will receive the generated code - class_ -- the c++ class wrapper the method belongs to + :param code_sink: a CodeSink instance that will receive the generated code + :param class_: the c++ class wrapper the method belongs to Returns the wrapper function name. """ diff --git a/pybindgen/enum.py b/pybindgen/enum.py index 816fd0f..bebbe82 100644 --- a/pybindgen/enum.py +++ b/pybindgen/enum.py @@ -14,10 +14,10 @@ class Enum(object): """ Creates a new enum wrapper, which should be added to a module with module.add_enum(). - @param name: C name of the enum type - @param values: a list of strings with all enumeration value names, or list of (name, C-value-expr) tuples. - @param values_prefix: prefix to add to value names, or None - @param cpp_namespace: optional C++ namespace identifier, or None. + :param name: C name of the enum type + :param values: a list of strings with all enumeration value names, or list of (name, C-value-expr) tuples. + :param values_prefix: prefix to add to value names, or None + :param cpp_namespace: optional C++ namespace identifier, or None. Note: this namespace is *in addition to* whatever namespace of the module the enum belongs to. Typically this parameter is to diff --git a/pybindgen/function.py b/pybindgen/function.py index 331a10a..09d9147 100644 --- a/pybindgen/function.py +++ b/pybindgen/function.py @@ -23,26 +23,26 @@ class Function(ForwardWrapperBase): template_parameters=(), custom_name=None, deprecated=False, foreign_cpp_namespace=None, throw=()): """ - @param function_name: name of the C function - @param return_value: the function return value + :param function_name: name of the C function + :param return_value: the function return value @type return_value: L{ReturnValue} - @param parameters: the function parameters + :param parameters: the function parameters @type parameters: list of L{Parameter} - @param custom_name: an alternative name to give to this + :param custom_name: an alternative name to give to this function at python-side; if omitted, the name of the function in the python module will be the same name as the function in C++ (minus namespace). - @param deprecated: deprecation state for this API: + :param deprecated: deprecation state for this API: - False: Not deprecated - True: Deprecated - "message": Deprecated, and deprecation warning contains the given message - @param foreign_cpp_namespace: if set, the function is assumed to + :param foreign_cpp_namespace: if set, the function is assumed to belong to the given C++ namespace, regardless of the C++ namespace of the python module it will be added to. - @param throw: list of C++ exceptions that the function may throw + :param throw: list of C++ exceptions that the function may throw @type throw: list of L{CppException} """ self.stack_where_defined = traceback.extract_stack() @@ -123,10 +123,10 @@ class Function(ForwardWrapperBase): - C{-1}: the return value of the function - value > 0: the nth parameter of the function, starting at 1 - @parameter custodian: number of the object that assumes the role of custodian - @parameter ward: number of the object that assumes the role of ward + :parameter custodian: number of the object that assumes the role of custodian + :parameter ward: number of the object that assumes the role of ward - @parameter postcall: if True, the relationship is added after + :parameter postcall: if True, the relationship is added after the C function call, if False it is added before the call. If not given, the value False is assumed if the return value is not involved, else postcall=True is used. @@ -251,7 +251,7 @@ class Function(ForwardWrapperBase): Returns an array element to use in a PyMethodDef table. Should only be called after code generation. - @param name: python function/method name + :param name: python function/method name """ flags = self.get_py_method_def_flags() assert isinstance(self.wrapper_return, basestring) diff --git a/pybindgen/gccxmlparser.py b/pybindgen/gccxmlparser.py index ec85b57..3e4737d 100644 --- a/pybindgen/gccxmlparser.py +++ b/pybindgen/gccxmlparser.py @@ -186,7 +186,7 @@ def _pygen_param(args, kwargs): class GccXmlTypeRegistry(object): def __init__(self, root_module): """ - @param root_module: the root L{Module} object + :param root_module: the root L{Module} object """ assert isinstance(root_module, Module) assert root_module.parent is None @@ -322,7 +322,7 @@ class AnnotationsScanner(object): def get_annotations(self, decl): """ - @param decl: pygccxml declaration_t object + :param decl: pygccxml declaration_t object """ assert isinstance(decl, declaration_t) @@ -413,23 +413,23 @@ class PygenSection(object): "Class to hold information about a python generation section" def __init__(self, name, code_sink, local_customizations_module=None): """ - @param name: section name; this name should be a valid python + :param name: section name; this name should be a valid python module name; the special name '__main__' is used to denote the main section, which comprises the main script itself - @type name: str + :type name: str - @param code_sink: code sink that will receive the generated + :param code_sink: code sink that will receive the generated code for the section. Normally the code sink should write to a file with the name of the section and a .py extension, to allow importing it as module. - @type code_sink: L{CodeSink} + :type code_sink: L{CodeSink} - @param local_customizations_module: name of the python module + :param local_customizations_module: name of the python module that may contain local customizations for the section, or None. If not None, PyBindGen will generate code that tries to import that module in the respective section and call functions on it, or ignore it if the module does not exist. - @type local_customizations_module: str + :type local_customizations_module: str """ assert isinstance(name, str) self.name = name @@ -446,8 +446,8 @@ class PygenClassifier(object): subclasses. It will be called by PyBindGen for every API definition, and should return a section name. - @param pygccxml_definition: gccxml definition object - @returns: section name + :param pygccxml_definition: gccxml definition object + :returns: section name """ raise NotImplementedError @@ -459,9 +459,10 @@ class PygenClassifier(object): This is used when sections reflect 'modules' whose types must be registered in a certain order. - @param section_name: the name of the section @returns: order - of precedence of the section. The lower the number, the - sooner the section is to be registered. + :param section_name: the name of the section + + :returns: order of precedence of the section. The lower the + number, the sooner the section is to be registered. """ raise NotImplementedError @@ -479,8 +480,8 @@ class ModuleParser(object): Creates an object that will be able parse header files and create a pybindgen module definition. - @param module_name: name of the Python module - @param module_namespace_name: optional C++ namespace name; if + :param module_name: name of the Python module + :param module_namespace_name: optional C++ namespace name; if given, only definitions of this namespace will be included in the python module @@ -599,22 +600,22 @@ class ModuleParser(object): 2. scan_functions() 3. parse_finalize() - @param header_files: header files to parse - @type header_files: list of string + :param header_files: header files to parse + :type header_files: list of string - @param include_paths: (deprecated, use the parameter gccxml_options) list of include paths - @type include_paths: list of string + :param include_paths: (deprecated, use the parameter gccxml_options) list of include paths + :type include_paths: list of string - @param whitelist_paths: additional directories for definitions to be included + :param whitelist_paths: additional directories for definitions to be included Normally the module parser filters out API definitions that have been defined outside one of the header files indicated for parsing. The parameter whitelist_paths instructs the module parser to accept definitions defined in another header file if such header file is inside one of the directories listed by whitelist_paths. - @type whitelist_paths: list of string + :type whitelist_paths: list of string - @param pygen_sink: code sink for python script generation. + :param pygen_sink: code sink for python script generation. This parameter activates a mode wherein ModuleParser, in addition to building in memory API definitions, creates a @@ -628,17 +629,17 @@ class ModuleParser(object): 2. A list of L{PygenSection} objects. This option requires the pygen_classifier to be given. - @type pygen_sink: L{CodeSink} or list of L{PygenSection} objects + :type pygen_sink: L{CodeSink} or list of L{PygenSection} objects - @param pygen_classifier: the classifier to use when pygen is given and is a dict + :param pygen_classifier: the classifier to use when pygen is given and is a dict - @param gccxml_options: extra options to pass into + :param gccxml_options: extra options to pass into the gccxml_configuration_t object as keyword arguments (see U{pygccxml API documentation} for more information). - @type gccxml_options: dict + :type gccxml_options: dict """ assert isinstance(header_files, list) diff --git a/pybindgen/module.py b/pybindgen/module.py index 64df487..2150ae0 100644 --- a/pybindgen/module.py +++ b/pybindgen/module.py @@ -82,8 +82,9 @@ class MultiSectionFactory(object): def get_section_code_sink(self, section_name): """ Create and/or return a code sink for a given section. - @param section_name: name of the section - @returns: a L{CodeSink} object that will receive generated code belonging to the section C{section_name} + + :param section_name: name of the section + :return: a L{CodeSink} object that will receive generated code belonging to the section C{section_name} """ raise NotImplementedError def get_main_code_sink(self): @@ -100,7 +101,7 @@ class MultiSectionFactory(object): """ Return the argument for an #include directive to include the common header. - @returns: a string with the header name, including surrounding + :returns: a string with the header name, including surrounding "" or <>. For example, '"foomodule.h"'. """ raise NotImplementedError @@ -113,8 +114,8 @@ class _SinkManager(object): """ def get_code_sink_for_wrapper(self, wrapper): """ - @param wrapper: wrapper object - @returns: (body_code_sink, header_code_sink) + :param wrapper: wrapper object + :returns: (body_code_sink, header_code_sink) """ raise NotImplementedError def get_includes_code_sink(self): @@ -208,11 +209,12 @@ class ModuleBase(dict): def __init__(self, name, parent=None, docstring=None, cpp_namespace=None): """ Note: this is an abstract base class, see L{Module} - @param name: module name - @param parent: parent L{module} (i.e. the one that contains this submodule) or None if this is a root module - @param docstring: docstring to use for this module - @param cpp_namespace: C++ namespace prefix associated with this module - @return: a new module object + + :param name: module name + :param parent: parent L{module} (i.e. the one that contains this submodule) or None if this is a root module + :param docstring: docstring to use for this module + :param cpp_namespace: C++ namespace prefix associated with this module + :return: a new module object """ super(ModuleBase, self).__init__() self.parent = parent @@ -290,7 +292,7 @@ class ModuleBase(dict): Declare the end of a section, i.e. further types and functions will belong to the main module. - @param section_name: name of section; must match the one in + :param section_name: name of section; must match the one in the previous L{begin_section} call. """ assert self.parent is None @@ -323,7 +325,7 @@ class ModuleBase(dict): raise ValueError("submodule %s not found" % submodule_name) def get_root(self): - "@return: the root L{Module} (even if it is self)" + ":return: the root L{Module} (even if it is self)" root = self while root.parent is not None: root = root.parent @@ -356,7 +358,7 @@ class ModuleBase(dict): """ Adds an additional include directive, needed to compile this python module - @param include: the name of the header file to include, including + :param include: the name of the header file to include, including surrounding "" or <>. """ include = utils.ascii(include) @@ -423,9 +425,9 @@ class ModuleBase(dict): the future. Normally should not be called by the programmer, as it is meant for internal pybindgen use and called automatically. - @param name: type name without any C++ namespace prefix, or None - @param full_name: type name with a C++ namespace prefix, or None - @param type_wrapper: the wrapper object for the type (e.g. L{CppClass} or L{Enum}) + :param name: type name without any C++ namespace prefix, or None + :param full_name: type name with a C++ namespace prefix, or None + :param type_wrapper: the wrapper object for the type (e.g. L{CppClass} or L{Enum}) """ module = self if name: @@ -439,7 +441,7 @@ class ModuleBase(dict): """ Add a class to the module. - @param class_: a CppClass object + :param class_: a CppClass object """ assert isinstance(class_, CppClass) class_.module = self @@ -509,11 +511,11 @@ class ModuleBase(dict): namespace. If the requested namespace was already added, the existing module is returned instead of creating a new one. - @param name: name of C++ namespace (just the last component, + :param name: name of C++ namespace (just the last component, not full scoped name); this also becomes the name of the submodule. - @return: a L{SubModule} object that maps to this namespace. + :return: a L{SubModule} object that maps to this namespace. """ name = utils.ascii(name) try: @@ -553,7 +555,7 @@ class ModuleBase(dict): """ Add a container to the module. - @param container: a L{Container} object + :param container: a L{Container} object """ assert isinstance(container, Container) container.module = self @@ -598,7 +600,7 @@ class ModuleBase(dict): (note: assuming here one-to-one mapping between 'module' and 'compilation unit'). - @param definition_name: a string that uniquely identifies the code + :param definition_name: a string that uniquely identifies the code definition that will be added. If the given definition was already declared KeyError is raised. @@ -826,8 +828,8 @@ __attribute__ ((visibility("default"))) Declares an equivalent to a typedef in C:: typedef Foo Bar; - @param wrapper: the wrapper object to alias (Foo in the example) - @param alias: name of the typedef alias + :param wrapper: the wrapper object to alias (Foo in the example) + :param alias: name of the typedef alias @note: only typedefs for CppClass objects have been implemented so far; others will be implemented in the future. @@ -844,17 +846,18 @@ __attribute__ ((visibility("default"))) class Module(ModuleBase): def __init__(self, name, docstring=None, cpp_namespace=None): """ - @param name: module name - @param docstring: docstring to use for this module - @param cpp_namespace: C++ namespace prefix associated with this module + :param name: module name + :param docstring: docstring to use for this module + :param cpp_namespace: C++ namespace prefix associated with this module """ super(Module, self).__init__(name, docstring=docstring, cpp_namespace=cpp_namespace) def generate(self, out, module_file_base_name=None): """Generates the module - @type out: a file object, L{FileCodeSink}, or L{MultiSectionFactory} - @param module_file_base_name: base name of the module file. + :type out: a file object, L{FileCodeSink}, or L{MultiSectionFactory} + + :param module_file_base_name: base name of the module file. This is useful when we want to produce a _foo module that will be imported into a foo module, to avoid making all types docstrings contain _foo.Xpto instead of foo.Xpto. @@ -890,9 +893,9 @@ class Module(ModuleBase): Use: this method is to be considered pybindgen internal, used by code generation modules. - @type value_type: L{ReturnValue} - @type code_sink: L{CodeSink} - @returns: name of the converter function + :type value_type: L{ReturnValue} + :type code_sink: L{CodeSink} + :returns: name of the converter function """ assert isinstance(value_type, TypeHandler) converter_function_name = self.get_python_to_c_type_converter_function_name(value_type) @@ -929,9 +932,9 @@ class Module(ModuleBase): Use: this method is to be considered pybindgen internal, used by code generation modules. - @type value_type: L{ReturnValue} - @type code_sink: L{CodeSink} - @returns: name of the converter function + :type value_type: L{ReturnValue} + :type code_sink: L{CodeSink} + :returns: name of the converter function """ assert isinstance(value_type, TypeHandler) converter_function_name = self.get_c_to_python_type_converter_function_name(value_type) @@ -951,10 +954,10 @@ class Module(ModuleBase): class SubModule(ModuleBase): def __init__(self, name, parent, docstring=None, cpp_namespace=None): """ - @param parent: parent L{module} (i.e. the one that contains this submodule) - @param name: name of the submodule - @param docstring: docstring to use for this module - @param cpp_namespace: C++ namespace component associated with this module + :param parent: parent L{module} (i.e. the one that contains this submodule) + :param name: name of the submodule + :param docstring: docstring to use for this module + :param cpp_namespace: C++ namespace component associated with this module """ super(SubModule, self).__init__(name, parent, docstring=docstring, cpp_namespace=cpp_namespace) diff --git a/pybindgen/typehandlers/base.py b/pybindgen/typehandlers/base.py index ea70c42..4d15b59 100644 --- a/pybindgen/typehandlers/base.py +++ b/pybindgen/typehandlers/base.py @@ -128,11 +128,11 @@ class CodeBlock(object): clean3(); clean1(); - @param error_return: code that is generated on error conditions + :param error_return: code that is generated on error conditions (detected by write_error_check()); normally it returns from the wrapper function, e.g. return NULL; - @param predecessor: optional predecessor code block; a + :param predecessor: optional predecessor code block; a predecessor is used to search for additional cleanup actions. ''' @@ -204,9 +204,9 @@ class CodeBlock(object): def write_error_check(self, failure_expression, failure_cleanup=None): '''Add a chunk of code that checks for a possible error - @param failure_expression: C boolean expression that is true when + :param failure_expression: C boolean expression that is true when an error occurred - @param failure_cleanup: optional extra cleanup code to write only + :param failure_cleanup: optional extra cleanup code to write only for the the case when failure_expression is true; this extra cleanup code comes before all other cleanup code previously registered. @@ -273,12 +273,12 @@ class ParseTupleParameters(object): """ Adds a new parameter specification - @param param_template: template item, see documentation for + :param param_template: template item, see documentation for PyArg_ParseTuple for more information - @param param_values: list of parameters, see documentation + :param param_values: list of parameters, see documentation for PyArg_ParseTuple for more information - @param prepend: whether this parameter should be parsed first - @param optional: whether the parameter is optional; note that after + :param prepend: whether this parameter should be parsed first + :param optional: whether the parameter is optional; note that after the first optional parameter, all remaining parameters must also be optional """ @@ -365,12 +365,12 @@ class BuildValueParameters(object): """ Adds a new parameter to the Py_BuildValue (or similar) statement. - @param param_template: template item, see documentation for + :param param_template: template item, see documentation for Py_BuildValue for more information - @param param_values: list of C expressions to use as value, see documentation + :param param_values: list of C expressions to use as value, see documentation for Py_BuildValue for more information - @param prepend: whether this parameter should come first in the tuple being built - @param cancels_cleanup: optional handle to a cleanup action, + :param prepend: whether this parameter should come first in the tuple being built + :param cancels_cleanup: optional handle to a cleanup action, that is removed after the call. Typically this is used for 'N' parameters, which already consume an object reference @@ -386,7 +386,7 @@ class BuildValueParameters(object): Py_BuildValue-style function call, the first paramter in the list being the template string. - @param force_tuple_creation: if True, Py_BuildValue is + :param force_tuple_creation: if True, Py_BuildValue is instructed to always create a tuple, even for zero or 1 values. """ @@ -433,7 +433,7 @@ class DeclarationsScope(object): int foo3 = 1; const char *kwargs[] = {"hello", NULL}; - @param parent_scope: optional 'parent scope'; if given, + :param parent_scope: optional 'parent scope'; if given, declarations in this scope will avoid clashing with names in the parent scope, and vice versa. @@ -453,11 +453,12 @@ class DeclarationsScope(object): def declare_variable(self, type_, name, initializer=None, array=None): """Add code to declare a variable. Returns the actual variable name used (uses 'name' as base, with a number in case of conflict.) - @param type_: C type name of the variable - @param name: base name of the variable; actual name used can be + + :param type_: C type name of the variable + :param name: base name of the variable; actual name used can be slightly different in case of name conflict. - @param initializer: optional, value to initialize the variable with - @param array: optional, array size specifiction, e.g. '[]', or '[100]' + :param initializer: optional, value to initialize the variable with + :param array: optional, array size specifiction, e.g. '[]', or '[100]' """ try: num = self.declared_variables[name] @@ -479,7 +480,8 @@ class DeclarationsScope(object): def reserve_variable(self, name): """Reserve a variable name, to be used later. - @param name: base name of the variable; actual name used can be + + :param name: base name of the variable; actual name used can be slightly different in case of name conflict. """ try: @@ -538,8 +540,8 @@ class ReverseWrapperBase(object): ''' Base constructor - @param return_value: type handler for the return value - @param parameters: a list of type handlers for the parameters + :param return_value: type handler for the return value + :param parameters: a list of type handlers for the parameters ''' @@ -595,9 +597,10 @@ class ReverseWrapperBase(object): def generate(self, code_sink, wrapper_name, decl_modifiers=('static',), decl_post_modifiers=()): """Generate the wrapper - @param code_sink: a CodeSink object that will receive the code - @param wrapper_name: C/C++ identifier of the function/method to generate - @param decl_modifiers: list of C/C++ declaration modifiers, e.g. 'static' + + :param code_sink: a CodeSink object that will receive the code + :param wrapper_name: C/C++ identifier of the function/method to generate + :param decl_modifiers: list of C/C++ declaration modifiers, e.g. 'static' """ assert isinstance(decl_modifiers, (list, tuple)) assert all([isinstance(mod, str) for mod in decl_modifiers]) @@ -729,13 +732,13 @@ class ForwardWrapperBase(object): ''' Base constructor - @param return_value: type handler for the return value - @param parameters: a list of type handlers for the parameters - @param parse_error_return: statement to return an error during parameter parsing - @param error_return: statement to return an error after parameter parsing - @param force_parse: force generation of code to parse parameters even if there are none - @param no_c_retval: force the wrapper to not have a C return value - @param unblock_threads: generate code to unblock python threads during the C function call + :param return_value: type handler for the return value + :param parameters: a list of type handlers for the parameters + :param parse_error_return: statement to return an error during parameter parsing + :param error_return: statement to return an error after parameter parsing + :param force_parse: force generation of code to parse parameters even if there are none + :param no_c_retval: force the wrapper to not have a C return value + :param unblock_threads: generate code to unblock python threads during the C function call ''' assert isinstance(return_value, ReturnValue) or return_value is None assert isinstance(parameters, list) @@ -991,9 +994,9 @@ class TypeTransformation(object): """ Given a type_handler class, create an instance with proper customization. - @param type_handler_class: type handler class - @param args: arguments - @param kwargs: keywords arguments + :param type_handler_class: type handler class + :param args: arguments + :param kwargs: keywords arguments """ raise NotImplementedError @@ -1147,7 +1150,7 @@ class ReturnValue(TypeHandler): Keywork Arguments: - @param ctype: actual C/C++ type being used + :param ctype: actual C/C++ type being used ''' if type(self) is ReturnValue: raise TypeError('ReturnValue is an abstract class; use ReturnValue.new(...)') @@ -1258,9 +1261,9 @@ class Parameter(TypeHandler): Keywork Arguments: - @param ctype: actual C/C++ type being used - @param name: parameter name - @param direction: direction of the parameter transfer, valid values + :param ctype: actual C/C++ type being used + :param name: parameter name + :param direction: direction of the parameter transfer, valid values are DIRECTION_IN, DIRECTION_OUT, and DIRECTION_IN|DIRECTION_OUT ''' @@ -1322,8 +1325,8 @@ class TypeMatcher(object): def register(self, name, type_handler): """Register a new handler class for a given C type - @param name: C type name - @param type_handler: class to handle this C type + :param name: C type name + :param type_handler: class to handle this C type """ name = ctypeparser.normalize_type_string(name) if name in self._types: @@ -1361,10 +1364,10 @@ class TypeMatcher(object): """ lookup(name) -> type_handler, type_transformation, type_traits - Returns a handler with the given ctype name, or raises KeyError. + :param name: C type name, possibly transformed (e.g. MySmartPointer looks up Foo*) + :returns: a handler with the given ctype name, or raises KeyError. Supports type transformations. - @param name: C type name, possibly transformed (e.g. MySmartPointer looks up Foo*) """ logger.debug("TypeMatcher.lookup(%r)", name) given_type_traits = ctypeparser.TypeTraits(name) diff --git a/pybindgen/typehandlers/ctypeparser/__init__.py b/pybindgen/typehandlers/ctypeparser/__init__.py index 3b9926f..7cb5e08 100644 --- a/pybindgen/typehandlers/ctypeparser/__init__.py +++ b/pybindgen/typehandlers/ctypeparser/__init__.py @@ -161,8 +161,8 @@ def parse_type(type_string): """ Parse a C type string. - @param type_string: C type expression - @returns: a L{CType} object representing the type + :param type_string: C type expression + :returns: a L{CType} object representing the type """ tokens = list(tokenizer.GetTokens(type_string + '\n')) ctype, last_token = _parse_type_recursive(tokens) @@ -176,8 +176,8 @@ def normalize_type_string(type_string): strings match regardless of small variations of representation that do not change the meaning. - @param type_string: C type expression - @returns: another string representing the same C type but in a canonical format + :param type_string: C type expression + :returns: another string representing the same C type but in a canonical format >>> normalize_type_string('char *') 'char *' diff --git a/pybindgen/typehandlers/ctypeparser/tokenizer.py b/pybindgen/typehandlers/ctypeparser/tokenizer.py index 3d5a431..4f98be4 100644 --- a/pybindgen/typehandlers/ctypeparser/tokenizer.py +++ b/pybindgen/typehandlers/ctypeparser/tokenizer.py @@ -117,8 +117,8 @@ def GetTokens(source): """ Returns a sequence of Tokens. - @param source: string of C++ source code. - @returns: an iterator that yields the L{Token}s in the source. + :param source: string of C++ source code. + :returns: an iterator that yields the L{Token}s in the source. """ # Cache various valid character sets for speed. valid_identifier_chars = VALID_IDENTIFIER_CHARS diff --git a/pybindgen/typehandlers/pyobjecttype.py b/pybindgen/typehandlers/pyobjecttype.py index 1ed9a43..a0651a6 100644 --- a/pybindgen/typehandlers/pyobjecttype.py +++ b/pybindgen/typehandlers/pyobjecttype.py @@ -12,9 +12,9 @@ class PyObjectParam(Parameter): def __init__(self, ctype, name, transfer_ownership, is_const=False): """ - @param ctype: C type, normally 'PyObject*' - @param name: parameter name - @param transfer_ownership: this parameter transfer the ownership of + :param ctype: C type, normally 'PyObject*' + :param name: parameter name + :param transfer_ownership: this parameter transfer the ownership of the pointed-to object to the called function """ @@ -44,8 +44,8 @@ class PyObjectReturnValue(ReturnValue): def __init__(self, ctype, caller_owns_return, is_const=False): """ - @param ctype: C type, normally 'MyClass*' - @param caller_owns_return: if true, ownership of the object pointer + :param ctype: C type, normally 'MyClass*' + :param caller_owns_return: if true, ownership of the object pointer is transferred to the caller """ super(PyObjectReturnValue, self).__init__(ctype, is_const)