ctypes-commit Mailing List for ctypes (Page 67)
Brought to you by:
theller
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(90) |
Jun
(143) |
Jul
(106) |
Aug
(94) |
Sep
(84) |
Oct
(163) |
Nov
(60) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(128) |
Feb
(79) |
Mar
(227) |
Apr
(192) |
May
(179) |
Jun
(41) |
Jul
(53) |
Aug
(103) |
Sep
(28) |
Oct
(38) |
Nov
(81) |
Dec
(17) |
2006 |
Jan
(184) |
Feb
(111) |
Mar
(188) |
Apr
(67) |
May
(58) |
Jun
(123) |
Jul
(73) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Thomas H. <th...@us...> - 2005-03-18 09:38:36
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32495 Added Files: test_posix.py Log Message: tests for posix --- NEW FILE: test_posix.py --- import unittest, os, sys from ctypes import * if os.name == "posix" and sys.platform != "darwin": # On platforms where the default shared library suffix is '.so', # at least some libraries can be loaded as attributes of the cdll # object, since ctypes now tries loading the lib again # with '.so' appended of the first try fails. # # Won't work for libc, unfortunately. OTOH, it isn't # needed for libc since this is already mapped into the current # process (?) # # On MAC OSX, it won't work either, because dlopen() needs a full path, # and the default suffix is either none or '.dylib'. class LoadLibs(unittest.TestCase): def test_libm(self): import math libm = cdll.libm sqrt = libm.sqrt sqrt.argtypes = (c_double,) sqrt.restype = c_double self.failUnlessEqual(sqrt(2), math.sqrt(2)) if __name__ == "__main__": unittest.main() |
From: Thomas H. <th...@us...> - 2005-03-17 20:45:19
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25475 Modified Files: __init__.py Log Message: On platforms where dlopen is used, if dlopen fails and the name doesn't end with '.so', try again with '.so' appended to the filename. This allows to use the attribute access to load libraries in some cases. Suggested by Matti Jagula - thanks. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** __init__.py 17 Mar 2005 19:54:55 -0000 1.58 --- __init__.py 17 Mar 2005 20:45:03 -0000 1.59 *************** *** 121,126 **** elif _os.name == "posix": ! from _ctypes import dlopen as _LoadLibrary _FreeLibrary = None from _ctypes import sizeof, byref, addressof, alignment --- 121,133 ---- elif _os.name == "posix": ! from _ctypes import dlopen as _dlopen _FreeLibrary = None + def _LoadLibrary(name): + try: + return _dlopen(name) + except OSError: + if not name.endswith(".so"): + return _dlopen(name + ".so") + raise from _ctypes import sizeof, byref, addressof, alignment |
From: Thomas H. <th...@us...> - 2005-03-17 19:55:13
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10595 Modified Files: __init__.py Log Message: Remove the __del__ method in _CDLL. See comments in the code. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** __init__.py 16 Mar 2005 19:59:43 -0000 1.57 --- __init__.py 17 Mar 2005 19:54:55 -0000 1.58 *************** *** 338,345 **** return getattr(self, name) ! def __del__(self, FreeLibrary=_FreeLibrary): ! if self._handle != 0 and FreeLibrary: ! FreeLibrary(self._handle) ! self._handle = 0 class PyDLL(CDLL): --- 338,351 ---- return getattr(self, name) ! # This creates problems in gc. See ! # https://sourceforge.net/tracker/index.php?func=detail&aid=1042541&group_id=71702&atid=532154 ! # but since we cannot free the libraries anyway (the functions ! # retrieved don't keep a reference to the _DLL instance), it does no ! # harm to disable this code. ! # ! ## def __del__(self, FreeLibrary=_FreeLibrary): ! ## if self._handle != 0 and FreeLibrary: ! ## FreeLibrary(self._handle) ! ## self._handle = 0 class PyDLL(CDLL): |
From: Thomas H. <th...@us...> - 2005-03-17 19:33:38
|
Update of /cvsroot/ctypes/ctypes/win32/com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4295 Modified Files: register.py Log Message: Enclose the Python script to run as com server in double quotes in case the path contains spaces. Fix by Juan Carlos Coruna. Index: register.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/win32/com/register.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** register.py 20 Apr 2004 20:18:03 -0000 1.16 --- register.py 17 Mar 2005 19:33:29 -0000 1.17 *************** *** 81,85 **** else: # Or pythonw.exe? ! exe = "%s %s" % (sys.executable, os.path.abspath(sys.argv[0])) table.append((HKCR, "CLSID\\%s\\LocalServer32" % self._reg_clsid_, "", exe)) --- 81,85 ---- else: # Or pythonw.exe? ! exe = '%s "%s"' % (sys.executable, os.path.abspath(sys.argv[0])) table.append((HKCR, "CLSID\\%s\\LocalServer32" % self._reg_clsid_, "", exe)) |
From: Thomas H. <th...@us...> - 2005-03-17 19:30:45
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3621 Modified Files: ChangeLog Log Message: Record changes. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** ChangeLog 16 Mar 2005 19:54:16 -0000 1.82 --- ChangeLog 17 Mar 2005 19:30:27 -0000 1.83 *************** *** 1,2 **** --- 1,16 ---- + 2005-03-17 Thomas Heller <th...@py...> + + * ctypes.wrap.h2xml script: Added two command line options to + include preprocessor symbols into the xml file (the was the + default before), and to not delete temporary files which may help + locating problems in the compilation. The latter was suggested by + 'Bryan' on the ctypes-users list. + + Expanded the default excluded symbols list on Windows, so that + 'limits.h' can be processed. + + 'h2xml.py' can now read preprocessor symbol names to exclude from + a local configuration file 'h2xml.cfg' inb the current directory. + 2005-03-16 Thomas Heller <th...@py...> |
From: Thomas H. <th...@us...> - 2005-03-17 19:30:21
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3427 Modified Files: setup.py Log Message: Fix description (mainly for pypi). Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -d -r1.121 -r1.122 *** setup.py 16 Mar 2005 19:58:31 -0000 1.121 --- setup.py 17 Mar 2005 19:30:07 -0000 1.122 *************** *** 491,495 **** version=__version__, ! description="create and manipulate C data types in Python", long_description = __doc__, author="Thomas Heller", --- 491,495 ---- version=__version__, ! description="create and manipulate C data types in Python, call functions in shared libraries", long_description = __doc__, author="Thomas Heller", |
From: Thomas H. <th...@us...> - 2005-03-17 19:01:37
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28279 Modified Files: h2xml.py cparser.py Log Message: Implement adding excluded and excluded_re from the h2xml.cfg config file. Index: cparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/cparser.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cparser.py 17 Mar 2005 13:54:23 -0000 1.2 --- cparser.py 17 Mar 2005 19:01:26 -0000 1.3 *************** *** 6,9 **** --- 6,13 ---- except ImportError: subprocess = None + try: + set + except NameError: + from sets import Set as set if sys.platform == "win32": *************** *** 29,33 **** --- 33,57 ---- class IncludeParser(object): + def __init__(self, options): + """ + options must be an object having these attributes: + verbose - integer + flags - sequence of strings + keep_temporary_files - true if temporary files should not be deleted + cpp_symbols - whether to include preprocessor symbols in the XML file + excluded_symbols - collection of names for additional preprocessor symbols to exclude + excluded_symbols_re - collection of regular expressions for names to exclude + xml_file - pathname of output file (may be None) + """ + self.options = options + self.excluded = set() + self.excluded.update(EXCLUDED) + self.excluded.update(self.options.excluded_symbols) + self.excluded_re = set() + self.excluded_re.update(EXCLUDED_RE) + self.excluded_re.update(self.options.excluded_symbols_re) + + def create_source_file(self, lines, ext=".cpp"): "Create a temporary file, write lines to it, and return the filename" *************** *** 63,67 **** os.remove(fname) else: ! print >> sys.stderr, "file '%s' not removed" % fname return [line[len("#define "):] for line in data.splitlines() --- 87,91 ---- os.remove(fname) else: ! print >> sys.stderr, "Info: file '%s' not removed" % fname return [line[len("#define "):] for line in data.splitlines() *************** *** 87,91 **** if retcode: self.display_compiler_errors(err.splitlines()) - raise SystemExit(1) else: retcode = os.system(" ".join(args)) --- 111,114 ---- *************** *** 96,103 **** os.remove(fname) else: ! print >> sys.stderr, "file '%s' not removed" % fname def display_compiler_errors(self, lines): ! print "Compiler errors on these source lines:" import re, linecache pat = re.compile(r"(.*\.cpp):(\d+):(.*)") --- 119,126 ---- os.remove(fname) else: ! print >> sys.stderr, "Info: file '%s' not removed" % fname def display_compiler_errors(self, lines): ! print >> sys.stderr, "Compiler errors on these source lines:" import re, linecache pat = re.compile(r"(.*\.cpp):(\d+):(.*)") *************** *** 114,118 **** output[-1] = output[-1] + line.strip() for line in output: ! print line def get_defines(self, include_files): --- 137,141 ---- output[-1] = output[-1] + line.strip() for line in output: ! print >> sys.stderr, line def get_defines(self, include_files): *************** *** 143,149 **** if value in C_KEYWORDS: return "value is keyword" ! if name in EXCLUDED: return "excluded" ! for pat in EXCLUDED_RE: if pat.match(name): return "excluded (regex)" --- 166,172 ---- if value in C_KEYWORDS: return "value is keyword" ! if name in self.excluded: return "excluded" ! for pat in self.excluded_re: if pat.match(name): return "excluded (regex)" *************** *** 202,206 **** os.remove(fname) else: ! print >> sys.stderr, "file '%s' not removed" % fname types = {} --- 225,229 ---- os.remove(fname) else: ! print >> sys.stderr, "Info: file '%s' not removed" % fname types = {} *************** *** 253,265 **** ################################################################ ! def parse(self, include_files, options): ! """Main method. ! ! The options object must have these attribuites: ! verbose - integer ! flags - sequence of strings ! """ ! self.options = options ! if options.cpp_symbols: if options.verbose: --- 276,283 ---- ################################################################ ! def parse(self, include_files): ! """Parse include files.""" ! options = self.options ! if options.cpp_symbols: if options.verbose: Index: h2xml.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/h2xml.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** h2xml.py 17 Mar 2005 13:54:47 -0000 1.2 --- h2xml.py 17 Mar 2005 19:01:25 -0000 1.3 *************** *** 1,4 **** """h2xml - convert C include file(s) into an xml file by running gccxml.""" ! import sys, os, tempfile import cparser from optparse import OptionParser --- 1,4 ---- """h2xml - convert C include file(s) into an xml file by running gccxml.""" ! import sys, os, tempfile, re, ConfigParser import cparser from optparse import OptionParser *************** *** 29,32 **** --- 29,53 ---- parser.values.gccxml_options.extend((opt, value)) + # Hm, should there be a way to disable the config file? + # And then, this should be done AFTER the parameters are processed. + config = ConfigParser.ConfigParser() + try: + config.read("h2xml.cfg") + except ConfigParser.ParsingError, detail: + print >> sys.stderr, detail + return 1 + + def get_option(option, default_value): + # return an option from the platform specific section of the + # config file, or return the default_value if either the + # section or the option is not present. + try: + return config.get(sys.platform, option) + except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): + return default_value + + excluded = get_option("excluded", "").split() + excluded_re = get_option("excluded_re", "").split() + parser = OptionParser("usage: %prog includefile ... [options]") parser.add_option("-q", "--quiet", *************** *** 78,81 **** --- 99,114 ---- default=False) + parser.add_option("-s", + dest="excluded_symbols", + action="append", + help="specify preprocessor symbol name to exclude", + default=excluded) + + parser.add_option("-r", + dest="excluded_symbols_re", + action="append", + help="regular expression for preprocessor symbol names to exclude", + default=[]) + options, files = parser.parse_args() *************** *** 89,100 **** options.verbose = not options.quiet try: ! parser = cparser.IncludeParser() ! parser.parse(files, options) except cparser.CompilerError, detail: ! import traceback ! traceback.print_exc() ! ## print detail ! sys.exit(1) if __name__ == "__main__": --- 122,133 ---- options.verbose = not options.quiet + options.excluded_symbols_re = [re.compile(pat) for pat in options.excluded_symbols_re] + try: ! parser = cparser.IncludeParser(options) ! parser.parse(files) except cparser.CompilerError, detail: ! print >> sys.stderr, "CompilerError:", detail ! return 1 if __name__ == "__main__": |
From: Thomas H. <th...@us...> - 2005-03-17 18:59:55
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27734 Modified Files: codegen.txt Log Message: Document the h2xml.cfg config file. Index: codegen.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/codegen.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** codegen.txt 17 Mar 2005 13:54:47 -0000 1.2 --- codegen.txt 17 Mar 2005 18:59:46 -0000 1.3 *************** *** 50,54 **** .. _the ctypes download page: http://sourceforge.net/project/showfiles.php?group_id=71702 ! .. _GCC-XML windows installer: http://sourceforge.net/project/showfiles.php?group_id=71702&package_id=146740&release_id=311918 .. _GCC-XML: http://www.gccxml.org/ --- 50,55 ---- .. _the ctypes download page: http://sourceforge.net/project/showfiles.php?group_id=71702 ! XXX UPDATE LINK! ! .. _GCC-XML windows installer: http://sourceforge.net/project/showfiles.php?group_id=71702&package_id=71318&release_id=312072 .. _GCC-XML: http://www.gccxml.org/ *************** *** 70,73 **** --- 71,77 ---- - Better error output if the compilation fails. + - ``h2xml.py`` can load an optional local configuration file from the + current directory + Usage examples ============== *************** *** 303,306 **** --- 307,355 ---- compilation problems. + The h2xml.cfg configuration file + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + If you enable preprocessor definition processing with the ``-c`` flag, + it is possible that you get compiler errors on certain symbols. In + this case, it is needed to exclude those symbols by writing in local + configuration file named ``h2xml.cfg`` in the current directory. The + configuration file sections are named after ``sys.platform``, and it + allows to specify the symbols to exclude by names or by regular + expressions:: + + # h2xml.cfg + # + # config file for h2xml script + # + # sections should be named after 'sys.platform' + # options supported are: + # 'excluded' - names of preprocessor symbols to exclude, + # separated by whitespace + # 'excluded_re' - regular expressions, separated by whitespace, matching + # cpp symbols to exclude + # See the documentation of the standard Python ConfigParser module + # for maore information on the file format. + + [win32] + excluded = foo bar + excluded_re = spam.* .*spam + + [cygwin] + excluded = + excluded_re = + + [linux2] + excluded = + excluded_re = + + [darwin] + excluded = + excluded_re = + + [freebsd5] + excluded = + excluded_re = + + The xml2py.py script ==================== |
From: Thomas H. <th...@us...> - 2005-03-17 18:59:18
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27609 Modified Files: cparser_config.py Log Message: Update toddo comment. Index: cparser_config.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/cparser_config.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cparser_config.py 16 Mar 2005 08:50:26 -0000 1.2 --- cparser_config.py 17 Mar 2005 18:59:00 -0000 1.3 *************** *** 1,5 **** # cparser_config.py - configuration items for cparser.py # ! # XXX should be made platform specific! import re, sys, os --- 1,5 ---- # cparser_config.py - configuration items for cparser.py # ! # XXX Should this be converted to the h2xml.cfg style? import re, sys, os |
From: Thomas H. <th...@us...> - 2005-03-17 13:54:58
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22910 Modified Files: h2xml.py codegen.txt Log Message: The preprocessor magic is now optional (self.options.cpp_symbols), and optionally temprorary files will not be deleted (self.options.keep). Parse gccxml error messages when compilation fails - this only works when it is run with the subprocess module. Index: codegen.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/codegen.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** codegen.txt 11 Mar 2005 20:09:46 -0000 1.1 --- codegen.txt 17 Mar 2005 13:54:47 -0000 1.2 *************** *** 58,61 **** --- 58,73 ---- .. _get the development version from CVS: http://www.gccxml.org/HTML/Download.html + Changes in the ctypes 0.9.6 release + =================================== + + - ``h2xml.py`` doesn't try to find preprocessor definitions by default + anymore. Can be changed with the new ``-c`` or ``--cpp-symbols`` + flag. + + - Added ``-k`` option to ``h2xml.py`` to not delete temporary + files. + + - Better error output if the compilation fails. + Usage examples ============== *************** *** 67,73 **** This is useful to quickly look up the C source code. ! Parse the windows header files (this may take a while):: ! C:\>python h2xml.py windows.h -o windows.xml -q C:\> --- 79,86 ---- This is useful to quickly look up the C source code. ! Parse the windows header files (this may take a while), and include ! preprocessor definitions in the xml file:: ! C:\>python h2xml.py windows.h -o windows.xml -q -c C:\> *************** *** 90,94 **** C:\> ! Generate the ``MB_xxx`` constants, which are flags used for the ``MessageBox`` function:: c:\>python xml2py.py windows.xml -r MB_.* --- 103,109 ---- C:\> ! Generate the ``MB_xxx`` constants, which are flags used for the ! ``MessageBox`` function - since these are #define'd symbols this works ! only when the xml file includes preprocessor definitions:: c:\>python xml2py.py windows.xml -r MB_.* *************** *** 188,192 **** imports several symbols from the specified ``ctypes.com`` module. Note that the ``_iid_`` member of the interface cannot be created by ! the code generator, but the generated comment allows to quickly locate the header file and patch this manually:: --- 203,207 ---- imports several symbols from the specified ``ctypes.com`` module. Note that the ``_iid_`` member of the interface cannot be created by ! the code generator, but the generated comments allows to quickly locate the header file and patch this manually:: *************** *** 233,236 **** --- 248,263 ---- C:\> + On linux, the ``SDL.py`` module could be created in this way - both + the location of the include file and the name of the shared library is + different:: + + thomas@linux:~/ctypes/wrap> locate SDL.h + /usr/include/SDL/SDL.h + thomas@linux:~/ctypes/wrap> python h2xml.py SDL/SDL.h -o SDL.xml -q + thomas@linux:~/ctypes/wrap> python xml2py.py SDL.xml -o SDL.py -l libSDL.so + thomas@linux:~/ctypes/wrap> ls -l SDL.py + -rw-r--r-- 1 thomas users 95772 2004-10-26 02:23 SDL.py + thomas@linux:~/ctypes/wrap> + The h2xml.py script =================== *************** *** 265,268 **** --- 292,306 ---- This flag specifies name and path of the XML output file. + ``-c, --cpp-symbols`` + + Run additional magic to include #define symbols in the xml output. + Depending on the madness in the header files this may or may not + work. + + ``-k`` + + Do not delete temporary files created - this may be useful to find + compilation problems. + The xml2py.py script ==================== Index: h2xml.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/h2xml.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** h2xml.py 4 Feb 2005 17:01:24 -0000 1.1 --- h2xml.py 17 Mar 2005 13:54:47 -0000 1.2 *************** *** 30,34 **** parser = OptionParser("usage: %prog includefile ... [options]") - ## parser.add_option("-h", action="help") parser.add_option("-q", "--quiet", dest="quiet", --- 30,33 ---- *************** *** 44,47 **** --- 43,47 ---- metavar="NAME[=VALUE]", default=[]) + parser.add_option("-U", type="string", *************** *** 63,66 **** --- 63,81 ---- help="XML output filename", default=None) + + parser.add_option("-c", "--cpp-symbols", + dest="cpp_symbols", + action="store_true", + help="try to find #define symbols - this may give compiler errors, " \ + "so it's off by default.", + default=False) + + parser.add_option("-k", + dest="keep_temporary_files", + action="store_true", + help="don't delete the temporary files created "\ + "(useful for finding problems)", + default=False) + options, files = parser.parse_args() |
From: Thomas H. <th...@us...> - 2005-03-17 13:54:34
|
Update of /cvsroot/ctypes/ctypes/ctypes/wrap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22845 Modified Files: cparser.py Log Message: The preprocessor magic is now optional (self.options.cpp_symbols), and optionally temprorary files will not be deleted (self.options.keep). Parse gccxml error messages when compilation fails - this only works when it is run with the subprocess module. Index: cparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/wrap/cparser.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** cparser.py 4 Feb 2005 17:01:24 -0000 1.1 --- cparser.py 17 Mar 2005 13:54:23 -0000 1.2 *************** *** 60,64 **** data = o.read() finally: ! os.remove(fname) return [line[len("#define "):] for line in data.splitlines() --- 60,67 ---- data = o.read() finally: ! if not self.options.keep_temporary_files: ! os.remove(fname) ! else: ! print >> sys.stderr, "file '%s' not removed" % fname return [line[len("#define "):] for line in data.splitlines() *************** *** 76,80 **** print >> sys.stderr, "running:", " ".join(args) if subprocess: ! retcode = subprocess.call(args) else: retcode = os.system(" ".join(args)) --- 79,91 ---- print >> sys.stderr, "running:", " ".join(args) if subprocess: ! proc = subprocess.Popen(args, ! stdout=subprocess.PIPE, ! stderr=subprocess.PIPE, ! stdin=subprocess.PIPE) ! data, err = proc.communicate() ! retcode = proc.wait() ! if retcode: ! self.display_compiler_errors(err.splitlines()) ! raise SystemExit(1) else: retcode = os.system(" ".join(args)) *************** *** 82,86 **** raise CompilerError, "gccxml returned %s" % retcode finally: ! os.remove(fname) def get_defines(self, include_files): --- 93,118 ---- raise CompilerError, "gccxml returned %s" % retcode finally: ! if not self.options.keep_temporary_files: ! os.remove(fname) ! else: ! print >> sys.stderr, "file '%s' not removed" % fname ! ! def display_compiler_errors(self, lines): ! print "Compiler errors on these source lines:" ! import re, linecache ! pat = re.compile(r"(.*\.cpp):(\d+):(.*)") ! output = [] ! for line in lines: ! match = pat.search(line) ! if match: ! fnm, lineno, errmsg = match.groups() ! if re.match(r"\d+:", errmsg): ! errmsg = errmsg.split(":", 1)[1] ! text = "'%s' %s" % (linecache.getline(fnm, int(lineno)).rstrip(), errmsg) ! output.append(text) ! if line.startswith(" ") and output: ! output[-1] = output[-1] + line.strip() ! for line in output: ! print line def get_defines(self, include_files): *************** *** 167,171 **** finally: # make sure the temporary file is removed after using it ! os.remove(fname) types = {} --- 199,206 ---- finally: # make sure the temporary file is removed after using it ! if not self.options.keep_temporary_files: ! os.remove(fname) ! else: ! print >> sys.stderr, "file '%s' not removed" % fname types = {} *************** *** 227,247 **** self.options = options ! if options.verbose: ! print >> sys.stderr, "finding definitions ..." ! defines = self.get_defines(include_files) ! if options.verbose: ! print >> sys.stderr, "%d found" % len(defines) ! print >> sys.stderr, "filtering definitions ..." ! aliases, functions, excluded, defines = self.filter_definitions(defines) ! if options.verbose: ! print >> sys.stderr, "%d values, %d aliases" % (len(defines), len(aliases)) ! if options.verbose: ! print >> sys.stderr, "finding definitions types ..." ! # invoke C++ template magic ! types = self.find_types(include_files, defines) ! if options.verbose: ! print >> sys.stderr, "found %d types ..." % len(types) if options.verbose: --- 262,288 ---- self.options = options ! if options.cpp_symbols: ! if options.verbose: ! print >> sys.stderr, "finding definitions ..." ! defines = self.get_defines(include_files) ! if options.verbose: ! print >> sys.stderr, "%d found" % len(defines) ! print >> sys.stderr, "filtering definitions ..." ! aliases, functions, excluded, defines = self.filter_definitions(defines) ! if options.verbose: ! print >> sys.stderr, "%d values, %d aliases" % (len(defines), len(aliases)) ! if options.verbose: ! print >> sys.stderr, "finding definitions types ..." ! # invoke C++ template magic ! types = self.find_types(include_files, defines) ! if options.verbose: ! print >> sys.stderr, "found %d types ..." % len(types) ! else: ! types = {} ! functions = {} ! aliases = {} ! excluded = {} if options.verbose: |
From: Thomas H. <th...@us...> - 2005-03-17 10:34:43
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19539 Modified Files: __init__.py Log Message: Update some comments. Implement named properties. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** __init__.py 16 Mar 2005 20:18:36 -0000 1.24 --- __init__.py 17 Mar 2005 10:34:33 -0000 1.25 *************** *** 74,91 **** class _cominterface_meta(type): # Metaclass for COM interface classes. ! # Creates POINTER(cls) also for the newly created class. def __new__(self, name, bases, namespace): methods = namespace.pop("_methods_", None) cls = type.__new__(self, name, bases, namespace) - # XXX ??? First assign the _methods_, or first create the POINTER class? - # or does it not matter? if methods is not None: setattr(cls, "_methods_", methods) # If we sublass a COM interface, for example: # class IDispatch(IUnknown): # .... ! # then we want (need?) that ! # POINTER(IDispatch) is a subclass of POINTER(IUnknown). if bases == (object,): _ptr_bases = (cls, _compointer_base) --- 74,92 ---- class _cominterface_meta(type): # Metaclass for COM interface classes. ! # Creates also a POINTER type for the newly created class. def __new__(self, name, bases, namespace): methods = namespace.pop("_methods_", None) cls = type.__new__(self, name, bases, namespace) if methods is not None: setattr(cls, "_methods_", methods) # If we sublass a COM interface, for example: + # # class IDispatch(IUnknown): # .... ! # ! # then we need to make sure that POINTER(IDispatch) is a ! # subclass of POINTER(IUnknown) because of the way ctypes ! # typechecks work. if bases == (object,): _ptr_bases = (cls, _compointer_base) *************** *** 93,97 **** _ptr_bases = (cls, POINTER(bases[0])) # The interface 'cls' is used as a mixin. - # XXX "POINTER(<interface>)" looks nice as class name, but is it ok? p = type(_compointer_base)("POINTER(%s)" % cls.__name__, _ptr_bases, --- 94,97 ---- *************** *** 136,140 **** # attach it with a private name (__com_AddRef, for example), # so that custom method implementations can call it. - # XXX MORE INFO ABOUT THE SIGNATURE NEEDED! raw_func = prototype(i + vtbl_offset, name) setattr(self, --- 136,139 ---- *************** *** 146,165 **** func.__doc__ = doc # make it an unbound method, so we don't have to pass 'self' - # XXX MORE INFO ABOUT THE SIGNATURE NEEDED! mth = new.instancemethod(func, None, self) # is it a property set or property get? is_prop = False # The following code assumes that the docstrings for # propget and propput are identical. if "propget" in idlflags: assert name.startswith("_get_") propname = name[len("_get_"):] ! getters[propname, doc, len(argtypes)] = func is_prop = True elif "propput" in idlflags: assert name.startswith("_set_") propname = name[len("_set_"):] ! setters[propname, doc, len(argtypes)] = func is_prop = True --- 145,172 ---- func.__doc__ = doc # make it an unbound method, so we don't have to pass 'self' mth = new.instancemethod(func, None, self) # is it a property set or property get? is_prop = False + + # XXX Hm. What, when paramflags is None? + # Or does have '0' values? + # Seems we loose then, at least for properties... + # The following code assumes that the docstrings for # propget and propput are identical. if "propget" in idlflags: assert name.startswith("_get_") + nargs = len([flags for flags in paramflags + if flags[0] & 1]) propname = name[len("_get_"):] ! getters[propname, doc, nargs] = func is_prop = True elif "propput" in idlflags: assert name.startswith("_set_") + nargs = len([flags for flags in paramflags + if flags[0] & 1]) - 1 propname = name[len("_set_"):] ! setters[propname, doc, nargs] = func is_prop = True *************** *** 176,180 **** for item in set(getters.keys()) | set(getters.keys()): name, doc, nargs = item ! if nargs == 1: prop = property(getters.get(item), setters.get(item), doc=doc) else: --- 183,187 ---- for item in set(getters.keys()) | set(getters.keys()): name, doc, nargs = item ! if nargs == 0: prop = property(getters.get(item), setters.get(item), doc=doc) else: *************** *** 182,202 **** # returns a bound object having __getitem__ and # __setitem__ methods. ! ## prop = named_property(getters.get(item), setters.get(item), doc=doc) ! import warnings ! warnings.warn("Named property '%s'" % name, ! NotYetImplemented, ! stacklevel=3) ! g = getters.get(item) ! s = setters.get(item) ! if g is not None: ! name, doc, kind = item ! setattr(self, "_get_%s" % name, ! new.instancemethod(g, None, self)) ! if s is not None: ! name, doc, kind = item ! setattr(self, "_set_%s" % name, ! new.instancemethod(s, None, self)) ! continue ! setattr(self, name, prop) class NotYetImplemented(Warning): --- 189,226 ---- # returns a bound object having __getitem__ and # __setitem__ methods. ! prop = named_property(getters.get(item), setters.get(item), doc=doc) ! # Again, we should not overwrite class attributes that are ! # already present. ! if hasattr(self, name): ! setattr(self, "_" + name, prop) ! else: ! setattr(self, name, prop) ! ! class bound_named_property(object): ! def __init__(self, getter, setter, im_inst): ! self.im_inst = im_inst ! self.getter = getter ! self.setter = setter ! ! def __getitem__(self, index): ! if self.getter is None: ! raise TypeError("unsubscriptable object") ! return self.getter(self.im_inst, index) ! ! def __setitem__(self, index, value): ! if self.setter is None: ! raise TypeError("object does not support item assignment") ! self.setter(self.im_inst, index, value) ! ! class named_property(object): ! def __init__(self, getter, setter, doc): ! self.getter = getter ! self.setter = setter ! self.doc = doc ! ! def __get__(self, im_inst, im_class=None): ! if im_inst is None: ! return self ! return bound_named_property(self.getter, self.setter, im_inst) class NotYetImplemented(Warning): |
From: Thomas H. <th...@us...> - 2005-03-16 20:18:48
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14299 Modified Files: __init__.py Log Message: Create low level methods for named properties, the higher level is not yet implemented. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/__init__.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** __init__.py 16 Mar 2005 09:09:02 -0000 1.23 --- __init__.py 16 Mar 2005 20:18:36 -0000 1.24 *************** *** 187,190 **** --- 187,200 ---- NotYetImplemented, stacklevel=3) + g = getters.get(item) + s = setters.get(item) + if g is not None: + name, doc, kind = item + setattr(self, "_get_%s" % name, + new.instancemethod(g, None, self)) + if s is not None: + name, doc, kind = item + setattr(self, "_set_%s" % name, + new.instancemethod(s, None, self)) continue setattr(self, name, prop) |
From: Thomas H. <th...@us...> - 2005-03-16 19:59:56
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10146 Modified Files: __init__.py Log Message: Bump version number to 0.9.6 for next release. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** __init__.py 11 Mar 2005 19:26:42 -0000 1.56 --- __init__.py 16 Mar 2005 19:59:43 -0000 1.57 *************** *** 9,13 **** del _magicfile ! __version__ = "0.9.5" from _ctypes import Union, Structure, Array --- 9,13 ---- del _magicfile ! __version__ = "0.9.6" from _ctypes import Union, Structure, Array |
From: Thomas H. <th...@us...> - 2005-03-16 19:58:56
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9855 Modified Files: _ctypes.c Log Message: Bump version number to 0.9.6 for next release. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.225 retrieving revision 1.226 diff -C2 -d -r1.225 -r1.226 *** _ctypes.c 16 Mar 2005 19:45:27 -0000 1.225 --- _ctypes.c 16 Mar 2005 19:58:45 -0000 1.226 *************** *** 4048,4052 **** PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL)); PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI)); ! PyModule_AddStringConstant(m, "__version__", "0.9.5"); PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL); --- 4048,4052 ---- PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL)); PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI)); ! PyModule_AddStringConstant(m, "__version__", "0.9.6"); PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL); |
From: Thomas H. <th...@us...> - 2005-03-16 19:58:42
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9798 Modified Files: setup.py Log Message: Bump version number to 0.9.6 for next release. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.120 retrieving revision 1.121 diff -C2 -d -r1.120 -r1.121 *** setup.py 11 Mar 2005 20:43:35 -0000 1.120 --- setup.py 16 Mar 2005 19:58:31 -0000 1.121 *************** *** 12,16 **** LIBFFI_SOURCES='source/gcc/libffi' ! __version__ = "0.9.5" ################################################################ --- 12,16 ---- LIBFFI_SOURCES='source/gcc/libffi' ! __version__ = "0.9.6" ################################################################ |
From: Thomas H. <th...@us...> - 2005-03-16 19:54:27
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8823 Modified Files: ChangeLog Log Message: Record changes. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** ChangeLog 16 Mar 2005 18:00:46 -0000 1.81 --- ChangeLog 16 Mar 2005 19:54:16 -0000 1.82 *************** *** 1,4 **** --- 1,9 ---- 2005-03-16 Thomas Heller <th...@py...> + * ctypes\source\_ctyopes.c: Subclasses of c_char_p, c_wchar_p, and + c_void_p were not able to override the from_param class method in + their class definitions because SimpleType_new overwrote them. + Reported by Andreas Degert. + * ctypes\source: Removed the unneeded nArgBytes member from StgDictObject, and change the code accordingly. Thanks to |
From: Thomas H. <th...@us...> - 2005-03-16 19:53:32
|
Update of /cvsroot/ctypes/ctypes/unittests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8606 Modified Files: test_parameters.py Log Message: Subclasses of c_char_p, c_wchar_p, and c_void_p were not able to override the from_param class method in their class definitions because SimpleType_new overwrote them. Test it. Index: test_parameters.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/unittests/test_parameters.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** test_parameters.py 2 Dec 2004 09:53:48 -0000 1.27 --- test_parameters.py 16 Mar 2005 19:53:18 -0000 1.28 *************** *** 21,24 **** --- 21,52 ---- + def test_subclasses(self): + from ctypes import c_void_p, c_char_p + # ctypes 0.9.5 and before did overwrite from_param in SimpleType_new + class CVOIDP(c_void_p): + def from_param(cls, value): + return value * 2 + from_param = classmethod(from_param) + + class CCHARP(c_char_p): + def from_param(cls, value): + return value * 4 + from_param = classmethod(from_param) + + self.failUnlessEqual(CVOIDP.from_param("abc"), "abcabc") + self.failUnlessEqual(CCHARP.from_param("abc"), "abcabcabcabc") + + try: + from ctypes import c_wchar_p + except ImportError: + return + + class CWCHARP(c_wchar_p): + def from_param(cls, value): + return value * 3 + from_param = classmethod(from_param) + + self.failUnlessEqual(CWCHARP.from_param("abc"), "abcabcabc") + # XXX Replace by c_char_p tests def test_cstrings(self): |
From: Thomas H. <th...@us...> - 2005-03-16 19:45:38
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7180 Modified Files: _ctypes.c Log Message: Subclasses of c_char_p, c_wchar_p, and c_void_p were not able to override the from_param class method in their class definitions because SimpleType_new overwrote them. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.224 retrieving revision 1.225 diff -C2 -d -r1.224 -r1.225 *** _ctypes.c 16 Mar 2005 17:50:25 -0000 1.224 --- _ctypes.c 16 Mar 2005 19:45:27 -0000 1.225 *************** *** 113,116 **** --- 113,117 ---- PyObject *PyExc_ArgError; + static PyTypeObject Simple_Type; char *conversion_mode_encoding = NULL; *************** *** 1202,1206 **** #else ! static PyMethodDef c_void_p_method = { "from_param", c_void_p_from_param, METH_VARARGS }; static PyMethodDef c_char_p_method = { "from_param", c_char_p_from_param, METH_VARARGS }; --- 1203,1207 ---- #else ! #error static PyMethodDef c_void_p_method = { "from_param", c_void_p_from_param, METH_VARARGS }; static PyMethodDef c_char_p_method = { "from_param", c_char_p_from_param, METH_VARARGS }; *************** *** 1262,1308 **** result->tp_dict = (PyObject *)stgdict; ! switch (PyString_AS_STRING(proto)[0]) { ! case 'z': /* c_char_p */ ! ml = &c_char_p_method; ! break; ! case 'Z': /* c_wchar_p */ ! ml = &c_wchar_p_method; ! break; ! case 'P': /* c_void_p */ ! ml = &c_void_p_method; ! break; ! default: ! ml = NULL; ! break; ! } ! if (ml) { #if (PYTHON_API_VERSION >= 1012) ! PyObject *meth; ! int x; ! meth = PyDescr_NewClassMethod(result, ml); ! if (!meth) ! return NULL; #else ! PyObject *meth, *func; ! int x; ! func = PyCFunction_New(ml, NULL); ! if (!func) ! return NULL; ! meth = PyObject_CallFunctionObjArgs( ! (PyObject *)&PyClassMethod_Type, ! func, NULL); ! Py_DECREF(func); ! if (!meth) { ! return NULL; ! } #endif ! x = PyDict_SetItemString(result->tp_dict, ! ml->ml_name, ! meth); ! Py_DECREF(meth); ! if (x == -1) { ! Py_DECREF(result); ! return NULL; } } --- 1263,1315 ---- result->tp_dict = (PyObject *)stgdict; ! /* Install from_param class methods in ctypes base classes. ! Overrides the SimpleType_from_param generic method. ! */ ! if (result->tp_base == &Simple_Type) { ! switch (PyString_AS_STRING(proto)[0]) { ! case 'z': /* c_char_p */ ! ml = &c_char_p_method; ! break; ! case 'Z': /* c_wchar_p */ ! ml = &c_wchar_p_method; ! break; ! case 'P': /* c_void_p */ ! ml = &c_void_p_method; ! break; ! default: ! ml = NULL; ! break; ! } ! if (ml) { #if (PYTHON_API_VERSION >= 1012) ! PyObject *meth; ! int x; ! meth = PyDescr_NewClassMethod(result, ml); ! if (!meth) ! return NULL; #else ! #error ! PyObject *meth, *func; ! int x; ! func = PyCFunction_New(ml, NULL); ! if (!func) ! return NULL; ! meth = PyObject_CallFunctionObjArgs( ! (PyObject *)&PyClassMethod_Type, ! func, NULL); ! Py_DECREF(func); ! if (!meth) { ! return NULL; ! } #endif ! x = PyDict_SetItemString(result->tp_dict, ! ml->ml_name, ! meth); ! Py_DECREF(meth); ! if (x == -1) { ! Py_DECREF(result); ! return NULL; ! } } } |
From: Thomas H. <th...@us...> - 2005-03-16 18:10:36
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18849 Modified Files: setup_gccxml.iss Removed Files: xml2py.py tlbparser.py h2xml.py VARIANT.py README.txt .cvsignore Log Message: This stuff has been moved into the ctypes.wrap package. --- .cvsignore DELETED --- --- xml2py.py DELETED --- --- tlbparser.py DELETED --- --- h2xml.py DELETED --- --- VARIANT.py DELETED --- --- README.txt DELETED --- Index: setup_gccxml.iss =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/setup_gccxml.iss,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** setup_gccxml.iss 15 Mar 2005 11:10:58 -0000 1.2 --- setup_gccxml.iss 16 Mar 2005 18:10:20 -0000 1.3 *************** *** 9,12 **** --- 9,13 ---- LicenseFile="C:\sf\gccxml\GCC_XML\Copyright.txt" InfoBeforeFile=snapshot.txt + OutputDir="c:\inout" [Files] *************** *** 14,21 **** Source: "C:\sf\buildgcc\bin\release\snapshot.txt"; DestDir: "{app}\doc"; Destname: README.txt; Flags: ignoreversion ! Source: "C:\sf\buildgcc\bin\release\gccxml.exe"; DestDir: "{app}\bin"; Flags: ignoreversion ! Source: "C:\sf\buildgcc\bin\release\gccxml_cc1plus.exe"; DestDir: "{app}\bin"; Flags: ignoreversion ! Source: "C:\sf\buildgcc\bin\release\vcInstallPatch.exe"; DestDir: "{app}\install"; Flags: ignoreversion ! Source: "C:\sf\buildgcc\bin\release\vcInstall.exe"; DestDir: "{app}\install"; Flags: ignoreversion Source: "C:\sf\gccxml\GCC_XML\VcInstall\*.patch"; DestDir: "{app}\install"; Flags: ignoreversion --- 15,22 ---- Source: "C:\sf\buildgcc\bin\release\snapshot.txt"; DestDir: "{app}\doc"; Destname: README.txt; Flags: ignoreversion ! Source: "C:\sf\buildgcc6\bin\minsizerel\gccxml.exe"; DestDir: "{app}\bin"; Flags: ignoreversion ! Source: "C:\sf\buildgcc6\bin\minsizerel\gccxml_cc1plus.exe"; DestDir: "{app}\bin"; Flags: ignoreversion ! ;Source: "C:\sf\buildgcc6\bin\minsizerel\vcInstallPatch.exe"; DestName: "patch.exe"; DestDir: "{app}\install"; Flags: ignoreversion ! Source: "C:\sf\buildgcc6\bin\minsizerel\vcInstall.exe"; DestDir: "{app}\install"; Flags: ignoreversion Source: "C:\sf\gccxml\GCC_XML\VcInstall\*.patch"; DestDir: "{app}\install"; Flags: ignoreversion |
From: Thomas H. <th...@us...> - 2005-03-16 18:00:57
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16837 Modified Files: ChangeLog Log Message: Record changes. Index: ChangeLog =================================================================== RCS file: /cvsroot/ctypes/ctypes/ChangeLog,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** ChangeLog 14 Mar 2005 10:33:41 -0000 1.80 --- ChangeLog 16 Mar 2005 18:00:46 -0000 1.81 *************** *** 1,6 **** 2005-03-14 Thomas Heller <th...@py...> * _ctypes.c: Fixed refcount leak in functions with 'out' ! parameters. * _ctypes.c: Keyword arguments to Structures/Unions were ignored. --- 1,16 ---- + 2005-03-16 Thomas Heller <th...@py...> + + * ctypes\source: Removed the unneeded nArgBytes member from + StgDictObject, and change the code accordingly. Thanks to + Andreas Degert for spotting this. + + * ctypes\wrap\cparser_config.py: Added some symbols from windows + limits.h header file to the excluded list - h2xml.py choked on + them. + 2005-03-14 Thomas Heller <th...@py...> * _ctypes.c: Fixed refcount leak in functions with 'out' ! parameters. This has only relevance for comtypes. * _ctypes.c: Keyword arguments to Structures/Unions were ignored. |
From: Thomas H. <th...@us...> - 2005-03-16 17:50:36
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14221 Modified Files: ctypes.h callbacks.c _ctypes.c Log Message: Get rid of the nArgBytes member in StgDictObject. Unneeded and unused - spotted by Andreas Degert. Thanks! Index: ctypes.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/ctypes.h,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** ctypes.h 9 Mar 2005 18:23:33 -0000 1.73 --- ctypes.h 16 Mar 2005 17:50:25 -0000 1.74 *************** *** 118,122 **** extern THUNK AllocFunctionCallback(PyObject *callable, - int nArgBytes, PyObject *converters, PyObject *restype, --- 118,121 ---- *************** *** 174,178 **** PyObject *checker; int flags; /* calling convention and such */ - int nArgBytes; /* number of argument bytes for callback */ } StgDictObject; --- 173,176 ---- Index: callbacks.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/callbacks.c,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** callbacks.c 28 Jan 2005 16:07:32 -0000 1.70 --- callbacks.c 16 Mar 2005 17:50:25 -0000 1.71 *************** *** 319,323 **** THUNK AllocFunctionCallback(PyObject *callable, - int nArgBytes, PyObject *converters, PyObject *restype, --- 319,322 ---- Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.223 retrieving revision 1.224 diff -C2 -d -r1.223 -r1.224 *** _ctypes.c 14 Mar 2005 10:31:31 -0000 1.223 --- _ctypes.c 16 Mar 2005 17:50:25 -0000 1.224 *************** *** 1426,1435 **** static PyObject * ! converters_from_argtypes(PyObject *ob, int *psize) { PyObject *converters; int i; int nArgs; - int nArgBytes; ob = PySequence_Tuple(ob); /* new reference */ --- 1426,1434 ---- static PyObject * ! converters_from_argtypes(PyObject *ob) { PyObject *converters; int i; int nArgs; ob = PySequence_Tuple(ob); /* new reference */ *************** *** 1450,1454 **** */ - nArgBytes = 0; for (i = 0; i < nArgs; ++i) { PyObject *tp = PyTuple_GET_ITEM(ob, i); --- 1449,1452 ---- *************** *** 1457,1467 **** if (!dict || !cnv) goto argtypes_error_1; - /* round to full DWORDs */ - nArgBytes += (dict->size + sizeof(int) - 1) / sizeof(int) * sizeof(int); PyTuple_SET_ITEM(converters, i, cnv); } Py_DECREF(ob); - if (psize) - *psize = nArgBytes; return converters; --- 1455,1461 ---- *************** *** 1496,1503 **** /* _argtypes_ is optional... */ - stgdict->nArgBytes = 0; ob = PyDict_GetItemString((PyObject *)stgdict, "_argtypes_"); if (ob) { ! converters = converters_from_argtypes(ob, &stgdict->nArgBytes); if (!converters) goto error; --- 1490,1496 ---- /* _argtypes_ is optional... */ ob = PyDict_GetItemString((PyObject *)stgdict, "_argtypes_"); if (ob) { ! converters = converters_from_argtypes(ob); if (!converters) goto error; *************** *** 2208,2212 **** self->argtypes = NULL; } else { ! converters = converters_from_argtypes(ob, NULL); if (!converters) return -1; --- 2201,2205 ---- self->argtypes = NULL; } else { ! converters = converters_from_argtypes(ob); if (!converters) return -1; *************** *** 2518,2522 **** */ thunk = AllocFunctionCallback(callable, - dict->nArgBytes, dict->argtypes, dict->restype, --- 2511,2514 ---- |
From: Thomas H. <th...@us...> - 2005-03-16 16:34:18
|
Update of /cvsroot/ctypes/ctypes/comtypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28354 Modified Files: typeinfo.py Log Message: Wrap ITypeInfo::AddressOfMember. Index: typeinfo.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/typeinfo.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** typeinfo.py 16 Mar 2005 14:21:55 -0000 1.2 --- typeinfo.py 16 Mar 2005 16:34:05 -0000 1.3 *************** *** 4,7 **** --- 4,9 ---- import weakref + # Should probably be changed to use COMMETHOD! + from ctypes import * from comtypes import STDMETHOD *************** *** 333,337 **** return ti ! ## STDMETHOD(HRESULT, 'AddressOfMember', [MEMBERID, INVOKEKIND, POINTER(PVOID)]), ## STDMETHOD(HRESULT, 'CreateInstance', [POINTER(IUnknown), POINTER(IID), POINTER(PVOID)]), --- 335,344 ---- return ti ! def AddressOfMember(self, memid, invkind): ! "Get the address of a function in a dll" ! p = c_void_p() ! self.__com_AddressOfMember(memid, invkind, byref(p)) ! return p.value ! ## STDMETHOD(HRESULT, 'CreateInstance', [POINTER(IUnknown), POINTER(IID), POINTER(PVOID)]), *************** *** 552,557 **** ITypeComp._methods_ = [ # C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 3090 ! STDMETHOD(HRESULT, 'Bind', [LPOLESTR, DWORD, WORD, POINTER(POINTER(ITypeInfo)), POINTER(DESCKIND), POINTER(BINDPTR)]), ! STDMETHOD(HRESULT, 'BindType', [LPOLESTR, DWORD, POINTER(POINTER(ITypeInfo)), POINTER(POINTER(ITypeComp))]), ] --- 559,567 ---- ITypeComp._methods_ = [ # C:/Programme/gccxml/bin/Vc71/PlatformSDK/oaidl.h 3090 ! STDMETHOD(HRESULT, 'Bind', ! [LPOLESTR, DWORD, WORD, POINTER(POINTER(ITypeInfo)), ! POINTER(DESCKIND), POINTER(BINDPTR)]), ! STDMETHOD(HRESULT, 'BindType', ! [LPOLESTR, DWORD, POINTER(POINTER(ITypeInfo)), POINTER(POINTER(ITypeComp))]), ] |
From: Thomas H. <th...@us...> - 2005-03-16 14:25:25
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28647 Modified Files: tlbparser.py Log Message: Adapt to current package layout. For a dispinterface, try to get TKIND_INTERFACE, if that fails, use the TKIND_DISPATCH. Index: tlbparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/tlbparser.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tlbparser.py 17 Feb 2005 19:04:46 -0000 1.3 --- tlbparser.py 16 Mar 2005 14:25:12 -0000 1.4 *************** *** 1,3 **** ! from comtypes import _automation as automation import typedesc --- 1,5 ---- ! ##from comtypes import _automation as automation ! import comtypes.automation as automation ! import comtypes.typeinfo as typeinfo import typedesc *************** *** 63,67 **** automation.VT_HRESULT: HRESULT_type, # 25 # This is wrong. We must create separate SAFEARRAY(type) things. ! automation.VT_SAFEARRAY: SAFEARRAY_type, # 27 automation.VT_LPSTR: PTR(char_type), # 30 automation.VT_LPWSTR: PTR(wchar_t_type), # 31 --- 65,69 ---- automation.VT_HRESULT: HRESULT_type, # 25 # This is wrong. We must create separate SAFEARRAY(type) things. ! # automation.VT_SAFEARRAY: SAFEARRAY_type, # 27 automation.VT_LPSTR: PTR(char_type), # 30 automation.VT_LPWSTR: PTR(wchar_t_type), # 31 *************** *** 82,86 **** def __init__(self, path): ! self.tlib = automation.LoadTypeLibEx(path, regkind=automation.REGKIND_REGISTER) self.items = {} self.tlib.GetLibAttr() --- 84,88 ---- def __init__(self, path): ! self.tlib = typeinfo.LoadTypeLibEx(path, regkind=typeinfo.REGKIND_REGISTER) self.items = {} self.tlib.GetLibAttr() *************** *** 113,116 **** --- 115,119 ---- # SAFEARRAY(long), see Don Box pp.331f print "SAFEARRAY", tdesc._.lptdesc[0].vt + raise "HALT" return SAFEARRAY_type *************** *** 130,137 **** vd = tinfo.GetVarDesc(i) name = tinfo.GetDocumentation(vd.memid)[0] ! # XXX should be handled by VARIANT ! assert vd._.lpvarValue[0].n1.n2.vt == automation.VT_I4 ! assert vd.varkind == automation.VAR_CONST ! num_val = vd._.lpvarValue[0].n1.n2.n3.iVal v = typedesc.EnumValue(name, num_val, enum) enum.add_value(v) --- 133,138 ---- vd = tinfo.GetVarDesc(i) name = tinfo.GetDocumentation(vd.memid)[0] ! assert vd.varkind == typeinfo.VAR_CONST ! num_val = vd._.lpvarValue[0].value v = typedesc.EnumValue(name, num_val, enum) enum.add_value(v) *************** *** 153,157 **** name = tinfo.GetDocumentation(vd.memid)[0] offset = vd._.oInst * 8 ! assert vd.varkind == automation.VAR_PERINSTANCE typ = self.make_type(vd.elemdescVar.tdesc, tinfo) field = typedesc.Field(name, --- 154,158 ---- name = tinfo.GetDocumentation(vd.memid)[0] offset = vd._.oInst * 8 ! assert vd.varkind == typeinfo.VAR_PERINSTANCE typ = self.make_type(vd.elemdescVar.tdesc, tinfo) field = typedesc.Field(name, *************** *** 173,186 **** returns = self.make_type(fd.elemdescFunc.tdesc, tinfo) ! if fd.callconv == automation.CC_CDECL: attributes = "__cdecl__" ! elif fd.callconv == automation.CC_STDCALL: attributes = "__stdcall__" else: ! raise "NYI", fd.callconv func = typedesc.Function(func_name, returns, attributes, extern=1) if func_doc is not None: ! func.doc = str(func_doc) func.dllname = dllname self.items[func_name] = func --- 174,187 ---- returns = self.make_type(fd.elemdescFunc.tdesc, tinfo) ! if fd.callconv == typeinfo.CC_CDECL: attributes = "__cdecl__" ! elif fd.callconv == typeinfo.CC_STDCALL: attributes = "__stdcall__" else: ! raise ValueError, "calling convention %d" % fd.callconv func = typedesc.Function(func_name, returns, attributes, extern=1) if func_doc is not None: ! func.doc = func_doc.encode("mbcs") func.dllname = dllname self.items[func_name] = func *************** *** 194,212 **** vd = tinfo.GetVarDesc(i) name, var_doc = tinfo.GetDocumentation(vd.memid)[0:2] ! vt = vd._.lpvarValue[0].n1.n2.vt ! assert vd.varkind == automation.VAR_CONST ! # XXX Should be handled by VARIANT ! if vt == automation.VT_I4: ! typ = self.make_type(vd.elemdescVar.tdesc, tinfo) ! num_val = vd._.lpvarValue[0].n1.n2.n3.iVal ! v = typedesc.Variable(name, typ, repr(num_val)) ! self.items[name] = v ! elif vt == automation.VT_BSTR: ! typ = self.make_type(vd.elemdescVar.tdesc, tinfo) ! str_val = vd._.lpvarValue[0].n1.n2.n3.bstrVal ! v = typedesc.Variable(name, typ, '''"%s"''' % str_val) ! self.items[name] = v ! else: ! print "VT", vt if var_doc is not None: v.doc = var_doc --- 195,203 ---- vd = tinfo.GetVarDesc(i) name, var_doc = tinfo.GetDocumentation(vd.memid)[0:2] ! assert vd.varkind == typeinfo.VAR_CONST ! typ = self.make_type(vd.elemdescVar.tdesc, tinfo) ! var_value = vd._.lpvarValue[0].value ! v = typedesc.Variable(name, typ, repr(var_value)) ! self.items[name] = v if var_doc is not None: v.doc = var_doc *************** *** 248,262 **** name = names[p+1] flags = fd.lprgelemdescParam[p]._.paramdesc.wParamFlags ! if flags & automation.PARAMFLAG_FHASDEFAULT: # XXX should be handled by VARIANT itself var = fd.lprgelemdescParam[p]._.paramdesc.pparamdescex[0].varDefaultValue ! if var.n1.n2.vt == automation.VT_BSTR: ! default = var.n1.n2.n3.bstrVal ! elif var.n1.n2.vt == automation.VT_I4: ! default = var.n1.n2.n3.iVal ! elif var.n1.n2.vt == automation.VT_BOOL: ! default = bool(var.n1.n2.n3.boolVal) ! else: ! raise "NYI", var.n1.n2.vt else: default = None --- 239,246 ---- name = names[p+1] flags = fd.lprgelemdescParam[p]._.paramdesc.wParamFlags ! if flags & typeinfo.PARAMFLAG_FHASDEFAULT: # XXX should be handled by VARIANT itself var = fd.lprgelemdescParam[p]._.paramdesc.pparamdescex[0].varDefaultValue ! default = var.value else: default = None *************** *** 283,288 **** self.items[itf_name] = itf ! flags = ta.wTypeFlags & (automation.TYPEFLAG_FDISPATCHABLE | automation.TYPEFLAG_FDUAL) ! if flags == automation.TYPEFLAG_FDISPATCHABLE: # dual interface basemethods = 0 --- 267,272 ---- self.items[itf_name] = itf ! flags = ta.wTypeFlags & (typeinfo.TYPEFLAG_FDISPATCHABLE | typeinfo.TYPEFLAG_FDUAL) ! if flags == typeinfo.TYPEFLAG_FDISPATCHABLE: # dual interface basemethods = 0 *************** *** 294,298 **** for i in range(ta.cVars): vd = tinfo.GetVarDesc(i) ! assert vd.varkind == automation.VAR_DISPATCH var_name, doc = tinfo.GetDocumentation(vd.memid)[0:2] typ = self.make_type(vd.elemdescVar.tdesc, tinfo) --- 278,282 ---- for i in range(ta.cVars): vd = tinfo.GetVarDesc(i) ! assert vd.varkind == typeinfo.VAR_DISPATCH var_name, doc = tinfo.GetDocumentation(vd.memid)[0:2] typ = self.make_type(vd.elemdescVar.tdesc, tinfo) *************** *** 319,335 **** name = names[p+1] flags = fd.lprgelemdescParam[p]._.paramdesc.wParamFlags ! if flags & automation.PARAMFLAG_FHASDEFAULT: # XXX should be handled by VARIANT itself var = fd.lprgelemdescParam[p]._.paramdesc.pparamdescex[0].varDefaultValue ! if var.n1.n2.vt == automation.VT_BSTR: ! default = var.n1.n2.n3.bstrVal ! elif var.n1.n2.vt == automation.VT_I4: ! default = var.n1.n2.n3.iVal ! elif var.n1.n2.vt == automation.VT_BOOL: ! default = bool(var.n1.n2.n3.boolVal) ! elif var.n1.n2.vt == automation.VT_R4: ! default = var.n1.n2.n3.fltVal ! else: ! raise "NYI", var.n1.n2.vt else: default = None --- 303,310 ---- name = names[p+1] flags = fd.lprgelemdescParam[p]._.paramdesc.wParamFlags ! if flags & typeinfo.PARAMFLAG_FHASDEFAULT: # XXX should be handled by VARIANT itself var = fd.lprgelemdescParam[p]._.paramdesc.pparamdescex[0].varDefaultValue ! default = var.value else: default = None *************** *** 348,375 **** def func_flags(self, flags): # map FUNCFLAGS values to idl attributes ! NAMES = {automation.FUNCFLAG_FRESTRICTED: "restricted", ! automation.FUNCFLAG_FSOURCE: "source", ! automation.FUNCFLAG_FBINDABLE: "bindable", ! automation.FUNCFLAG_FREQUESTEDIT: "requestedit", ! automation.FUNCFLAG_FDISPLAYBIND: "displaybind", ! automation.FUNCFLAG_FDEFAULTBIND: "defaultbind", ! automation.FUNCFLAG_FHIDDEN: "hidden", ! automation.FUNCFLAG_FUSESGETLASTERROR: "usesgetlasterror", ! automation.FUNCFLAG_FDEFAULTCOLLELEM: "defaultcollelem", ! automation.FUNCFLAG_FUIDEFAULT: "uidefault", ! automation.FUNCFLAG_FNONBROWSABLE: "nonbrowsable", ! # automation.FUNCFLAG_FREPLACEABLE: "???", ! automation.FUNCFLAG_FIMMEDIATEBIND: "immediatebind"} return [NAMES[bit] for bit in NAMES if bit & flags] def param_flags(self, flags): # map PARAMFLAGS values to idl attributes ! NAMES = {automation.PARAMFLAG_FIN: "in", ! automation.PARAMFLAG_FOUT: "out", ! automation.PARAMFLAG_FLCID: "lcid", ! automation.PARAMFLAG_FRETVAL: "retval", ! automation.PARAMFLAG_FOPT: "optional", ! # automation.PARAMFLAG_FHASDEFAULT: "", ! # automation.PARAMFLAG_FHASCUSTDATA: "", } return [NAMES[bit] for bit in NAMES if bit & flags] --- 323,350 ---- def func_flags(self, flags): # map FUNCFLAGS values to idl attributes ! NAMES = {typeinfo.FUNCFLAG_FRESTRICTED: "restricted", ! typeinfo.FUNCFLAG_FSOURCE: "source", ! typeinfo.FUNCFLAG_FBINDABLE: "bindable", ! typeinfo.FUNCFLAG_FREQUESTEDIT: "requestedit", ! typeinfo.FUNCFLAG_FDISPLAYBIND: "displaybind", ! typeinfo.FUNCFLAG_FDEFAULTBIND: "defaultbind", ! typeinfo.FUNCFLAG_FHIDDEN: "hidden", ! typeinfo.FUNCFLAG_FUSESGETLASTERROR: "usesgetlasterror", ! typeinfo.FUNCFLAG_FDEFAULTCOLLELEM: "defaultcollelem", ! typeinfo.FUNCFLAG_FUIDEFAULT: "uidefault", ! typeinfo.FUNCFLAG_FNONBROWSABLE: "nonbrowsable", ! # typeinfo.FUNCFLAG_FREPLACEABLE: "???", ! typeinfo.FUNCFLAG_FIMMEDIATEBIND: "immediatebind"} return [NAMES[bit] for bit in NAMES if bit & flags] def param_flags(self, flags): # map PARAMFLAGS values to idl attributes ! NAMES = {typeinfo.PARAMFLAG_FIN: "in", ! typeinfo.PARAMFLAG_FOUT: "out", ! typeinfo.PARAMFLAG_FLCID: "lcid", ! typeinfo.PARAMFLAG_FRETVAL: "retval", ! typeinfo.PARAMFLAG_FOPT: "optional", ! # typeinfo.PARAMFLAG_FHASDEFAULT: "", ! # typeinfo.PARAMFLAG_FHASCUSTDATA: "", } return [NAMES[bit] for bit in NAMES if bit & flags] *************** *** 377,412 **** def idl_flags(self, flags): # map TYPEFLAGS values to idl attributes ! NAMES = {automation.TYPEFLAG_FAPPOBJECT: "appobject", ! # automation.TYPEFLAG_FCANCREATE: ! automation.TYPEFLAG_FLICENSED: "licensed", ! # automation.TYPEFLAG_FPREDECLID: ! automation.TYPEFLAG_FHIDDEN: "hidden", ! automation.TYPEFLAG_FCONTROL: "control", ! automation.TYPEFLAG_FDUAL: "dual", ! automation.TYPEFLAG_FNONEXTENSIBLE: "nonextensible", ! automation.TYPEFLAG_FOLEAUTOMATION: "oleautomation", ! automation.TYPEFLAG_FRESTRICTED: "restricted", ! automation.TYPEFLAG_FAGGREGATABLE: "aggregatable", ! # automation.TYPEFLAG_FREPLACEABLE: ! # automation.TYPEFLAG_FDISPATCHABLE # computed, no flag for this ! automation.TYPEFLAG_FREVERSEBIND: "reversebind", ! automation.TYPEFLAG_FPROXY: "proxy", } return [NAMES[bit] for bit in NAMES if bit & flags] def var_flags(self, flags): ! NAMES = {automation.VARFLAG_FREADONLY: "readonly", ! automation.VARFLAG_FSOURCE: "source", ! automation.VARFLAG_FBINDABLE: "bindable", ! automation.VARFLAG_FREQUESTEDIT: "requestedit", ! automation.VARFLAG_FDISPLAYBIND: "displaybind", ! automation.VARFLAG_FDEFAULTBIND: "defaultbind", ! automation.VARFLAG_FHIDDEN: "hidden", ! automation.VARFLAG_FRESTRICTED: "restricted", ! automation.VARFLAG_FDEFAULTCOLLELEM: "defaultcollelem", ! automation.VARFLAG_FUIDEFAULT: "uidefault", ! automation.VARFLAG_FNONBROWSABLE: "nonbrowsable", ! automation.VARFLAG_FREPLACEABLE: "replaceable", ! automation.VARFLAG_FIMMEDIATEBIND: "immediatebind" } return [NAMES[bit] for bit in NAMES if bit & flags] --- 352,387 ---- def idl_flags(self, flags): # map TYPEFLAGS values to idl attributes ! NAMES = {typeinfo.TYPEFLAG_FAPPOBJECT: "appobject", ! # typeinfo.TYPEFLAG_FCANCREATE: ! typeinfo.TYPEFLAG_FLICENSED: "licensed", ! # typeinfo.TYPEFLAG_FPREDECLID: ! typeinfo.TYPEFLAG_FHIDDEN: "hidden", ! typeinfo.TYPEFLAG_FCONTROL: "control", ! typeinfo.TYPEFLAG_FDUAL: "dual", ! typeinfo.TYPEFLAG_FNONEXTENSIBLE: "nonextensible", ! typeinfo.TYPEFLAG_FOLEAUTOMATION: "oleautomation", ! typeinfo.TYPEFLAG_FRESTRICTED: "restricted", ! typeinfo.TYPEFLAG_FAGGREGATABLE: "aggregatable", ! # typeinfo.TYPEFLAG_FREPLACEABLE: ! # typeinfo.TYPEFLAG_FDISPATCHABLE # computed, no flag for this ! typeinfo.TYPEFLAG_FREVERSEBIND: "reversebind", ! typeinfo.TYPEFLAG_FPROXY: "proxy", } return [NAMES[bit] for bit in NAMES if bit & flags] def var_flags(self, flags): ! NAMES = {typeinfo.VARFLAG_FREADONLY: "readonly", ! typeinfo.VARFLAG_FSOURCE: "source", ! typeinfo.VARFLAG_FBINDABLE: "bindable", ! typeinfo.VARFLAG_FREQUESTEDIT: "requestedit", ! typeinfo.VARFLAG_FDISPLAYBIND: "displaybind", ! typeinfo.VARFLAG_FDEFAULTBIND: "defaultbind", ! typeinfo.VARFLAG_FHIDDEN: "hidden", ! typeinfo.VARFLAG_FRESTRICTED: "restricted", ! typeinfo.VARFLAG_FDEFAULTCOLLELEM: "defaultcollelem", ! typeinfo.VARFLAG_FUIDEFAULT: "uidefault", ! typeinfo.VARFLAG_FNONBROWSABLE: "nonbrowsable", ! typeinfo.VARFLAG_FREPLACEABLE: "replaceable", ! typeinfo.VARFLAG_FIMMEDIATEBIND: "immediatebind" } return [NAMES[bit] for bit in NAMES if bit & flags] *************** *** 453,457 **** name = tinfo.GetDocumentation(vd.memid)[0] offset = vd._.oInst * 8 ! assert vd.varkind == automation.VAR_PERINSTANCE typ = self.make_type(vd.elemdescVar.tdesc, tinfo) field = typedesc.Field(name, --- 428,432 ---- name = tinfo.GetDocumentation(vd.memid)[0] offset = vd._.oInst * 8 ! assert vd.varkind == typeinfo.VAR_PERINSTANCE typ = self.make_type(vd.elemdescVar.tdesc, tinfo) field = typedesc.Field(name, *************** *** 472,490 **** ta = tinfo.GetTypeAttr() tkind = ta.typekind ! if tkind == automation.TKIND_ENUM: # 0 return self.ParseEnum(tinfo, ta) ! elif tkind == automation.TKIND_RECORD: # 1 return self.ParseRecord(tinfo, ta) ! elif tkind == automation.TKIND_MODULE: # 2 return self.ParseModule(tinfo, ta) ! elif tkind == automation.TKIND_INTERFACE: # 3 return self.ParseInterface(tinfo, ta) ! elif tkind == automation.TKIND_DISPATCH: # 4 ! return self.ParseDispatch(tinfo, ta) ! elif tkind == automation.TKIND_COCLASS: # 5 return self.ParseCoClass(tinfo, ta) ! elif tkind == automation.TKIND_ALIAS: # 6 return self.ParseAlias(tinfo, ta) ! elif tkind == automation.TKIND_UNION: # 7 return self.ParseUnion(tinfo, ta) else: --- 447,473 ---- ta = tinfo.GetTypeAttr() tkind = ta.typekind ! if tkind == typeinfo.TKIND_ENUM: # 0 return self.ParseEnum(tinfo, ta) ! elif tkind == typeinfo.TKIND_RECORD: # 1 return self.ParseRecord(tinfo, ta) ! elif tkind == typeinfo.TKIND_MODULE: # 2 return self.ParseModule(tinfo, ta) ! elif tkind == typeinfo.TKIND_INTERFACE: # 3 return self.ParseInterface(tinfo, ta) ! elif tkind == typeinfo.TKIND_DISPATCH: # 4 ! try: ! href = tinfo.GetRefTypeOfImplType(-1) ! except WindowsError: ! # no dual interface ! return self.ParseDispatch(tinfo, ta) ! tinfo = tinfo.GetRefTypeInfo(href) ! ta = tinfo.GetTypeAttr() ! assert ta.typekind == typeinfo.TKIND_INTERFACE ! return self.ParseInterface(tinfo, ta) ! elif tkind == typeinfo.TKIND_COCLASS: # 5 return self.ParseCoClass(tinfo, ta) ! elif tkind == typeinfo.TKIND_ALIAS: # 6 return self.ParseAlias(tinfo, ta) ! elif tkind == typeinfo.TKIND_UNION: # 7 return self.ParseUnion(tinfo, ta) else: *************** *** 502,546 **** ################################################################ - coclass = typedesc.FundamentalType("CoClass", 32, 32) # fake for codegen - def main(): import sys ## path = r"hnetcfg.dll" ## path = r"simpdata.tlb" ## path = r"nscompat.tlb" - ## path = r"mshtml.tlb" # has propputref ## path = r"stdole32.tlb" ! ## path = "msscript.ocx" ## path = r"shdocvw.dll" ## path = r"c:\Programme\Microsoft Office\Office\MSO97.DLL" - ## path = r"c:\Programme\Microsoft Office\Office\MSWORD8.OLB" # has propputref - ## path = r"msi.dll" # DispProperty - ## path = r"PICCLP32.OCX" # DispProperty - ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\win.tlb" - ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\win32.tlb" ## path = r"MSHFLXGD.OCX" # DispProperty, propputref ## path = r"scrrun.dll" # propput AND propputref on IDictionary::Item - ## path = r"c:\Programme\Gemeinsame Dateien\Microsoft Shared\Speech\sapi.dll" ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\threadapi.tlb" - ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\win32.tlb" - - path = "mytlb.tlb" - ## # this has a IUnknown* default parameter - ## path = r"c:\Programme\Gemeinsame Dateien\Microsoft Shared\Speech\sapi.dll" - ## path = r"c:\tss5\include\fpanel.tlb" - - ## path = "auto.tlb" known_symbols = {} ! ! from ctypes.wrap import template ! templates = {} ! ## templates = template.get_templates("mytlb.py") ! ! ## for name in ("comtypes._automation", "comtypes", "ctypes"): ! for name in ("auto", "comtypes", "ctypes"): mod = __import__(name) for submodule in name.split(".")[1:]: --- 485,522 ---- ################################################################ def main(): import sys + ## these do NOT work: + # XXX infinite loop? + ## path = r"mshtml.tlb" # has propputref + # has SAFEARRAY + ## path = "msscript.ocx" + # has SAFEARRAY + ## path = r"c:\Programme\Microsoft Office\Office\MSWORD8.OLB" # has propputref + # has SAFEARRAY + ## path = r"msi.dll" # DispProperty + # fails packing IDLDESC + ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\win.tlb" + # fails packing WIN32_FIND_DATA + ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\win32.tlb" + # has a POINTER(IUnknown) as default parameter value + ## path = r"c:\Programme\Gemeinsame Dateien\Microsoft Shared\Speech\sapi.dll" + ## path = r"hnetcfg.dll" ## path = r"simpdata.tlb" ## path = r"nscompat.tlb" ## path = r"stdole32.tlb" ! ## path = r"shdocvw.dll" ## path = r"c:\Programme\Microsoft Office\Office\MSO97.DLL" ## path = r"PICCLP32.OCX" # DispProperty ## path = r"MSHFLXGD.OCX" # DispProperty, propputref ## path = r"scrrun.dll" # propput AND propputref on IDictionary::Item ## path = r"C:\Dokumente und Einstellungen\thomas\Desktop\tlb\threadapi.tlb" known_symbols = {} ! for name in ("comtypes.automation", "comtypes", "ctypes"): mod = __import__(name) for submodule in name.split(".")[1:]: *************** *** 551,561 **** p = TlbParser(path) items = p.parse() ! items["CoClass"] = coclass from codegenerator import Generator ! ## gen = Generator(open("mytlb.py", "w")) ! gen = Generator(sys.stdout) ! print >> gen.imports, "from helpers import *" ! loops = gen.generate_code(items.values(), known_symbols, [], templates) if __name__ == "__main__": --- 527,539 ---- p = TlbParser(path) items = p.parse() ! from codegenerator import Generator ! gen = Generator(sys.stdout, ! use_decorators=True, ! known_symbols=known_symbols, ! ## searched_dlls=None, ! ) ! gen.generate_code(items.values()) if __name__ == "__main__": |
From: Thomas H. <th...@us...> - 2005-03-16 14:22:56
|
Update of /cvsroot/ctypes/ctypes/comtypes/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28039 Modified Files: codegenerator.py Log Message: Clean up, fix a small bug. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/comtypes/tools/codegenerator.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** codegenerator.py 16 Mar 2005 09:52:57 -0000 1.5 --- codegenerator.py 16 Mar 2005 14:22:41 -0000 1.6 *************** *** 102,106 **** def make_ComMethod(self, m): # typ, name, idlflags, default - args = [self.type_name(a[0]) for a in m.arguments] code = " COMMETHOD(%r, %s, '%s'" % ( m.idlflags, --- 102,105 ---- *************** *** 116,120 **** for typ, name, idlflags, default in m.arguments: if default is not None: ! arglist.append("( %r, '%s', %r )" % ( idlflags, self.type_name(typ), --- 115,119 ---- for typ, name, idlflags, default in m.arguments: if default is not None: ! arglist.append("( %r, %s, '%s', %r )" % ( idlflags, self.type_name(typ), *************** *** 131,135 **** def make_DispMethod(self, m): # typ, name, idlflags, default - args = [self.type_name(a[0]) for a in m.arguments] code = " DISPMETHOD(%r, %s, '%s'" % ( [m.dispid] + m.idlflags, --- 130,133 ---- |