[pygccxml-commit] source/pyplusplus/experimental pypp_api.py,1.1,1.2
Brought to you by:
mbaas,
roman_yakovenko
From: Allen B. <al...@us...> - 2006-03-05 00:50:58
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19921 Modified Files: pypp_api.py Log Message: Started to refactor. - New documentation format - Try to call new pyplusplus API - Stills needs a *lot* of work. I can't figure out how to get the new decl wrapper interface. Index: pypp_api.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/pypp_api.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** pypp_api.py 4 Mar 2006 15:48:12 -0000 1.1 --- pypp_api.py 5 Mar 2006 00:50:54 -0000 1.2 *************** *** 1,5 **** ! #!/bin/python ! # import os, os.path, re from pygccxml import parser from pygccxml import declarations --- 1,35 ---- ! # Copyright 2004 Roman Yakovenko. ! # Distributed under the Boost Software License, Version 1.0. (See ! # accompanying file LICENSE_1_0.txt or copy at ! # http://www.boost.org/LICENSE_1_0.txt) ! ! __docformat__ = "restructuredtext en" ! __doc__ = """ ! pypp api ! ======== ! ! This module provides a simplified high-level API for using ! pygccxml and pyplusplus. It is currently under heavy construction. ! ! Quickstart Usage ! ---------------- ! ! Add quickstart here ! ! Detailed Usage ! -------------- ! ! Add detailed usage here. ! ! :todo: Add quickstart and detailed documentation for API. ! :author: Allen Bierbaum ! :author: Matthias Baas ! :license: Boost Software License, Version 1.0 (see http://www.boost.org/LICENSE_1_0.txt) ! :copyright: 2006 Allen Bierbaum, Matthias Baas ! """ ! import os, os.path, re + + # Bring in everything I need from pyplusplus and pygccxml from pygccxml import parser from pygccxml import declarations *************** *** 9,25 **** from pyplusplus import module_creator from pyplusplus import file_writers # Bring in call policies to use ! from pyplusplus.code_creators import return_self ! from pyplusplus.code_creators import return_internal_reference ! from pyplusplus.code_creators import with_custodian_and_ward ! from pyplusplus.code_creators import copy_const_reference ! from pyplusplus.code_creators import copy_non_const_reference ! from pyplusplus.code_creators import manage_new_object ! from pyplusplus.code_creators import reference_existing_object ! from pyplusplus.code_creators import return_by_value ! from pyplusplus.code_creators import return_opaque_pointer ! from pyplusplus.code_creators import return_value_policy ! def cleanTemplateName(templateName): --- 39,55 ---- from pyplusplus import module_creator from pyplusplus import file_writers + from pyplusplus import decl_wrappers # Bring in call policies to use ! from pyplusplus.decl_wrappers import return_self ! from pyplusplus.decl_wrappers import return_internal_reference ! from pyplusplus.decl_wrappers import with_custodian_and_ward ! from pyplusplus.decl_wrappers import copy_const_reference ! from pyplusplus.decl_wrappers import copy_non_const_reference ! from pyplusplus.decl_wrappers import manage_new_object ! from pyplusplus.decl_wrappers import reference_existing_object ! from pyplusplus.decl_wrappers import return_by_value ! from pyplusplus.decl_wrappers import return_opaque_pointer ! from pyplusplus.decl_wrappers import return_value_policy def cleanTemplateName(templateName): *************** *** 34,39 **** By default all declarations are ignored. ! Todo: ! - ??? """ def __init__(self, headerFiles, workingDir=None, --- 64,69 ---- By default all declarations are ignored. ! :todo: Fix the parsing to work with recent changes ! """ def __init__(self, headerFiles, workingDir=None, *************** *** 41,51 **** defines=[], undefines=[], cacheFile = None, verbose=True): ! """ Initialize module. ! workingDir - directory to start processing. (default: current working dir) ! includePaths - List of paths to tell gccxml to search for header files. ! gccxmlPath - path to gccxml. If not set then attempt to find it in system path. ! (un)defines - set of symbols to add as (un)defined when compiling. ! cacheFile - name of file to use for caching parse data for this module. ! verbose - If true output status and command information as building the module. """ if not isinstance(headerFiles, list): --- 71,83 ---- defines=[], undefines=[], cacheFile = None, verbose=True): ! """ ! Initialize module. ! :Parameters: ! - 'workingDir': directory to start processing. (default: current working dir) ! - 'includePaths': List of paths to tell gccxml to search for header files. ! - 'gccxmlPath': path to gccxml. If not set then attempt to find it in system path. ! - '(un)defines': set of symbols to add as (un)defined when compiling. ! - 'cacheFile': name of file to use for caching parse data for this module. ! - 'verbose': if true output status and command information as building the module. """ if not isinstance(headerFiles, list): *************** *** 79,84 **** This method can be called anytime after initialization and all Template() calls have been made. ! @post: This class can act as a wrapper for namespace("::") ! and all declarations are set to be ignored. """ if self.mVerbose: --- 111,116 ---- This method can be called anytime after initialization and all Template() calls have been made. ! ! :postcondition: This class can act as a wrapper for namespace("::") and all declarations are set to be ignored. """ if self.mVerbose: *************** *** 107,111 **** the_parser = parser.project_reader_t(config=parser_cfg, ! cache=self.mCacheFile) parsed_decls = the_parser.read_files(full_header_list, parser.project_reader.COMPILATION_MODE.FILE_BY_FILE) --- 139,144 ---- the_parser = parser.project_reader_t(config=parser_cfg, ! cache=self.mCacheFile, ! decl_factory=decl_wrappers.dwfactory_t()) parsed_decls = the_parser.read_files(full_header_list, parser.project_reader.COMPILATION_MODE.FILE_BY_FILE) *************** *** 203,211 **** """ Create the module and write it out. Automatically calls createCreators() and filterExposed() if needed. ! moduleName - The name of the module being created. ! filename - The file or directory to create the code. ! useScope - If true the creators all use scope in their code. ! multiFile - If true use the multifile writer. ! multiCreateMain - If true and using multifile then create main reg method. """ if not self.mExtModule: --- 236,244 ---- """ Create the module and write it out. Automatically calls createCreators() and filterExposed() if needed. ! :arg moduleName: The name of the module being created. ! :arg filename: The file or directory to create the code. ! :arg useScope: If true the creators all use scope in their code. ! :arg multiFile: If true use the multifile writer. ! :arg multiCreateMain: If true and using multifile then create main reg method. """ if not self.mExtModule: *************** *** 233,240 **** def Template(self, templateType, typedefName=None): """ Add a template to instantiate. ! templateType - Fully instantiated name. (ex: TemplateClass<float> ) ! typedefName - Name of type def to define to this template type. ! This name can then be used later to look up the real fully ! expanded template type from the typedef map. (see self.mTypeDefMap) """ if not typedefName: --- 266,273 ---- def Template(self, templateType, typedefName=None): """ Add a template to instantiate. ! :param templateType: Fully instantiated name. (ex: TemplateClass<float> ) ! :param typedefName: Name of type def to define to this template type. ! This name can then be used later to look up the real fully ! expanded template type from the typedef map. (see self.mTypeDefMap) """ if not typedefName: *************** *** 312,322 **** class DeclWrapper: """ Class to wrap a single declaration. ! This is the core class for all API exposing. ! Instances of this class are normally created by calling ! one of the creation methods (Namespace, Class, Method, Var, Enum) ! on an existing wrapper or on a module. ! TODO: ! - ??? """ def __init__(self, decl): --- 345,354 ---- class DeclWrapper: """ Class to wrap a single declaration. ! This is the core class for all API exposing. ! Instances of this class are normally created by calling ! one of the creation methods (Namespace, Class, Method, Var, Enum) ! on an existing wrapper or on a module. ! :todo: Rewrite methods to use new wrappers. """ def __init__(self, decl): *************** *** 413,417 **** def setCallPolicy(self, callPolicy): """ Set the callpolicy of the contained method. ! callPolicy - Callpolicy object to use (must be of type code_creators.call_policy_t) """ assert isinstance(callPolicy, code_creators.call_policy_t) --- 445,449 ---- def setCallPolicy(self, callPolicy): """ Set the callpolicy of the contained method. ! :arg callPolicy: Callpolicy object to use (must be of type code_creators.call_policy_t) """ assert isinstance(callPolicy, code_creators.call_policy_t) *************** *** 434,438 **** """ Manually wrap method. Example: setWrapper("method", "ns::new_method") ! @post: ignores any old methods of methodName and defines new method """ self.Method(methodName).ignore() --- 466,470 ---- """ Manually wrap method. Example: setWrapper("method", "ns::new_method") ! :postcondition: ignores any old methods of methodName and defines new method """ self.Method(methodName).ignore() *************** *** 488,499 **** # --------- Internal helpers --------- # def findContainedDecls(self, name=None, declType=None): ! """ Search contained declarations for ones of specific type and or name. ! name: regex to use for matching. (can just be full name) ! Note: To make it more predictable matching we automatically add ! a '$' to the end of the regex to match the end of the name. ! This helps to prevent names with similar prefix's from matching. ! If you need this ability you can still get it by adding '.*' ! declType: a single type or a list of decl types to look for. ! Returns None if not found. Returns 1 or a list if found. """ found = [] --- 520,532 ---- # --------- Internal helpers --------- # def findContainedDecls(self, name=None, declType=None): ! """ ! Search contained declarations for ones of specific type and or name. ! :param name: regex to use for matching. (can just be full name) ! :param declType: a single type or a list of decl types to look for. ! :return: None if not found. Returns 1 or a list if found. ! :note: To make name lookup more predictable matching we automatically add ! a '$' to the end of the regex to match the end of the name. ! This helps to prevent names with similar prefix's from matching. ! If you need this ability you can still get it by adding '.*' """ found = [] *************** *** 511,516 **** def findContained(self, name=None, declType=None): """ Return a new DeclWrapper or MultiDeclWrapper for matching decls. ! name - If set this regex is used. ! declType - If set restrict search to decls based on the given type. """ found = self.findContainedDecls(name, declType) --- 544,549 ---- def findContained(self, name=None, declType=None): """ Return a new DeclWrapper or MultiDeclWrapper for matching decls. ! :arg name: If set this regex is used. ! :arg declType: If set restrict search to decls based on the given type. """ found = self.findContainedDecls(name, declType) *************** *** 789,791 **** curr_level = self.level + 1 print ' ' * curr_level * self.INDENT_SIZE, 'type: %s value: %s'%(self.__inst.type.decl_string, self.__inst.value) ! \ No newline at end of file --- 822,824 ---- curr_level = self.level + 1 print ' ' * curr_level * self.INDENT_SIZE, 'type: %s value: %s'%(self.__inst.type.decl_string, self.__inst.value) ! |