ctypes-commit Mailing List for ctypes (Page 9)
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...> - 2006-05-31 17:57:08
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv29119 Removed Files: ctypes.tex Log Message: Remove now-unused file. --- ctypes.tex DELETED --- |
From: Thomas H. <th...@us...> - 2006-05-31 17:55:52
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv28400 Removed Files: manual.html Log Message: Remove now-unused file. --- manual.html DELETED --- |
From: Thomas H. <th...@us...> - 2006-05-31 17:55:25
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv28345 Modified Files: make.bat Added Files: filter.py Log Message: --- NEW FILE: filter.py --- import sys TOKENS = """: funcdesc : excdesc : vardesc : classdesc : methoddesc : memberdesc : classdesc*""".splitlines() for line in open(sys.argv[1], "r"): for token in TOKENS: line = line.rstrip() if line.endswith(token): print line[:-len(token)] break else: print line Index: make.bat =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/make.bat,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** make.bat 21 Mar 2006 21:17:51 -0000 1.3 --- make.bat 31 May 2006 17:55:21 -0000 1.4 *************** *** 1,3 **** ! c:\python24\scripts\rst2html.py manual.txt manual.html ! c:\python24\scripts\rst2html.py docs.txt docs.html ! c:\python24\scripts\rst2html.py tutorial.txt tutorial.html --- 1,3 ---- ! filter.py tutorial.txt | c:\python24\python c:\python24\scripts\rst2html.py > tutorial.html ! filter.py reference.txt | c:\python24\python c:\python24\scripts\rst2html.py > reference.html ! filter.py ctypes.txt | c:\python24\python c:\python24\scripts\rst2html.py > ctypes.html |
From: Thomas H. <th...@us...> - 2006-05-31 17:55:08
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27976 Modified Files: mkpydoc.py Log Message: Newest version from docutils/sandbox/docpy-writer. Index: mkpydoc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/mkpydoc.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** mkpydoc.py 12 May 2006 19:57:27 -0000 1.12 --- mkpydoc.py 31 May 2006 17:54:51 -0000 1.13 *************** *** 1,5 **** #!/usr/bin/python ! # Convert the ctypes docs to LaTeX for use in Python docs # This script is a hacked version taken from the Optik SVN repository. --- 1,5 ---- #!/usr/bin/python ! # Convert the reStructuredText docs to LaTeX for use in Python docs # This script is a hacked version taken from the Optik SVN repository. *************** *** 7,12 **** import sys, os import re - from popen2 import popen2 - from glob import glob import rfc822 from distutils.dep_util import newer_group, newer --- 7,10 ---- *************** *** 45,56 **** } roman = (None,None,"ii","iii","iv","v") - # XXX need to factor this out - module_name = "ctypes" - module_summary = "A foreign function library for Python." - module_type = "standard" - module_author = "Thomas Heller" - module_author_email = "th...@py..." - module_synopsis = ("A foreign function library for Python.") - version_added = "2.5" refuri_override = { --- 43,46 ---- *************** *** 61,68 **** --- 51,62 ---- def __init__(self, document): LaTeXTranslator.__init__(self, document) + self.label_prefix = "" + self.docinfo = {} self.head_prefix = [] self.head = [] self.body_prefix = [] self.in_title = False + self.in_anydesc = False # _title is different if it is a funcdesc + self.admonition_stack = [] # Disable a bunch of methods from the base class. *************** *** 74,86 **** setattr(self, 'visit_' + nodetype, empty_method) setattr(self, 'depart_' + nodetype, empty_method) ! # TODO document properties from document ! self.head_prefix = [ ! "\\section{\\module{%(module_name)s} --- %(module_summary)s}\n" ! "\\declaremodule{%(module_type)s}{%(module_name)s}\n" ! "\\moduleauthor{%(module_author)s}{%(module_author_email)s}\n" ! "\\modulesynopsis{%(module_synopsis)s}\n" ! "\\versionadded{%(version_added)s}\n" ! % vars(self.__class__) ! ] # definitions must be guarded if multiple modules are included self.definitions = [ --- 68,72 ---- setattr(self, 'visit_' + nodetype, empty_method) setattr(self, 'depart_' + nodetype, empty_method) ! self.head_prefix = [] # definitions must be guarded if multiple modules are included self.definitions = [ *************** *** 96,99 **** --- 82,88 ---- self.body_suffix) + def set_label_prefix(self, text): + self.label_prefix = text.replace(" ","-") + def generate_section_label(self, title): title = title.lower() *************** *** 102,107 **** title = re.sub(r'\b(the|an?|and|your|are)\b', '', title) title = re.sub(r'(example \d+).*', r'\1', title) ! ## title = title.replace("optik", "optparse") ! return "ctypes-" + "-".join(title.split()) def visit_document(self, node): --- 91,95 ---- title = re.sub(r'\b(the|an?|and|your|are)\b', '', title) title = re.sub(r'(example \d+).*', r'\1', title) ! return self.label_prefix + "-" + "-".join(title.split()) def visit_document(self, node): *************** *** 112,128 **** def visit_docinfo(self, node): ! #print "visit_docinfo: %r" % node ! self.docinfo = [] def depart_docinfo(self, node): ! #print "depart_docinfo: %r" % node ! self.body = self.docinfo + self.body ! self.docinfo = None def visit_docinfo_item(self, node, name): - #print "visit_docinfo_item: node=%r, name=%r" % (node, name) if name == "author": ! (name, email) = rfc822.parseaddr(node.astext()) ! self.docinfo.append("\\sectionauthor{%s}{%s}\n" % (name, email)) raise nodes.SkipNode --- 100,141 ---- def visit_docinfo(self, node): ! pass def depart_docinfo(self, node): ! # module and summary are mandatory ! self.body.append( ! "\\section{\\module{%(module)s} --- %(summary)s}\n" ! % self.docinfo ) ! if self.docinfo.has_key("moduletype"): ! self.body.append( ! "\\declaremodule{%(moduletype)s}{%(module)s}\n" ! % self.docinfo ) ! if self.docinfo.has_key("moduleauthor"): ! self.body.append( ! "\\moduleauthor{%(moduleauthor)s}{%(moduleauthoremail)s}\n" ! % self.docinfo ) ! if self.docinfo.has_key("synopsis"): ! self.body.append( ! "\\modulesynopsis{%(synopsis)s}\n" ! % self.docinfo ) ! if self.docinfo.has_key("release"): ! self.body.append( "\\release{%(release)s}\n" % self.docinfo ) ! if self.docinfo.has_key("shortversion"): ! self.body.append( "\\setshortversion{%(shortversion)s}\n" ! % self.docinfo ) ! if self.docinfo.has_key("sectionauthor"): ! self.body.append( ! "\\sectionauthor{%(sectionauthor)s}{%(sectionauthoremail)s}\n" ! % self.docinfo ) ! if self.docinfo.has_key("versionadded"): ! self.body.append( ! "\\versionadded{%(versionadded)s}\n" ! % self.docinfo ) def visit_docinfo_item(self, node, name): if name == "author": ! (ename, email) = rfc822.parseaddr(node.astext()) ! self.docinfo["moduleauthor"] = ename ! self.docinfo["moduleauthoremail"] = email raise nodes.SkipNode *************** *** 130,141 **** pass ! #def visit_field(self, node): ! # (name, value) = (node[0].astext(), node[1].astext()) ! # print "visit_field: node=%r (name=%r, value=%r)" % (node, name, value) ! # if self.docinfo is not None: ! # if name == "VersionAdded": ! # self.docinfo.append("\\versionadded{%s}\n" % value) ! # raise nodes.SkipNode ! _quoted_string_re = re.compile(r'\"[^\"]*\"') _short_opt_string_re = re.compile(r'-[a-zA-Z]') --- 143,163 ---- pass ! def visit_field(self, node): ! if isinstance(node.parent, nodes.docinfo): ! name = node[0].astext().lower().replace(" ","") ! if name == "moduleauthor": ! (ename, email) = rfc822.parseaddr(node[1].astext()) ! self.docinfo["moduleauthor"] = ename ! self.docinfo["moduleauthoremail"] = email ! elif name in ("author", "sectionauthor") : ! (ename, email) = rfc822.parseaddr(node[1].astext()) ! self.docinfo["sectionauthor"] = ename ! self.docinfo["sectionauthoremail"] = email ! else: ! if name == "module": ! self.set_label_prefix(node[1].astext()) ! self.docinfo[name] = node[1].astext() ! raise nodes.SkipNode ! _quoted_string_re = re.compile(r'\"[^\"]*\"') _short_opt_string_re = re.compile(r'-[a-zA-Z]') *************** *** 148,152 **** assert isinstance(node[0], nodes.Text) text = node[0].data - #### text = re.sub(r'optik(\.[a-z]+)?\.', 'optparse.', text) if self.in_title: cmd = None --- 170,173 ---- *************** *** 172,175 **** --- 193,283 ---- self.body.append('\\%s{' % cmd) + # use topics for special environments + def visit_topic(self, node): + classes = node.get('classes', ['topic', ]) + if classes[0] in ('datadesc', 'datadescni', 'excdesc', 'classdesc*', + 'csimplemacrodesc', 'ctypedesc', 'memberdesc', + 'memberdescni', 'cvardesc', 'excclassdesc', + 'funcdesc', 'funcdescni', 'methoddesc', + 'methoddescni', 'cmemberdesc', 'classdesc', + 'cfuncdesc'): + self.body.append('\n\\begin{%s}' % classes[0]) + self.context.append('\\end{%s}\n' % classes[0]) + self.in_anydesc = classes[0] + else: + self.context.append('') + + def depart_topic(self, node): + self.in_anydesc = False + self.body.append(self.context.pop()) + + # use definition lists for special environments + # + # definition_list + # defintion_list_item + # term + # classifier + # definition + # paragraph ? + def visit_definition_list(self, node): + pass + + def depart_definition_list(self, node): + pass + + def visit_definition_list_item(self, node): + self._dl_term = [] + + def depart_definition_list_item(self, node): + try: + self.body.append(self.context.pop()) + except: + self.body.append("% WARN definition list without classifier\n") + + + def visit_term(self, node): + self._dl_term.append(node.astext()) + raise nodes.SkipNode + + def depart_term(self, node): + pass + + def visit_classifier(self, node): + # TODO here it should be decided if it is latex or python + classifier = node.astext() + + if classifier in ('datadesc', 'datadescni', 'excdesc', 'classdesc*', + 'csimplemacrodesc', 'ctypedesc', 'memberdesc', + 'memberdescni', 'cvardesc', 'excclassdesc', + 'funcdesc', 'funcdescni', 'methoddesc', + 'methoddescni', 'cmemberdesc', 'classdesc', + 'cfuncdesc'): + pass + else: + classifier = 'datadescni' + self.body.append('\n\\begin{%s}' % classifier) + self.in_anydesc = classifier + self.body.append(self.anydesc_title(self._dl_term.pop())) + self.context.append('\\end{%s}\n' % classifier) + self.in_anydesc = None + raise nodes.SkipNode + + def depart_classifier(self, node): + pass + + def visit_definition(self, node): + if len(self._dl_term)>0: + # no classifier, fake it (maybe make a plain latex description). + classifier = 'datadescni' + self.body.append('\n\\begin{%s}' % classifier) + self.in_anydesc = classifier + self.body.append(self.anydesc_title(self._dl_term.pop())) + self.context.append('\\end{%s}\n' % classifier) + self.in_anydesc = None + + def depart_definition(self, node): + pass + + def depart_literal(self, node): if not self.in_title: *************** *** 185,193 **** self.body.append("\n\\end{verbatim}\n") def visit_title(self, node): title = node.astext() title = self.remap_title.get(title, title) label = self.generate_section_label(title) - #print "%s -> %s" % (title, label) section_name = self.d_class.section(self.section_level + 1) self.body.append("\n\n\\%s{" % section_name) --- 293,318 ---- self.body.append("\n\\end{verbatim}\n") + def anydesc_title(self, title): + """Returns the title for xxxdesc environments.""" + if self.in_anydesc in ('ctypedesc','memberdesc','memberdescni',): + # TODO [tag_or_type] {name} + return '%s' % title + elif self.in_anydesc in ('cvardesc','excclassdesc', + 'funcdesc','funcdescni'): + # "funcname(arguments)" to "{funcname}{arguments}" + # "funcname([arguments])" to "{funcname}{\optional{arguments}}" + t = '{'+title.replace('(','}{').replace(')','}') + return t.replace('[','\\optional{').replace(']','}') + # 'datadesc','datadescni', 'excdesc','classdesc*','csimplemacrodesc' + return "{%s}" % title + def visit_title(self, node): title = node.astext() + if self.in_anydesc: + self.body.append(self.anydesc_title(title)) + raise nodes.SkipNode title = self.remap_title.get(title, title) + # TODO label_prefix might not be set yet. label = self.generate_section_label(title) section_name = self.d_class.section(self.section_level + 1) self.body.append("\n\n\\%s{" % section_name) *************** *** 198,202 **** self.in_title = False self.body.append(self.context.pop()) ! def visit_target(self, node): pass --- 323,327 ---- self.in_title = False self.body.append(self.context.pop()) ! def visit_target(self, node): pass *************** *** 205,221 **** pass ! def bookmark(self, node): ! pass ! ! def visit_definition(self, node): ! pass ! ! def depart_definition(self, node): ! pass ! ! def visit_definition_list_item(self, node): ! pass ! def depart_definition_list_item(self, node): pass --- 330,347 ---- pass ! def visit_admonition(self, node, name=''): ! self.admonition_stack.append(name) ! if name in ('note', 'warning'): ! self.body.append('\\begin{notice}[%s]' % name) ! else: ! LaTeXTranslator.visit_admonition(self, node, name) ! def depart_admonition(self, node=None): ! name = self.admonition_stack.pop() ! if name=="note": ! self.body.append('\\end{notice}\n') ! else: ! LaTeXTranslator.depart_admonition(self, node) ! def bookmark(self, node): pass *************** *** 224,228 **** refuri = node['refuri'] basename = os.path.splitext(refuri)[0] ! label = "optparse-" + self.refuri_override.get(basename, basename) print "got refuri=%r, label=%r" % (refuri, label) elif node.has_key('refid'): --- 350,354 ---- refuri = node['refuri'] basename = os.path.splitext(refuri)[0] ! label = self.label_prefix + "-" + self.refuri_override.get(basename, basename) print "got refuri=%r, label=%r" % (refuri, label) elif node.has_key('refid'): *************** *** 231,235 **** else: print "warning: unhandled reference: node=%r" % node ! LaTeXTranslator.visit_reference(self, node) self.body.append("section~\\ref{%s}, " % label) --- 357,361 ---- else: print "warning: unhandled reference: node=%r" % node ! LaTeXTranslator.visit_reference(self, node) self.body.append("section~\\ref{%s}, " % label) *************** *** 248,257 **** text = self._quoted_phrase_re.sub(u"\u201C\\1\u201D", text) text = re.sub(r'\bdocument\b', "section", text) - #### text = re.sub(r'optik(\.[a-z]+)?', 'optparse', text) text = self.encode(text) # A couple of transformations are easiest if they go direct # to LaTeX, so do them *after* encode(). - ## text = text.replace("Optik", "\\module{optparse}") text = text.replace("UNIX", "\\UNIX{}") --- 374,381 ---- |
From: Thomas H. <th...@us...> - 2006-05-31 17:54:28
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27917 Removed Files: mkpydoc1.py Log Message: Remove temporary file. --- mkpydoc1.py DELETED --- |
From: Thomas H. <th...@us...> - 2006-05-31 11:50:19
|
Update of /cvsroot/ctypes/ctypes/source/libffi/src/x86 In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv12657 Added Files: ffi_darwin.c Log Message: Merge in changes done in Python trunk, up to svn revision 46409, by bob ippolito and ronald oussuren: enable darwin/x86 support for libffi and hence ctypes (doesn't yet support --enable-universalsdk) --- NEW FILE: ffi_darwin.c --- # ifdef __i386__ /* ----------------------------------------------------------------------- ffi.c - Copyright (c) 1996, 1998, 1999, 2001 Red Hat, Inc. Copyright (c) 2002 Ranjit Mathew Copyright (c) 2002 Bo Thorsen Copyright (c) 2002 Roger Sayle x86 Foreign Function Interface Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------- */ #ifndef __x86_64__ #include <ffi.h> #include <ffi_common.h> #include <stdlib.h> /* ffi_prep_args is called by the assembly routine once stack space has been allocated for the function's arguments */ /*@-exportheader@*/ void ffi_prep_args(char *stack, extended_cif *ecif); static inline int retval_on_stack(ffi_type* tp) { if (tp->type == FFI_TYPE_STRUCT) { int sz = tp->size; if (sz > 8) { return 1; } switch (sz) { case 1: case 2: case 4: case 8: return 0; default: return 1; } } return 0; } void ffi_prep_args(char *stack, extended_cif *ecif) /*@=exportheader@*/ { register unsigned int i; register void **p_argv; register char *argp; register ffi_type **p_arg; argp = stack; if (retval_on_stack(ecif->cif->rtype)) { *(void **) argp = ecif->rvalue; argp += 4; } p_argv = ecif->avalue; for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types; i != 0; i--, p_arg++) { size_t z; /* Align if necessary */ if ((sizeof(int) - 1) & (unsigned) argp) argp = (char *) ALIGN(argp, sizeof(int)); z = (*p_arg)->size; if (z < sizeof(int)) { z = sizeof(int); switch ((*p_arg)->type) { case FFI_TYPE_SINT8: *(signed int *) argp = (signed int)*(SINT8 *)(* p_argv); break; case FFI_TYPE_UINT8: *(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv); break; case FFI_TYPE_SINT16: *(signed int *) argp = (signed int)*(SINT16 *)(* p_argv); break; case FFI_TYPE_UINT16: *(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv); break; case FFI_TYPE_SINT32: *(signed int *) argp = (signed int)*(SINT32 *)(* p_argv); break; case FFI_TYPE_UINT32: *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); break; case FFI_TYPE_STRUCT: *(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv); break; default: FFI_ASSERT(0); } } else { memcpy(argp, *p_argv, z); } p_argv++; argp += z; } return; } /* Perform machine dependent cif processing */ ffi_status ffi_prep_cif_machdep(ffi_cif *cif) { /* Set the return type flag */ switch (cif->rtype->type) { case FFI_TYPE_VOID: #if !defined(X86_WIN32) case FFI_TYPE_STRUCT: #endif case FFI_TYPE_SINT64: case FFI_TYPE_FLOAT: case FFI_TYPE_DOUBLE: case FFI_TYPE_LONGDOUBLE: cif->flags = (unsigned) cif->rtype->type; break; case FFI_TYPE_UINT64: cif->flags = FFI_TYPE_SINT64; break; #if defined X86_WIN32 case FFI_TYPE_STRUCT: if (cif->rtype->size == 1) { cif->flags = FFI_TYPE_SINT8; /* same as char size */ } else if (cif->rtype->size == 2) { cif->flags = FFI_TYPE_SINT16; /* same as short size */ } else if (cif->rtype->size == 4) { cif->flags = FFI_TYPE_INT; /* same as int type */ } else if (cif->rtype->size == 8) { cif->flags = FFI_TYPE_SINT64; /* same as int64 type */ } else { cif->flags = FFI_TYPE_STRUCT; } break; #endif default: cif->flags = FFI_TYPE_INT; break; } /* Darwin: The stack needs to be aligned to a multiple of 16 bytes */ #if 0 cif->bytes = (cif->bytes + 15) & ~0xF; #endif return FFI_OK; } /*@-declundef@*/ /*@-exportheader@*/ extern void ffi_call_SYSV(void (*)(char *, extended_cif *), /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, void (*fn)(void)); /*@=declundef@*/ /*@=exportheader@*/ #ifdef X86_WIN32 /*@-declundef@*/ /*@-exportheader@*/ extern void ffi_call_STDCALL(void (*)(char *, extended_cif *), /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, void (*fn)(void)); /*@=declundef@*/ /*@=exportheader@*/ #endif /* X86_WIN32 */ void ffi_call(/*@dependent@*/ ffi_cif *cif, void (*fn)(), /*@out@*/ void *rvalue, /*@dependent@*/ void **avalue) { extended_cif ecif; int flags; ecif.cif = cif; ecif.avalue = avalue; /* If the return value is a struct and we don't have a return */ /* value address then we need to make one */ if ((rvalue == NULL) && retval_on_stack(cif->rtype)) { /*@-sysunrecog@*/ ecif.rvalue = alloca(cif->rtype->size); /*@=sysunrecog@*/ } else ecif.rvalue = rvalue; flags = cif->flags; if (flags == FFI_TYPE_STRUCT) { if (cif->rtype->size == 8) { flags = FFI_TYPE_SINT64; } else if (cif->rtype->size == 4) { flags = FFI_TYPE_INT; } else if (cif->rtype->size == 2) { flags = FFI_TYPE_INT; } else if (cif->rtype->size == 1) { flags = FFI_TYPE_INT; } } switch (cif->abi) { case FFI_SYSV: /*@-usedef@*/ /* To avoid changing the assembly code make sure the size of the argument * block is a multiple of 16. Then add 8 to compensate for local variables * in ffi_call_SYSV. */ ffi_call_SYSV(ffi_prep_args, &ecif, ALIGN(cif->bytes, 16) +8, flags, ecif.rvalue, fn); /*@=usedef@*/ break; #ifdef X86_WIN32 case FFI_STDCALL: /*@-usedef@*/ ffi_call_STDCALL(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue, fn); /*@=usedef@*/ break; #endif /* X86_WIN32 */ default: FFI_ASSERT(0); break; } } /** private members **/ static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, void** args, ffi_cif* cif); static void ffi_closure_SYSV (ffi_closure *) __attribute__ ((regparm(1))); #if !FFI_NO_RAW_API static void ffi_closure_raw_SYSV (ffi_raw_closure *) __attribute__ ((regparm(1))); #endif /* This function is jumped to by the trampoline */ static void ffi_closure_SYSV (closure) ffi_closure *closure; { // this is our return value storage long double res; // our various things... ffi_cif *cif; void **arg_area; unsigned short rtype; void *resp = (void*)&res; void *args = __builtin_dwarf_cfa (); cif = closure->cif; arg_area = (void**) alloca (cif->nargs * sizeof (void*)); /* this call will initialize ARG_AREA, such that each * element in that array points to the corresponding * value on the stack; and if the function returns * a structure, it will re-set RESP to point to the * structure return address. */ ffi_prep_incoming_args_SYSV(args, (void**)&resp, arg_area, cif); (closure->fun) (cif, resp, arg_area, closure->user_data); rtype = cif->flags; if (!retval_on_stack(cif->rtype) && cif->flags == FFI_TYPE_STRUCT) { if (cif->rtype->size == 8) { rtype = FFI_TYPE_SINT64; } else { rtype = FFI_TYPE_INT; } } /* now, do a generic return based on the value of rtype */ if (rtype == FFI_TYPE_INT) { asm ("movl (%0),%%eax" : : "r" (resp) : "eax"); } else if (rtype == FFI_TYPE_FLOAT) { asm ("flds (%0)" : : "r" (resp) : "st" ); } else if (rtype == FFI_TYPE_DOUBLE) { asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" ); } else if (rtype == FFI_TYPE_LONGDOUBLE) { asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" ); } else if (rtype == FFI_TYPE_SINT64) { asm ("movl 0(%0),%%eax;" "movl 4(%0),%%edx" : : "r"(resp) : "eax", "edx"); } #ifdef X86_WIN32 else if (rtype == FFI_TYPE_SINT8) /* 1-byte struct */ { asm ("movsbl (%0),%%eax" : : "r" (resp) : "eax"); } else if (rtype == FFI_TYPE_SINT16) /* 2-bytes struct */ { asm ("movswl (%0),%%eax" : : "r" (resp) : "eax"); } #endif } /*@-exportheader@*/ static void ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue, ffi_cif *cif) /*@=exportheader@*/ { register unsigned int i; register void **p_argv; register char *argp; register ffi_type **p_arg; argp = stack; if (retval_on_stack(cif->rtype)) { *rvalue = *(void **) argp; argp += 4; } p_argv = avalue; for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++) { size_t z; /* Align if necessary */ if ((sizeof(int) - 1) & (unsigned) argp) { argp = (char *) ALIGN(argp, sizeof(int)); } z = (*p_arg)->size; /* because we're little endian, this is what it turns into. */ *p_argv = (void*) argp; p_argv++; argp += z; } return; } /* How to make a trampoline. Derived from gcc/config/i386/i386.c. */ #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \ ({ unsigned char *__tramp = (unsigned char*)(TRAMP); \ unsigned int __fun = (unsigned int)(FUN); \ unsigned int __ctx = (unsigned int)(CTX); \ unsigned int __dis = __fun - ((unsigned int) __tramp + FFI_TRAMPOLINE_SIZE); \ *(unsigned char*) &__tramp[0] = 0xb8; \ *(unsigned int*) &__tramp[1] = __ctx; /* movl __ctx, %eax */ \ *(unsigned char *) &__tramp[5] = 0xe9; \ *(unsigned int*) &__tramp[6] = __dis; /* jmp __fun */ \ }) /* the cif must already be prep'ed */ ffi_status ffi_prep_closure (ffi_closure* closure, ffi_cif* cif, void (*fun)(ffi_cif*,void*,void**,void*), void *user_data) { FFI_ASSERT (cif->abi == FFI_SYSV); FFI_INIT_TRAMPOLINE (&closure->tramp[0], \ &ffi_closure_SYSV, \ (void*)closure); closure->cif = cif; closure->user_data = user_data; closure->fun = fun; return FFI_OK; } /* ------- Native raw API support -------------------------------- */ #if !FFI_NO_RAW_API static void ffi_closure_raw_SYSV (closure) ffi_raw_closure *closure; { // this is our return value storage long double res; // our various things... ffi_raw *raw_args; ffi_cif *cif; unsigned short rtype; void *resp = (void*)&res; /* get the cif */ cif = closure->cif; /* the SYSV/X86 abi matches the RAW API exactly, well.. almost */ raw_args = (ffi_raw*) __builtin_dwarf_cfa (); (closure->fun) (cif, resp, raw_args, closure->user_data); rtype = cif->flags; /* now, do a generic return based on the value of rtype */ if (rtype == FFI_TYPE_INT) { asm ("movl (%0),%%eax" : : "r" (resp) : "eax"); } else if (rtype == FFI_TYPE_FLOAT) { asm ("flds (%0)" : : "r" (resp) : "st" ); } else if (rtype == FFI_TYPE_DOUBLE) { asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" ); } else if (rtype == FFI_TYPE_LONGDOUBLE) { asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" ); } else if (rtype == FFI_TYPE_SINT64) { asm ("movl 0(%0),%%eax; movl 4(%0),%%edx" : : "r"(resp) : "eax", "edx"); } } ffi_status ffi_prep_raw_closure (ffi_raw_closure* closure, ffi_cif* cif, void (*fun)(ffi_cif*,void*,ffi_raw*,void*), void *user_data) { int i; FFI_ASSERT (cif->abi == FFI_SYSV); // we currently don't support certain kinds of arguments for raw // closures. This should be implemented by a separate assembly language // routine, since it would require argument processing, something we // don't do now for performance. for (i = cif->nargs-1; i >= 0; i--) { FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_STRUCT); FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE); } FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV, (void*)closure); closure->cif = cif; closure->user_data = user_data; closure->fun = fun; return FFI_OK; } static void ffi_prep_args_raw(char *stack, extended_cif *ecif) { memcpy (stack, ecif->avalue, ecif->cif->bytes); } /* we borrow this routine from libffi (it must be changed, though, to * actually call the function passed in the first argument. as of * libffi-1.20, this is not the case.) */ extern void ffi_call_SYSV(void (*)(char *, extended_cif *), /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, void (*fn)()); #ifdef X86_WIN32 extern void ffi_call_STDCALL(void (*)(char *, extended_cif *), /*@out@*/ extended_cif *, unsigned, unsigned, /*@out@*/ unsigned *, void (*fn)()); #endif /* X86_WIN32 */ void ffi_raw_call(/*@dependent@*/ ffi_cif *cif, void (*fn)(), /*@out@*/ void *rvalue, /*@dependent@*/ ffi_raw *fake_avalue) { extended_cif ecif; void **avalue = (void **)fake_avalue; ecif.cif = cif; ecif.avalue = avalue; /* If the return value is a struct and we don't have a return */ /* value address then we need to make one */ if ((rvalue == NULL) && retval_on_stack(cif->rtype)) { /*@-sysunrecog@*/ ecif.rvalue = alloca(cif->rtype->size); /*@=sysunrecog@*/ } else ecif.rvalue = rvalue; switch (cif->abi) { case FFI_SYSV: /*@-usedef@*/ ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags, ecif.rvalue, fn); /*@=usedef@*/ break; #ifdef X86_WIN32 case FFI_STDCALL: /*@-usedef@*/ ffi_call_STDCALL(ffi_prep_args_raw, &ecif, cif->bytes, cif->flags, ecif.rvalue, fn); /*@=usedef@*/ break; #endif /* X86_WIN32 */ default: FFI_ASSERT(0); break; } } #endif #endif /* __x86_64__ */ #endif /* __i386__ */ |
From: Thomas H. <th...@us...> - 2006-05-31 11:35:13
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv6835 Modified Files: _ctypes.c Log Message: PyTuple_Pack does not exist in Python 2.3. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.332 retrieving revision 1.333 diff -C2 -d -r1.332 -r1.333 *** _ctypes.c 31 May 2006 10:27:47 -0000 1.332 --- _ctypes.c 31 May 2006 11:35:06 -0000 1.333 *************** *** 2228,2232 **** b_objects list PLUS the array itself, and return that! */ ! return PyTuple_Pack(2, keep, value); } PyErr_Format(PyExc_TypeError, --- 2228,2232 ---- b_objects list PLUS the array itself, and return that! */ ! return Py_BuildValue("(OO)", keep, value); } PyErr_Format(PyExc_TypeError, |
From: Thomas H. <th...@us...> - 2006-05-31 11:27:05
|
Update of /cvsroot/ctypes/ctypes/source/libffi/src/x86 In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3423 Modified Files: ffitarget.h Added Files: darwin.S Log Message: Merge in changes done in Python trunk, up to svn revision 46409, by bob ippolito and ronald oussuren: enable darwin/x86 support for libffi and hence ctypes (doesn't yet support --enable-universalsdk) --- NEW FILE: darwin.S --- #ifdef __i386__ /* ----------------------------------------------------------------------- darwin.S - Copyright (c) 1996, 1998, 2001, 2002, 2003 Red Hat, Inc. X86 Foreign Function Interface Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------- */ /* * This file is based on sysv.S and then hacked up by Ronald who hasn't done * assembly programming in 8 years. */ #ifndef __x86_64__ #define LIBFFI_ASM #include <fficonfig.h> #include <ffi.h> .text .globl _ffi_prep_args .align 4 .globl _ffi_call_SYSV _ffi_call_SYSV: .LFB1: pushl %ebp .LCFI0: movl %esp,%ebp .LCFI1: /* Make room for all of the new args. */ movl 16(%ebp),%ecx subl %ecx,%esp movl %esp,%eax /* Place all of the ffi_prep_args in position */ pushl 12(%ebp) pushl %eax call *8(%ebp) /* Return stack to previous state and call the function */ addl $8,%esp call *28(%ebp) /* Remove the space we pushed for the args */ movl 16(%ebp),%ecx addl %ecx,%esp /* Load %ecx with the return type code */ movl 20(%ebp),%ecx /* If the return value pointer is NULL, assume no return value. */ cmpl $0,24(%ebp) jne retint /* Even if there is no space for the return value, we are obliged to handle floating-point values. */ cmpl $FFI_TYPE_FLOAT,%ecx jne noretval fstp %st(0) jmp epilogue retint: cmpl $FFI_TYPE_INT,%ecx jne retfloat /* Load %ecx with the pointer to storage for the return value */ movl 24(%ebp),%ecx movl %eax,0(%ecx) jmp epilogue retfloat: cmpl $FFI_TYPE_FLOAT,%ecx jne retdouble /* Load %ecx with the pointer to storage for the return value */ movl 24(%ebp),%ecx fstps (%ecx) jmp epilogue retdouble: cmpl $FFI_TYPE_DOUBLE,%ecx jne retlongdouble /* Load %ecx with the pointer to storage for the return value */ movl 24(%ebp),%ecx fstpl (%ecx) jmp epilogue retlongdouble: cmpl $FFI_TYPE_LONGDOUBLE,%ecx jne retint64 /* Load %ecx with the pointer to storage for the return value */ movl 24(%ebp),%ecx fstpt (%ecx) jmp epilogue retint64: cmpl $FFI_TYPE_SINT64,%ecx jne retstruct /* Load %ecx with the pointer to storage for the return value */ movl 24(%ebp),%ecx movl %eax,0(%ecx) movl %edx,4(%ecx) retstruct: /* Nothing to do! */ noretval: epilogue: movl %ebp,%esp popl %ebp ret .LFE1: .ffi_call_SYSV_end: #if 0 .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV #endif #if 0 .section .eh_frame,EH_FRAME_FLAGS,@progbits .Lframe1: .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */ .LSCIE1: .long 0x0 /* CIE Identifier Tag */ .byte 0x1 /* CIE Version */ #ifdef __PIC__ .ascii "zR\0" /* CIE Augmentation */ #else .ascii "\0" /* CIE Augmentation */ #endif .byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */ .byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */ .byte 0x8 /* CIE RA Column */ #ifdef __PIC__ .byte 0x1 /* .uleb128 0x1; Augmentation size */ .byte 0x1b /* FDE Encoding (pcrel sdata4) */ #endif .byte 0xc /* DW_CFA_def_cfa */ .byte 0x4 /* .uleb128 0x4 */ .byte 0x4 /* .uleb128 0x4 */ .byte 0x88 /* DW_CFA_offset, column 0x8 */ .byte 0x1 /* .uleb128 0x1 */ .align 4 .LECIE1: .LSFDE1: .long .LEFDE1-.LASFDE1 /* FDE Length */ .LASFDE1: .long .LASFDE1-.Lframe1 /* FDE CIE offset */ #ifdef __PIC__ .long .LFB1-. /* FDE initial location */ #else .long .LFB1 /* FDE initial location */ #endif .long .LFE1-.LFB1 /* FDE address range */ #ifdef __PIC__ .byte 0x0 /* .uleb128 0x0; Augmentation size */ #endif .byte 0x4 /* DW_CFA_advance_loc4 */ .long .LCFI0-.LFB1 .byte 0xe /* DW_CFA_def_cfa_offset */ .byte 0x8 /* .uleb128 0x8 */ .byte 0x85 /* DW_CFA_offset, column 0x5 */ .byte 0x2 /* .uleb128 0x2 */ .byte 0x4 /* DW_CFA_advance_loc4 */ .long .LCFI1-.LCFI0 .byte 0xd /* DW_CFA_def_cfa_register */ .byte 0x5 /* .uleb128 0x5 */ .align 4 .LEFDE1: #endif #endif /* ifndef __x86_64__ */ #endif /* defined __i386__ */ #ifdef __i386__ /* ----------------------------------------------------------------------- darwin.S - Copyright (c) 1996, 1998, 2001, 2002, 2003 Red Hat, Inc. X86 Foreign Function Interface Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------- */ /* * This file is based on sysv.S and then hacked up by Ronald who hasn't done * assembly programming in 8 years. */ #ifndef __x86_64__ #define LIBFFI_ASM #include <fficonfig.h> #include <ffi.h> .text .globl _ffi_prep_args .align 4 .globl _ffi_call_SYSV _ffi_call_SYSV: .LFB1: pushl %ebp .LCFI0: movl %esp,%ebp .LCFI1: /* Make room for all of the new args. */ movl 16(%ebp),%ecx subl %ecx,%esp movl %esp,%eax /* Place all of the ffi_prep_args in position */ pushl 12(%ebp) pushl %eax call *8(%ebp) /* Return stack to previous state and call the function */ addl $8,%esp call *28(%ebp) /* Remove the space we pushed for the args */ movl 16(%ebp),%ecx addl %ecx,%esp /* Load %ecx with the return type code */ movl 20(%ebp),%ecx /* If the return value pointer is NULL, assume no return value. */ cmpl $0,24(%ebp) jne retint /* Even if there is no space for the return value, we are obliged to handle floating-point values. */ cmpl $FFI_TYPE_FLOAT,%ecx jne noretval fstp %st(0) jmp epilogue retint: cmpl $FFI_TYPE_INT,%ecx jne retfloat /* Load %ecx with the pointer to storage for the return value */ movl 24(%ebp),%ecx movl %eax,0(%ecx) jmp epilogue retfloat: cmpl $FFI_TYPE_FLOAT,%ecx jne retdouble /* Load %ecx with the pointer to storage for the return value */ movl 24(%ebp),%ecx fstps (%ecx) jmp epilogue retdouble: cmpl $FFI_TYPE_DOUBLE,%ecx jne retlongdouble /* Load %ecx with the pointer to storage for the return value */ movl 24(%ebp),%ecx fstpl (%ecx) jmp epilogue retlongdouble: cmpl $FFI_TYPE_LONGDOUBLE,%ecx jne retint64 /* Load %ecx with the pointer to storage for the return value */ movl 24(%ebp),%ecx fstpt (%ecx) jmp epilogue retint64: cmpl $FFI_TYPE_SINT64,%ecx jne retstruct /* Load %ecx with the pointer to storage for the return value */ movl 24(%ebp),%ecx movl %eax,0(%ecx) movl %edx,4(%ecx) retstruct: /* Nothing to do! */ noretval: epilogue: movl %ebp,%esp popl %ebp ret .LFE1: .ffi_call_SYSV_end: #if 0 .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV #endif #if 0 .section .eh_frame,EH_FRAME_FLAGS,@progbits .Lframe1: .long .LECIE1-.LSCIE1 /* Length of Common Information Entry */ .LSCIE1: .long 0x0 /* CIE Identifier Tag */ .byte 0x1 /* CIE Version */ #ifdef __PIC__ .ascii "zR\0" /* CIE Augmentation */ #else .ascii "\0" /* CIE Augmentation */ #endif .byte 0x1 /* .uleb128 0x1; CIE Code Alignment Factor */ .byte 0x7c /* .sleb128 -4; CIE Data Alignment Factor */ .byte 0x8 /* CIE RA Column */ #ifdef __PIC__ .byte 0x1 /* .uleb128 0x1; Augmentation size */ .byte 0x1b /* FDE Encoding (pcrel sdata4) */ #endif .byte 0xc /* DW_CFA_def_cfa */ .byte 0x4 /* .uleb128 0x4 */ .byte 0x4 /* .uleb128 0x4 */ .byte 0x88 /* DW_CFA_offset, column 0x8 */ .byte 0x1 /* .uleb128 0x1 */ .align 4 .LECIE1: .LSFDE1: .long .LEFDE1-.LASFDE1 /* FDE Length */ .LASFDE1: .long .LASFDE1-.Lframe1 /* FDE CIE offset */ #ifdef __PIC__ .long .LFB1-. /* FDE initial location */ #else .long .LFB1 /* FDE initial location */ #endif .long .LFE1-.LFB1 /* FDE address range */ #ifdef __PIC__ .byte 0x0 /* .uleb128 0x0; Augmentation size */ #endif .byte 0x4 /* DW_CFA_advance_loc4 */ .long .LCFI0-.LFB1 .byte 0xe /* DW_CFA_def_cfa_offset */ .byte 0x8 /* .uleb128 0x8 */ .byte 0x85 /* DW_CFA_offset, column 0x5 */ .byte 0x2 /* .uleb128 0x2 */ .byte 0x4 /* DW_CFA_advance_loc4 */ .long .LCFI1-.LCFI0 .byte 0xd /* DW_CFA_def_cfa_register */ .byte 0x5 /* .uleb128 0x5 */ .align 4 .LEFDE1: #endif #endif /* ifndef __x86_64__ */ #endif /* defined __i386__ */ Index: ffitarget.h =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/src/x86/ffitarget.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ffitarget.h 3 Mar 2006 20:26:09 -0000 1.2 --- ffitarget.h 31 May 2006 11:27:01 -0000 1.3 *************** *** 52,56 **** /* ---- Intel x86 and AMD x86-64 - */ ! #if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__)) FFI_SYSV, FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */ --- 52,56 ---- /* ---- Intel x86 and AMD x86-64 - */ ! #if !defined(X86_WIN32) && (defined(__i386__) || defined(__x86_64__)) FFI_SYSV, FFI_UNIX64, /* Unix variants all use the same ABI for x86-64 */ |
From: Thomas H. <th...@us...> - 2006-05-31 11:26:59
|
Update of /cvsroot/ctypes/ctypes/source/libffi/src/powerpc In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3404 Modified Files: ffi_darwin.c darwin_closure.S darwin.S Log Message: Merge in changes done in Python trunk, up to svn revision 46409, by bob ippolito and ronald oussuren: enable darwin/x86 support for libffi and hence ctypes (doesn't yet support --enable-universalsdk) Index: darwin.S =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/src/powerpc/darwin.S,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** darwin.S 3 Mar 2006 20:25:31 -0000 1.2 --- darwin.S 31 May 2006 11:26:56 -0000 1.3 *************** *** 1,2 **** --- 1,3 ---- + #ifdef __ppc__ /* ----------------------------------------------------------------------- darwin.S - Copyright (c) 2000 John Hornkvist *************** *** 244,245 **** --- 245,247 ---- LLFB0$non_lazy_ptr: .g_long LFB0 + #endif Index: darwin_closure.S =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/src/powerpc/darwin_closure.S,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** darwin_closure.S 5 Apr 2006 12:47:43 -0000 1.3 --- darwin_closure.S 31 May 2006 11:26:56 -0000 1.4 *************** *** 1,2 **** --- 1,3 ---- + #ifdef __ppc__ /* ----------------------------------------------------------------------- darwin_closure.S - Copyright (c) 2002, 2003, 2004, Free Software Foundation, *************** *** 316,317 **** --- 317,319 ---- LLFB1$non_lazy_ptr: .g_long LFB1 + #endif Index: ffi_darwin.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/src/powerpc/ffi_darwin.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ffi_darwin.c 25 Apr 2006 18:29:36 -0000 1.3 --- ffi_darwin.c 31 May 2006 11:26:56 -0000 1.4 *************** *** 1,2 **** --- 1,3 ---- + #ifdef __ppc__ /* ----------------------------------------------------------------------- ffi.c - Copyright (c) 1998 Geoffrey Keating *************** *** 768,769 **** --- 769,771 ---- return cif->rtype->type; } + #endif |
From: Thomas H. <th...@us...> - 2006-05-31 11:26:54
|
Update of /cvsroot/ctypes/ctypes/source/libffi/src/darwin In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3382 Added Files: ffitarget.h Log Message: Merge in changes done in Python trunk, up to svn revision 46409, by bob ippolito and ronald oussuren: enable darwin/x86 support for libffi and hence ctypes (doesn't yet support --enable-universalsdk) --- NEW FILE: ffitarget.h --- /* * This file is for MacOSX only. Dispatch to the right architecture include * file based on the current archictecture (instead of relying on a symlink * created by configure). This makes is possible to build a univeral binary * of ctypes in one go. */ #if defined(__i386__) #ifndef X86_DARWIN #define X86_DARWIN #endif #undef POWERPC_DARWIN #include "../src/x86/ffitarget.h" #elif defined(__ppc__) #ifndef POWERPC_DARWIN #define POWERPC_DARWIN #endif #undef X86_DARWIN #include "../src/powerpc/ffitarget.h" #endif |
From: Thomas H. <th...@us...> - 2006-05-31 11:26:47
|
Update of /cvsroot/ctypes/ctypes/source/libffi/src In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3364 Modified Files: prep_cif.c Log Message: Merge in changes done in Python trunk, up to svn revision 46409, by bob ippolito and ronald oussuren: enable darwin/x86 support for libffi and hence ctypes (doesn't yet support --enable-universalsdk) Index: prep_cif.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/src/prep_cif.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** prep_cif.c 3 Mar 2006 20:24:20 -0000 1.2 --- prep_cif.c 31 May 2006 11:26:44 -0000 1.3 *************** *** 56,59 **** --- 56,76 ---- FFI_ASSERT_VALID_TYPE(*ptr); + #ifdef POWERPC_DARWIN + { + int curalign; + + curalign = (*ptr)->alignment; + if (ptr != &(arg->elements[0])) { + if (curalign > 4 && curalign != 16) { + curalign = 4; + } + } + arg->size = ALIGN(arg->size, curalign); + arg->size += (*ptr)->size; + + arg->alignment = (arg->alignment > curalign) ? + arg->alignment : curalign; + } + #else arg->size = ALIGN(arg->size, (*ptr)->alignment); arg->size += (*ptr)->size; *************** *** 61,64 **** --- 78,82 ---- arg->alignment = (arg->alignment > (*ptr)->alignment) ? arg->alignment : (*ptr)->alignment; + #endif ptr++; *************** *** 90,93 **** --- 108,124 ---- machine dependent routine. */ + #ifdef X86_DARWIN + static inline int struct_on_stack(int size) + { + if (size > 8) return 1; + /* This is not what the ABI says, but is what is really implemented */ + switch (size) { + case 1: case 2: case 4: case 8: return 0; + } + return 1; + } + #endif + + ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif, ffi_abi abi, unsigned int nargs, *************** *** 125,128 **** --- 156,163 ---- && (cif->abi != FFI_V9 || cif->rtype->size > 32) #endif + #ifdef X86_DARWIN + + && (struct_on_stack(cif->rtype->size)) + #endif ) bytes = STACK_ARG_SIZE(sizeof(void*)); *************** *** 140,144 **** FFI_ASSERT_VALID_TYPE(*ptr); ! #if !defined __x86_64__ && !defined S390 && !defined PA #ifdef SPARC if (((*ptr)->type == FFI_TYPE_STRUCT --- 175,188 ---- FFI_ASSERT_VALID_TYPE(*ptr); ! #if defined(X86_DARWIN) ! { ! int align = (*ptr)->alignment; ! if (align > 4) align = 4; ! if ((align - 1) & bytes) ! bytes = ALIGN(bytes, align); ! bytes += STACK_ARG_SIZE((*ptr)->size); ! } ! ! #elif !defined __x86_64__ && !defined S390 && !defined PA #ifdef SPARC if (((*ptr)->type == FFI_TYPE_STRUCT |
From: Thomas H. <th...@us...> - 2006-05-31 11:26:42
|
Update of /cvsroot/ctypes/ctypes/source/libffi In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3332 Modified Files: fficonfig.py.in fficonfig.h.in configure.ac configure Log Message: Merge in changes done in Python trunk, up to svn revision 46409, by bob ippolito and ronald oussuren: enable darwin/x86 support for libffi and hence ctypes (doesn't yet support --enable-universalsdk) Index: fficonfig.h.in =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/fficonfig.h.in,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fficonfig.h.in 3 Mar 2006 20:19:51 -0000 1.2 --- fficonfig.h.in 31 May 2006 11:26:40 -0000 1.3 *************** *** 115,121 **** #undef STDC_HEADERS /* Define to 1 if your processor stores words with the most significant byte ! first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN --- 115,134 ---- #undef STDC_HEADERS + /* Define to 1 if your processor stores words with the most significant byte ! first (like Motorola and SPARC, unlike Intel and VAX). ! ! The block below does compile-time checking for endianness on platforms ! that use GCC and therefore allows compiling fat binaries on OSX by using ! '-arch ppc -arch i386' as the compile flags. The phrasing was choosen ! such that the configure-result is used on systems that don't use GCC. ! */ ! #ifdef __BIG_ENDIAN__ ! #define WORDS_BIGENDIAN 1 ! #else ! #ifndef __LITTLE_ENDIAN__ #undef WORDS_BIGENDIAN + #endif + #endif Index: configure.ac =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/configure.ac,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** configure.ac 5 Apr 2006 12:43:24 -0000 1.3 --- configure.ac 31 May 2006 11:26:40 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- TARGETDIR="unknown" case "$host" in + i*86-*-darwin*) TARGET=X86_DARWIN; TARGETDIR=x86;; i*86-*-linux*) TARGET=X86; TARGETDIR=x86;; i*86-*-gnu*) TARGET=X86; TARGETDIR=x86;; *************** *** 94,97 **** --- 95,116 ---- AC_C_BIGENDIAN + AH_VERBATIM([WORDS_BIGENDIAN], + [ + /* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). + + The block below does compile-time checking for endianness on platforms + that use GCC and therefore allows compiling fat binaries on OSX by using + '-arch ppc -arch i386' as the compile flags. The phrasing was choosen + such that the configure-result is used on systems that don't use GCC. + */ + #ifdef __BIG_ENDIAN__ + #define WORDS_BIGENDIAN 1 + #else + #ifndef __LITTLE_ENDIAN__ + #undef WORDS_BIGENDIAN + #endif + #endif]) + if test x$TARGET = xSPARC; then *************** *** 195,199 **** ], [TARGETDIR="$TARGETDIR"]) ! AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h) AC_CONFIG_LINKS(include/ffi_common.h:include/ffi_common.h) --- 214,226 ---- ], [TARGETDIR="$TARGETDIR"]) ! TARGETINCDIR=$TARGETDIR ! case $host in ! *-*-darwin*) ! TARGETINCDIR="darwin" ! ;; ! esac ! ! ! AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h) AC_CONFIG_LINKS(include/ffi_common.h:include/ffi_common.h) Index: configure =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/configure,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** configure 5 Apr 2006 12:43:24 -0000 1.3 --- configure 31 May 2006 11:26:40 -0000 1.4 *************** *** 3484,3487 **** --- 3484,3488 ---- TARGETDIR="unknown" case "$host" in + i*86-*-darwin*) TARGET=X86_DARWIN; TARGETDIR=x86;; i*86-*-linux*) TARGET=X86; TARGETDIR=x86;; i*86-*-gnu*) TARGET=X86; TARGETDIR=x86;; *************** *** 5242,5245 **** --- 5243,5249 ---- + + + if test x$TARGET = xSPARC; then echo "$as_me:$LINENO: checking assembler and linker support unaligned pc related relocs" >&5 *************** *** 5468,5472 **** ! ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETDIR/ffitarget.h" ac_config_links="$ac_config_links include/ffi_common.h:include/ffi_common.h" --- 5472,5484 ---- ! TARGETINCDIR=$TARGETDIR ! case $host in ! *-*-darwin*) ! TARGETINCDIR="darwin" ! ;; ! esac ! ! ! ac_config_links="$ac_config_links include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h" ac_config_links="$ac_config_links include/ffi_common.h:include/ffi_common.h" *************** *** 6015,6019 **** "include/ffi.h" ) CONFIG_FILES="$CONFIG_FILES include/ffi.h" ;; "fficonfig.py" ) CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;; ! "include/ffitarget.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETDIR/ffitarget.h" ;; "include/ffi_common.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;; "include" ) CONFIG_COMMANDS="$CONFIG_COMMANDS include" ;; --- 6027,6031 ---- "include/ffi.h" ) CONFIG_FILES="$CONFIG_FILES include/ffi.h" ;; "fficonfig.py" ) CONFIG_FILES="$CONFIG_FILES fficonfig.py" ;; ! "include/ffitarget.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffitarget.h:src/$TARGETINCDIR/ffitarget.h" ;; "include/ffi_common.h" ) CONFIG_LINKS="$CONFIG_LINKS include/ffi_common.h:include/ffi_common.h" ;; "include" ) CONFIG_COMMANDS="$CONFIG_COMMANDS include" ;; Index: fficonfig.py.in =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/libffi/fficonfig.py.in,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fficonfig.py.in 5 Apr 2006 12:43:24 -0000 1.3 --- fficonfig.py.in 31 May 2006 11:26:40 -0000 1.4 *************** *** 7,10 **** --- 7,11 ---- 'MIPS_LINUX': ['src/mips/ffi.c', 'src/mips/o32.S'], 'X86': ['src/x86/ffi.c', 'src/x86/sysv.S'], + 'X86_DARWIN': ['src/x86/ffi_darwin.c', 'src/x86/darwin.S'], 'X86_WIN32': ['src/x86/ffi.c', 'src/x86/win32.S'], 'SPARC': ['src/sparc/ffi.c', 'src/sparc/v8.S', 'src/sparc/v9.S'], *************** *** 27,30 **** --- 28,42 ---- } + # Build all darwin related files on all supported darwin architectures, this + # makes it easier to build universal binaries. + if 1: + all_darwin = ('X86_DARWIN', 'POWERPC_DARWIN') + all_darwin_files = [] + for pn in all_darwin: + all_darwin_files.extend(ffi_platforms[pn]) + for pn in all_darwin: + ffi_platforms[pn] = all_darwin_files + del all_darwin, all_darwin_files, pn + ffi_srcdir = '@srcdir@' ffi_sources += ffi_platforms['@TARGET@'] |
From: Thomas H. <th...@us...> - 2006-05-31 10:40:57
|
Update of /cvsroot/ctypes/ctypes/source/libffi/src/darwin In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16956/darwin Log Message: Directory /cvsroot/ctypes/ctypes/source/libffi/src/darwin added to the repository |
From: Thomas H. <th...@us...> - 2006-05-31 10:28:07
|
Update of /cvsroot/ctypes/ctypes/source In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv11674 Modified Files: _ctypes.c Log Message: Replace Py_BuildValue("OO") with PyTuple_Pack. Index: _ctypes.c =================================================================== RCS file: /cvsroot/ctypes/ctypes/source/_ctypes.c,v retrieving revision 1.331 retrieving revision 1.332 diff -C2 -d -r1.331 -r1.332 *** _ctypes.c 19 May 2006 20:07:20 -0000 1.331 --- _ctypes.c 31 May 2006 10:27:47 -0000 1.332 *************** *** 2228,2232 **** b_objects list PLUS the array itself, and return that! */ ! return Py_BuildValue("(OO)", keep, value); } PyErr_Format(PyExc_TypeError, --- 2228,2232 ---- b_objects list PLUS the array itself, and return that! */ ! return PyTuple_Pack(2, keep, value); } PyErr_Format(PyExc_TypeError, |
From: Thomas H. <th...@us...> - 2006-05-30 20:07:52
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv22580 Modified Files: reference.txt Log Message: *** empty log message *** Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** reference.txt 30 May 2006 18:03:41 -0000 1.13 --- reference.txt 30 May 2006 20:07:48 -0000 1.14 *************** *** 2,31 **** ================ ! helper functions ! ---------------- ! ``addressof(obj)`` : funcdesc ! Returns the address of the memory buffer as integer. ``obj`` must ! be an instance of a ctypes type. ! ``alignment(obj_or_type)`` : funcdesc ! Returns the alignment requirements of a ctypes type. ! ``obj_or_type`` must be a ctypes type or instance. ! ``ArgumentError()`` : excdesc ! This exception is raised when a foreign function call cannot ! convert one of the passed arguments. ! ``byref(obj)`` : funcdesc ! Returns a light-weight pointer to ``obj``, which must be an ! instance of a ctypes type. The returned object can only be used as ! a foreign function call parameter. It behaves similar to ! ``pointer(obj)``, but the construction is a lot faster. ! ``cast(obj, type)`` : funcdesc ! This function is similar to the cast operator in C. It returns a ! new instance of ``type`` which points to the same memory block as ! ``obj``. ``type`` must be a pointer type, and ``obj`` must be an ! object that can be interpreted as a pointer. ``CFUNCTYPE(restype, *argtypes)`` : funcdesc --- 2,56 ---- ================ ! loading shared libraries ! ------------------------ ! ``LibraryLoader(dlltype)`` : classdesc ! Class which loads shared libraries. ! ``LoadLibrary(name, mode=RTLD_LOCAL, handle=None)`` : methoddesc ! Load a shared library. ! ``CDLL(name, mode=RTLD_LOCAL, handle=None)`` : classdesc* ! XXX ! ``cdll`` : vardesc ! XXX ! ``OleDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc ! XXX ! ! ``oledll`` : vardesc ! XXX ! ! ``py_object`` : classdesc* ! XXX ! ! ``PyDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc ! XXX ! ! ``pydll`` : vardesc ! XXX ! ! ``RTLD_GLOBAL`` : vardesc ! XXX ! ! ``RTLD_LOCAL`` : vardesc ! XXX ! ! ``WinDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc ! XXX ! ! ``windll`` : vardesc ! XXX ! ! foreign functions ! ----------------- ! ! The ultimate goal (so to say) of ``ctypes`` is to call functions in ! shared libraries, aka as foreign functions. ! ! There are several ways to access foreign functions. ! ! XXX as attributes of loaded libraries. ``CFUNCTYPE(restype, *argtypes)`` : funcdesc *************** *** 46,49 **** --- 71,109 ---- function, and acquire it back after leaving the function code. + ``WINFUNCTYPE(restype, *argtypes)`` : funcdesc + TBD + + ``PYFUNCTYPE(restype, *argtypes)`` : funcdesc + TBD + + ``ArgumentError()`` : excdesc + This exception is raised when a foreign function call cannot + convert one of the passed arguments. + + + + helper functions + ---------------- + + ``addressof(obj)`` : funcdesc + Returns the address of the memory buffer as integer. ``obj`` must + be an instance of a ctypes type. + + ``alignment(obj_or_type)`` : funcdesc + Returns the alignment requirements of a ctypes type. + ``obj_or_type`` must be a ctypes type or instance. + + ``byref(obj)`` : funcdesc + Returns a light-weight pointer to ``obj``, which must be an + instance of a ctypes type. The returned object can only be used as + a foreign function call parameter. It behaves similar to + ``pointer(obj)``, but the construction is a lot faster. + + ``cast(obj, type)`` : funcdesc + This function is similar to the cast operator in C. It returns a + new instance of ``type`` which points to the same memory block as + ``obj``. ``type`` must be a pointer type, and ``obj`` must be an + object that can be interpreted as a pointer. + ``create_string_buffer(init_or_size[, size])`` : funcdesc This function creates a mutable character buffer. The returned *************** *** 123,129 **** function call, you should use ``byref(obj)`` which is much faster. - ``PYFUNCTYPE(restype, *argtypes)`` : funcdesc - TBD - ``pythonapi()`` : funcdesc XXX Not a function. --- 183,186 ---- *************** *** 164,170 **** get a textual description of the error. - ``WINFUNCTYPE(restype, *argtypes)`` : funcdesc - TBD - ``wstring_at(address)`` : funcdesc This function returns the wide character string starting at memory --- 221,224 ---- *************** *** 419,463 **** td.lptdesc = POINTER(some_type) td.u.lptdesc = POINTER(some_type) - - - libraries - --------- - - ``CDLL(name, mode=RTLD_LOCAL, handle=None)`` : classdesc* - XXX - - ``cdll`` : vardesc - XXX - - ``LibraryLoader(dlltype)`` : classdesc - Abstract base class which loads shared libraries. - - ``LoadLibrary(name, mode=RTLD_LOCAL, handle=None)`` : methoddesc - Load a shared library. - - ``OleDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc - XXX - - ``oledll`` : vardesc - XXX - - ``py_object`` : classdesc* - XXX - - ``PyDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc - XXX - - ``pydll`` : vardesc - XXX - - ``RTLD_GLOBAL`` : vardesc - XXX - - ``RTLD_LOCAL`` : vardesc - XXX - - ``WinDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc - XXX - - ``windll`` : vardesc - XXX --- 473,474 ---- |
From: Thomas H. <th...@us...> - 2006-05-30 18:03:44
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3068 Modified Files: reference.txt Log Message: Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** reference.txt 30 May 2006 17:05:12 -0000 1.12 --- reference.txt 30 May 2006 18:03:41 -0000 1.13 *************** *** 2,6 **** ================ ! ctypes functions ---------------- --- 2,6 ---- ================ ! helper functions ---------------- *************** *** 335,349 **** --------------------- ``BigEndianStructure`` : classdesc* ! Structure with big endian byte order. ``LittleEndianStructure`` : classdesc* ! Structure with little endian byte order. ``Structure`` : classdesc* ! Structure with native byte order. ! ``Union`` : classdesc* ! Union with native byte order. --- 335,422 ---- --------------------- + ``Union`` : classdesc* + Abstract base class for unions in native byte order. + ``BigEndianStructure`` : classdesc* ! Abstract base class for structures in big endian byte order. ``LittleEndianStructure`` : classdesc* ! Abstract base class for structures in little endian byte order. ``Structure`` : classdesc* ! Abstract base class for structures in native byte order. ! Structure and union types must be created by subclassing, and at least ! defining a ``_fields_`` class variable. ``ctypes`` will create ! descriptors which allow read/write access to the fields. ! ! ``_fields_`` : memberdesc ! ! A sequence defining the structure fields. The items must be ! 2-tuples or 3-tuples. The first tuple item is the name of the ! field, the second item specifies the type of the field; it must be ! any ctypes data type. ! ! The third item is optional, and only allowed for integer field ! types. It allows to define structures containing bit fields, it ! must be a small positive integer specifying the width of the bit ! field. ! ! It is possible to define the ``_fields_`` class variable *after* ! the class statement that defines the Structure subclass, this ! allows to create data types that directly or indirectly references ! themselves:: ! ! class List(Structure): ! pass ! List._fields_ = [("pnext", POINTER(List)), ! ... ! ] ! ! The ``_fields_`` class variable must, however, be defined before ! the type is first used (an instance is created, ``sizeof()`` is ! called on it, and so on). Later assignments to the ``_fields_`` ! class variable will raise an AttributeError. ! ! ``_pack_`` : memberdesc ! ! An optional small integer that allows to override the alignment of ! structure fields in the instance. ``_pack_`` must be defined when ! ``_fields_`` is assigned, otherwise it will have no effect. ! ! ``_anonymous_`` : memberdesc ! ! An optional sequence that lists the names of anonymous fields. ! ! The fields listed in this variable must be structure or union type ! fields. ``ctypes`` will create descriptors in the structure type ! that allows to access the nested fields directly, without the need ! to create the structure or union field. ! ! Here is an example type (Windows):: ! ! class _U(Union): ! _fields_ = [("lptdesc", POINTER(TYPEDESC)), ! ("lpadesc", POINTER(ARRAYDESC)), ! ("hreftype", HREFTYPE)] ! ! class TYPEDESC(Structure): ! _fields_ = [("u", _U), ! ("vt", VARTYPE)] ! ! _anonymous_ = ("u",) ! ! The ``TYPEDESC`` structure describes a COM data type, the ``vt`` ! field specifies which one of the union fields is valid. Since the ! ``u`` field is defined as anonymous field, it is now possible to ! access the members directly off the TYPEDESC instance. ! ``td.lptdesc`` and ``td.u.lptdesc`` are equivalent, but the former ! is faster since it does not need to create a temporary ``_U`` ! instance:: ! ! td = TYPEDESC() ! td.vt = VT_PTR ! td.lptdesc = POINTER(some_type) ! td.u.lptdesc = POINTER(some_type) *************** *** 358,362 **** ``LibraryLoader(dlltype)`` : classdesc ! Base class which loads shared libraries. ``LoadLibrary(name, mode=RTLD_LOCAL, handle=None)`` : methoddesc --- 431,435 ---- ``LibraryLoader(dlltype)`` : classdesc ! Abstract base class which loads shared libraries. ``LoadLibrary(name, mode=RTLD_LOCAL, handle=None)`` : methoddesc |
From: Thomas H. <th...@us...> - 2006-05-30 17:05:20
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16441 Modified Files: reference.txt Log Message: *** empty log message *** Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** reference.txt 30 May 2006 17:02:21 -0000 1.11 --- reference.txt 30 May 2006 17:05:12 -0000 1.12 *************** *** 214,241 **** ``c_byte`` : classdesc* ! Represents a C signed char datatype, and interprets the value as small integer. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_char`` : classdesc* ! Represents a C char datatype, and interprets the value as a single character. The constructor accepts an optional string initializer, the length of the string must be exactly one character. ``c_char_p`` : classdesc* ! Represents a C char * datatype, which must be a pointer to a zero-terminated string. The constructor accepts an integer address, or a string. ``c_double`` : classdesc* ! Represents a C double datatype. The constructor accepts an optional float initializer. ``c_float`` : classdesc* ! Represents a C double datatype. The constructor accepts an optional float initializer. ``c_int`` : classdesc* ! Represents a C signed int datatype. The constructor accepts an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(int) == sizeof(long)`` it is an alias to --- 214,241 ---- ``c_byte`` : classdesc* ! Represents the C signed char datatype, and interprets the value as small integer. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_char`` : classdesc* ! Represents the C char datatype, and interprets the value as a single character. The constructor accepts an optional string initializer, the length of the string must be exactly one character. ``c_char_p`` : classdesc* ! Represents the C char * datatype, which must be a pointer to a zero-terminated string. The constructor accepts an integer address, or a string. ``c_double`` : classdesc* ! Represents the C double datatype. The constructor accepts an optional float initializer. ``c_float`` : classdesc* ! Represents the C double datatype. The constructor accepts an optional float initializer. ``c_int`` : classdesc* ! Represents the C signed int datatype. The constructor accepts an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(int) == sizeof(long)`` it is an alias to *************** *** 243,283 **** ``c_int16`` : classdesc* ! Represents a C 16-bit signed int datatype. Usually an alias for ``c_short``. ``c_int32`` : classdesc* ! Represents a C 32-bit signed int datatype. Usually an alias for ``c_int``. ``c_int64`` : classdesc* ! Represents a C 64-bit ``signed int`` datatype. Usually an alias for ``c_longlong``. ``c_int8`` : classdesc* ! Represents a C 8-bit ``signed int`` datatype. Usually an alias for ``c_byte``. ``c_long`` : classdesc* ! Represents a C ``signed long`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_longlong`` : classdesc* ! Represents a C ``signed long long`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_short`` : classdesc* ! Represents a C ``signed short`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_size_t`` : classdesc* ! Represents a C ``size_t`` datatype. ``c_ubyte`` : classdesc* ! Represents a C ``unsigned char`` datatype, it interprets the value as small integer. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_uint`` : classdesc* ! Represents a C ``unsigned int`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(int) == sizeof(long)`` it is an alias for --- 243,283 ---- ``c_int16`` : classdesc* ! Represents the C 16-bit signed int datatype. Usually an alias for ``c_short``. ``c_int32`` : classdesc* ! Represents the C 32-bit signed int datatype. Usually an alias for ``c_int``. ``c_int64`` : classdesc* ! Represents the C 64-bit ``signed int`` datatype. Usually an alias for ``c_longlong``. ``c_int8`` : classdesc* ! Represents the C 8-bit ``signed int`` datatype. Usually an alias for ``c_byte``. ``c_long`` : classdesc* ! Represents the C ``signed long`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_longlong`` : classdesc* ! Represents the C ``signed long long`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_short`` : classdesc* ! Represents the C ``signed short`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_size_t`` : classdesc* ! Represents the C ``size_t`` datatype. ``c_ubyte`` : classdesc* ! Represents the C ``unsigned char`` datatype, it interprets the value as small integer. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_uint`` : classdesc* ! Represents the C ``unsigned int`` datatype. The constructor accepts an optional integer initializer; no overflow checking is done. On platforms where ``sizeof(int) == sizeof(long)`` it is an alias for *************** *** 285,322 **** ``c_uint16`` : classdesc* ! Represents a C 16-bit unsigned int datatype. Usually an alias for ``c_ushort``. ``c_uint32`` : classdesc* ! Represents a C 32-bit unsigned int datatype. Usually an alias for ``c_uint``. ``c_uint64`` : classdesc* ! Represents a C 64-bit unsigned int datatype. Usually an alias for ``c_ulonglong``. ``c_uint8`` : classdesc* ! Represents a C 8-bit unsigned int datatype. Usually an alias for ``c_ubyte``. ``c_ulong`` : classdesc* ! Represents a C unsigned long datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_ulonglong`` : classdesc* ! Represents a C unsigned long long datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_ushort`` : classdesc* ! Represents a C unsigned short datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_void_p`` : classdesc* ! Represents a C void * type. The value is represented as integer. The constructor accepts an optional integer initializer. ``c_wchar`` : classdesc* ! Represents a C ``wchar_t`` datatype, and interprets the value as a single character unicode string. The constructor accepts an optional string initializer, the length of the string must be --- 285,322 ---- ``c_uint16`` : classdesc* ! Represents the C 16-bit unsigned int datatype. Usually an alias for ``c_ushort``. ``c_uint32`` : classdesc* ! Represents the C 32-bit unsigned int datatype. Usually an alias for ``c_uint``. ``c_uint64`` : classdesc* ! Represents the C 64-bit unsigned int datatype. Usually an alias for ``c_ulonglong``. ``c_uint8`` : classdesc* ! Represents the C 8-bit unsigned int datatype. Usually an alias for ``c_ubyte``. ``c_ulong`` : classdesc* ! Represents the C unsigned long datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_ulonglong`` : classdesc* ! Represents the C unsigned long long datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_ushort`` : classdesc* ! Represents the C unsigned short datatype. The constructor accepts an optional integer initializer; no overflow checking is done. ``c_void_p`` : classdesc* ! Represents the C void * type. The value is represented as integer. The constructor accepts an optional integer initializer. ``c_wchar`` : classdesc* ! Represents the C ``wchar_t`` datatype, and interprets the value as a single character unicode string. The constructor accepts an optional string initializer, the length of the string must be *************** *** 324,328 **** ``c_wchar_p`` : classdesc* ! Represents a C ``wchar_t *`` datatype, which must be a pointer to a zero-terminated wide character string. The constructor accepts an integer address, or a string. --- 324,328 ---- ``c_wchar_p`` : classdesc* ! Represents the C ``wchar_t *`` datatype, which must be a pointer to a zero-terminated wide character string. The constructor accepts an integer address, or a string. |
From: Thomas H. <th...@us...> - 2006-05-30 17:02:35
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv15435 Modified Files: reference.txt Log Message: Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** reference.txt 30 May 2006 15:49:12 -0000 1.10 --- reference.txt 30 May 2006 17:02:21 -0000 1.11 *************** *** 357,363 **** XXX ! ``LibraryLoader(dlltype)`` : classdesc* ! ``LoadLibrary(name, mode=RTLD_LOCAL, handle=None)`` : methoddesc ! Load a shared library. ``OleDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc --- 357,365 ---- XXX ! ``LibraryLoader(dlltype)`` : classdesc ! Base class which loads shared libraries. ! ! ``LoadLibrary(name, mode=RTLD_LOCAL, handle=None)`` : methoddesc ! Load a shared library. ``OleDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc |
From: Thomas H. <th...@us...> - 2006-05-30 15:49:22
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20658 Modified Files: reference.txt Log Message: Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** reference.txt 29 May 2006 16:38:47 -0000 1.9 --- reference.txt 30 May 2006 15:49:12 -0000 1.10 *************** *** 331,332 **** --- 331,388 ---- Windows only: Represents a HRESULT value, which contains success or error information for a function or method call. + + structured data types + --------------------- + + ``BigEndianStructure`` : classdesc* + Structure with big endian byte order. + + ``LittleEndianStructure`` : classdesc* + Structure with little endian byte order. + + ``Structure`` : classdesc* + Structure with native byte order. + + ``Union`` : classdesc* + Union with native byte order. + + + libraries + --------- + + ``CDLL(name, mode=RTLD_LOCAL, handle=None)`` : classdesc* + XXX + + ``cdll`` : vardesc + XXX + + ``LibraryLoader(dlltype)`` : classdesc* + ``LoadLibrary(name, mode=RTLD_LOCAL, handle=None)`` : methoddesc + Load a shared library. + + ``OleDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc + XXX + + ``oledll`` : vardesc + XXX + + ``py_object`` : classdesc* + XXX + + ``PyDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc + XXX + + ``pydll`` : vardesc + XXX + + ``RTLD_GLOBAL`` : vardesc + XXX + + ``RTLD_LOCAL`` : vardesc + XXX + + ``WinDLL(name, mode=RTLD_LOCAL, handle=None)`` : funcdesc + XXX + + ``windll`` : vardesc + XXX |
From: Thomas H. <th...@us...> - 2006-05-29 16:38:50
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13261 Modified Files: reference.txt Log Message: Small fix. Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** reference.txt 29 May 2006 16:35:17 -0000 1.8 --- reference.txt 29 May 2006 16:38:47 -0000 1.9 *************** *** 201,208 **** ``_SimpleCData`` : classdesc* ! This non-public class is the base class of all ctypes data types. It is mentioned here because it contains the common attributes of the ctypes data types. ``value`` : memberdesc This attribute contains the actual value of the instance. For --- 201,210 ---- ``_SimpleCData`` : classdesc* ! This non-public class is the base class of all simple ctypes data types. It is mentioned here because it contains the common attributes of the ctypes data types. + Instances have a single attribute: + ``value`` : memberdesc This attribute contains the actual value of the instance. For *************** *** 211,215 **** These are the simple ctypes data types: ! ``c_byte([value]) : classdesc* Represents a C signed char datatype, and interprets the value as small integer. The constructor accepts an optional integer --- 213,217 ---- These are the simple ctypes data types: ! ``c_byte`` : classdesc* Represents a C signed char datatype, and interprets the value as small integer. The constructor accepts an optional integer |
From: Thomas H. <th...@us...> - 2006-05-29 16:35:23
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv11774 Modified Files: reference.txt Log Message: Add simple data types. Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** reference.txt 29 May 2006 12:09:37 -0000 1.7 --- reference.txt 29 May 2006 16:35:17 -0000 1.8 *************** *** 196,197 **** --- 196,330 ---- library. name is the name of the symbol that exports the data, library is the loaded shared library. + + simple data types + ----------------- + + ``_SimpleCData`` : classdesc* + This non-public class is the base class of all ctypes data + types. It is mentioned here because it contains the common + attributes of the ctypes data types. + + ``value`` : memberdesc + This attribute contains the actual value of the instance. For + integer types, it is an integer. + + These are the simple ctypes data types: + + ``c_byte([value]) : classdesc* + Represents a C signed char datatype, and interprets the value as + small integer. The constructor accepts an optional integer + initializer; no overflow checking is done. + + ``c_char`` : classdesc* + Represents a C char datatype, and interprets the value as a single + character. The constructor accepts an optional string initializer, + the length of the string must be exactly one character. + + ``c_char_p`` : classdesc* + Represents a C char * datatype, which must be a pointer to a + zero-terminated string. The constructor accepts an integer + address, or a string. + + ``c_double`` : classdesc* + Represents a C double datatype. The constructor accepts an + optional float initializer. + + ``c_float`` : classdesc* + Represents a C double datatype. The constructor accepts an + optional float initializer. + + ``c_int`` : classdesc* + Represents a C signed int datatype. The constructor accepts an + optional integer initializer; no overflow checking is done. On + platforms where ``sizeof(int) == sizeof(long)`` it is an alias to + ``c_long``. + + ``c_int16`` : classdesc* + Represents a C 16-bit signed int datatype. Usually an alias for + ``c_short``. + + ``c_int32`` : classdesc* + Represents a C 32-bit signed int datatype. Usually an alias for + ``c_int``. + + ``c_int64`` : classdesc* + Represents a C 64-bit ``signed int`` datatype. Usually an alias + for ``c_longlong``. + + ``c_int8`` : classdesc* + Represents a C 8-bit ``signed int`` datatype. Usually an alias for + ``c_byte``. + + ``c_long`` : classdesc* + Represents a C ``signed long`` datatype. The constructor accepts an + optional integer initializer; no overflow checking is done. + + ``c_longlong`` : classdesc* + Represents a C ``signed long long`` datatype. The constructor accepts + an optional integer initializer; no overflow checking is done. + + ``c_short`` : classdesc* + Represents a C ``signed short`` datatype. The constructor accepts an + optional integer initializer; no overflow checking is done. + + ``c_size_t`` : classdesc* + Represents a C ``size_t`` datatype. + + ``c_ubyte`` : classdesc* + Represents a C ``unsigned char`` datatype, it interprets the + value as small integer. The constructor accepts an optional + integer initializer; no overflow checking is done. + + ``c_uint`` : classdesc* + Represents a C ``unsigned int`` datatype. The constructor accepts an + optional integer initializer; no overflow checking is done. On + platforms where ``sizeof(int) == sizeof(long)`` it is an alias for + ``c_ulong``. + + ``c_uint16`` : classdesc* + Represents a C 16-bit unsigned int datatype. Usually an alias for + ``c_ushort``. + + ``c_uint32`` : classdesc* + Represents a C 32-bit unsigned int datatype. Usually an alias for + ``c_uint``. + + ``c_uint64`` : classdesc* + Represents a C 64-bit unsigned int datatype. Usually an alias for + ``c_ulonglong``. + + ``c_uint8`` : classdesc* + Represents a C 8-bit unsigned int datatype. Usually an alias for + ``c_ubyte``. + + ``c_ulong`` : classdesc* + Represents a C unsigned long datatype. The constructor accepts an + optional integer initializer; no overflow checking is done. + + ``c_ulonglong`` : classdesc* + Represents a C unsigned long long datatype. The constructor + accepts an optional integer initializer; no overflow checking is + done. + + ``c_ushort`` : classdesc* + Represents a C unsigned short datatype. The constructor accepts an + optional integer initializer; no overflow checking is done. + + ``c_void_p`` : classdesc* + Represents a C void * type. The value is represented as + integer. The constructor accepts an optional integer initializer. + + ``c_wchar`` : classdesc* + Represents a C ``wchar_t`` datatype, and interprets the value as a + single character unicode string. The constructor accepts an + optional string initializer, the length of the string must be + exactly one character. + + ``c_wchar_p`` : classdesc* + Represents a C ``wchar_t *`` datatype, which must be a pointer to + a zero-terminated wide character string. The constructor accepts + an integer address, or a string. + + ``HRESULT`` : classdesc* + Windows only: Represents a HRESULT value, which contains success + or error information for a function or method call. |
From: Thomas H. <th...@us...> - 2006-05-29 12:49:14
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv18066 Modified Files: ctypes.txt Log Message: *** empty log message *** Index: ctypes.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/ctypes.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ctypes.txt 26 May 2006 10:27:54 -0000 1.1 --- ctypes.txt 29 May 2006 12:49:00 -0000 1.2 *************** *** 1,2 **** --- 1,9 ---- + :Module: ctypes + :Summary: A foreign function library for Python. + :Module Type: standard + :Author: Thomas Heller <th...@py...> + :Synopsis: A foreign function library for Python. + :Version Added: 2.5 + ``ctypes`` is a foreign function library for Python. |
From: Thomas H. <th...@us...> - 2006-05-29 12:09:46
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv1764 Modified Files: reference.txt Log Message: *** empty log message *** Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** reference.txt 29 May 2006 11:39:49 -0000 1.6 --- reference.txt 29 May 2006 12:09:37 -0000 1.7 *************** *** 172,173 **** --- 172,197 ---- it is used as the number of characters of the string, otherwise the string is assumed to be zero-terminated. + + + data types + ---------- + + ``_CData`` : classdesc* + This non-public class is the base class of all ctypes data types. + Among other things, a ctypes type instance contains a memory block + that contains C compatible data. + + Common methods of ctypes data types, these are all class methods (to + be exact, they are methods of the metaclass): + + ``from_address(address)`` : methoddesc + This method returns a ctypes type instance using the memory + specified by address. + + ``from_param(obj)`` : methoddesc + This method adapts obj to a ctypes type. + + ``in_dll(name, library)`` : methoddesc + This method returns a ctypes type instance exported by a shared + library. name is the name of the symbol that exports the data, + library is the loaded shared library. |
From: Thomas H. <th...@us...> - 2006-05-29 11:39:59
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv21943 Modified Files: reference.txt Log Message: *** empty log message *** Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** reference.txt 29 May 2006 11:22:18 -0000 1.5 --- reference.txt 29 May 2006 11:39:49 -0000 1.6 *************** *** 6,25 **** ``addressof(obj)`` : funcdesc - Returns the address of the memory buffer as integer. ``obj`` must ! be an instanceof a ctypes type. ``alignment(obj_or_type)`` : funcdesc - Returns the alignment requirements of a ctypes type. ``obj_or_type`` must be a ctypes type or instance. ``ArgumentError()`` : excdesc - This exception is raised when a foreign function call cannot convert one of the passed arguments. ``byref(obj)`` : funcdesc - Returns a light-weight pointer to ``obj``, which must be an instance of a ctypes type. The returned object can only be used as --- 6,21 ---- ``addressof(obj)`` : funcdesc Returns the address of the memory buffer as integer. ``obj`` must ! be an instance of a ctypes type. ``alignment(obj_or_type)`` : funcdesc Returns the alignment requirements of a ctypes type. ``obj_or_type`` must be a ctypes type or instance. ``ArgumentError()`` : excdesc This exception is raised when a foreign function call cannot convert one of the passed arguments. ``byref(obj)`` : funcdesc Returns a light-weight pointer to ``obj``, which must be an instance of a ctypes type. The returned object can only be used as *************** *** 28,32 **** ``cast(obj, type)`` : funcdesc - This function is similar to the cast operator in C. It returns a new instance of ``type`` which points to the same memory block as --- 24,27 ---- *************** *** 35,39 **** ``CFUNCTYPE(restype, *argtypes)`` : funcdesc - This is a factory function that returns a function prototype. The function prototype describes a function that has a result type of --- 30,33 ---- *************** *** 53,57 **** ``create_string_buffer(init_or_size[, size])`` : funcdesc - This function creates a mutable character buffer. The returned object is a ctypes array of ``c_char``. --- 47,50 ---- *************** *** 71,75 **** ``create_unicode_buffer(init_or_size[, size])`` : funcdesc - This function creates a mutable unicode character buffer. The returned object is a ctypes array of ``c_wchar``. --- 64,67 ---- *************** *** 90,94 **** ``DllCanUnloadNow()`` : funcdesc - Windows only: This function is a hook which allows to implement inprocess COM servers with ctypes. It is called from the --- 82,85 ---- *************** *** 96,100 **** ``DllGetClassObject()`` : funcdesc - Windows only: This function is a hook which allows to implement inprocess COM servers with ctypes. It is called from the --- 87,90 ---- *************** *** 102,106 **** ``FormatError([code])`` : funcdesc - Windows only: Returns a textual description of the error code. If no error code is specified, the last error code is used by calling --- 92,95 ---- *************** *** 108,117 **** ``GetLastError()`` : funcdesc - Windows only: Returns the last error code set by Windows in the calling thread. ``memmove(dst, src, count)`` : funcdesc - Same as the standard C memmove library function: copies ``count`` bytes from ``src`` to ``dst``. ``dst`` and ``src`` must be --- 97,104 ---- *************** *** 119,123 **** ``memset(dst, c, count)`` : funcdesc - Same as the standard C memset library function: fills the memory block at address ``dst`` with ``count`` bytes of value --- 106,109 ---- *************** *** 126,130 **** ``POINTER(type)`` : funcdesc - This factory function creates and returns a new ctypes pointer type. Pointer types are cached an reused internally, so calling --- 112,115 ---- *************** *** 132,138 **** ``pointer(obj)`` : funcdesc ! ! This function creates a new pointer instance, pointing to ``obj``. The ! returned object is of the type POINTER(type(obj)). Note: If you just want to pass a pointer to an object to a foreign --- 117,122 ---- ``pointer(obj)`` : funcdesc ! This function creates a new pointer instance, pointing to ! ``obj``. The returned object is of the type POINTER(type(obj)). Note: If you just want to pass a pointer to an object to a foreign *************** *** 140,152 **** ``PYFUNCTYPE(restype, *argtypes)`` : funcdesc - TBD ``pythonapi()`` : funcdesc - XXX Not a function. ``resize(obj, size)`` : funcdesc - This function resizes the internal memory buffer of obj, which must be an instance of a ctypes type. It is not possible to make --- 124,133 ---- *************** *** 156,160 **** ``set_conversion_mode(encoding, errors)`` : funcdesc - This function sets the rules that ctypes objects use when converting between 8-bit strings and unicode strings. encoding --- 137,140 ---- *************** *** 169,178 **** ``sizeof(obj_or_type)`` : funcdesc - Returns the size in bytes of a ctypes type or instance memory buffer. Does the same as the C ``sizeof()`` function. ``string_at(address[, size])`` : funcdesc - This function returns the string starting at memory address address. If size is specified, it is used as size, otherwise the --- 149,156 ---- *************** *** 180,184 **** ``WinError(code=None, descr=None)`` : funcdesc - Windows only: this function is probably the worst-named thing in ctypes. It creates an instance of WindowsError. If ``code`` is not --- 158,161 ---- *************** *** 188,196 **** ``WINFUNCTYPE(restype, *argtypes)`` : funcdesc - TBD ``wstring_at(address)`` : funcdesc - This function returns the wide character string starting at memory address ``address`` as unicode string. If ``size`` is specified, --- 165,171 ---- |
From: Thomas H. <th...@us...> - 2006-05-29 11:22:25
|
Update of /cvsroot/ctypes/ctypes/docs/manual In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv14184 Modified Files: reference.txt Log Message: Fresh start. Index: reference.txt =================================================================== RCS file: /cvsroot/ctypes/ctypes/docs/manual/reference.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** reference.txt 26 May 2006 12:51:50 -0000 1.4 --- reference.txt 29 May 2006 11:22:18 -0000 1.5 *************** *** 2,195 **** ================ ! ``addressof(obj)`` ! Returns the address of ``obj`` as integer. ``obj`` must be an ! instance of a ctypes type. ! ! ``alignment(obj)`` ! Returns the byte alignment requirement of ``obj``. ! ! ``ArgumentError`` ! This exception is raised when a parameter cannot be used in a ! foreign function call. ! ! .. undocumented because deprecated. ! ``ARRAY`` ! ``Array`` ! ! ``BigEndianStructure`` ! Base class. ! ! ``byref(obj)`` : funcdesc ! Returns a light-weight pointer to a ctypes instance. The returned ! object can only be used as function call parameter. Behaves the ! same as calling ``pointer(object)``, but is a lot faster. Same as ! ``&object`` in C. ! ! ! .. undocumented because deprecated. ! ``c_buffer`` ! ! .. topic:: ``c_byte`` ! :class: funcdef ! ! Represents the C ``char`` data type, interpreted as integer. ! ! ``c_char_p`` ! ! ``c_char`` ! ! ``c_double`` ! ! ``c_float`` ! ! ``c_int8``, ``c_int16``, ``c_int32``, ``c_int64`` ! ``c_short`` ! ``c_int`` ! ``c_long`` ! ``c_longlong`` ! ``c_size_t`` ! ``c_ubyte`` ! ``c_uint16`` ! ``c_uint32`` ! ``c_uint64`` ! ``c_uint8`` ! ``c_uint`` ! ``c_ulong`` ! ``c_ulonglong`` ! ``c_ushort`` ! ``c_void_p`` ! ``c_voidp`` ! ``c_wchar_p`` ! ``c_wchar`` ! ``cast(obj, type)`` ! This function is similar to the cast operator in C. Returns a new ! instance of ``type`` which shares the memory block of ``object``. ! ``type`` must be a pointer type. ! ``CDLL`` ! ``cdll`` ! ``CFUNCTYPE`` ! ``create_string_buffer(init_or_size[, size])`` ! Convenience function which creates a mutable character buffer. ! ``init`` must be a string. If ``size`` is supplied it must be a ! positive integer that specifies the size of the buffer, otherwise ! the length of the ``init`` string is used. ! This function returns a ctypes array of characters ``c_char``. ! ``create_unicode_buffer`` ! Convenience function which creates a mutable character buffer. ! ``init`` must be a unicode string. If ``size`` is supplied it ! must be a positive integer that specifies the size of the buffer, ! otherwise the length of the ``init`` string is used. This ! function returns a ctypes array of wide characters ``c_wchar``. ! ``DllCanUnloadNow`` ! Windows only. This function is used to implement COM servers. ! ``DllGetClassObject`` ! Windows only. This function is used to implement COM servers. ! ``FormatError([code], [descr])`` ! Windows only. Returns a textual description of the error code, or ! the last error code set by Windows. ! ``GetLastError()`` ! Windows only. Return the last error code set by Windows in the calling thread. ! ``HRESULT`` ! ``LibraryLoader`` ! Instances of this type are used to load shared libraries. ! ``LittleEndianStructure`` ! ``memmove(dst, src, count)`` ! Same as the standard C ``memmove`` library function: copies ! ``count`` bytes from ``src`` to ``dst``. ``dst`` and ``src`` must ! be integers or anything else that can be converted into a pointer. ! ``memset(dst, c, count)`` ! Same as the standard C ``memset`` function. Fills the memory block ! at address ``dst`` with ``count`` bytes of value ``c``. ``dst`` must be ! an integer specifying an address, or a ctypes instance. ! ``OleDLL`` ! ``oledll`` ! ``POINTER(type)`` ! This factory function creates and returns a new ctypes type. ! Pointer types are cached, so calling this function repeatedly is ! cheap. ! ``pointer(obj)`` ! This function creates a new pointer instance, pointing to ``obj`` ! which must be an instance of a ctypes type. The return pointer is ! of type ``POINTER(type(obj))``. If you just want to pass a ! pointer to this object to a foreign function call, you should use ! ``byref(obj)`` instead which is much faster. ! ``py_object`` ! ``PyDLL`` ! ``pydll`` ! ``PYFUNCTYPE`` ! ``pythonapi`` ! ``resize`` ! ``RTLD_GLOBAL`` ! ``RTLD_LOCAL`` ! ``set_conversion_mode`` ! ``SetPointerType`` ! ``sizeof`` ! ``string_at`` ! ``Structure`` ! ``Union`` ! ``WinDLL`` ! ``windll`` ! ``WinError`` ! ``WINFUNCTYPE`` ! ``wstring_at`` --- 2,198 ---- ================ ! ctypes functions ! ---------------- ! ``addressof(obj)`` : funcdesc ! Returns the address of the memory buffer as integer. ``obj`` must ! be an instanceof a ctypes type. ! ``alignment(obj_or_type)`` : funcdesc ! Returns the alignment requirements of a ctypes type. ! ``obj_or_type`` must be a ctypes type or instance. ! ``ArgumentError()`` : excdesc ! This exception is raised when a foreign function call cannot ! convert one of the passed arguments. ! ``byref(obj)`` : funcdesc ! Returns a light-weight pointer to ``obj``, which must be an ! instance of a ctypes type. The returned object can only be used as ! a foreign function call parameter. It behaves similar to ! ``pointer(obj)``, but the construction is a lot faster. ! ``cast(obj, type)`` : funcdesc ! This function is similar to the cast operator in C. It returns a ! new instance of ``type`` which points to the same memory block as ! ``obj``. ``type`` must be a pointer type, and ``obj`` must be an ! object that can be interpreted as a pointer. ! ``CFUNCTYPE(restype, *argtypes)`` : funcdesc ! This is a factory function that returns a function prototype. The ! function prototype describes a function that has a result type of ! ``restype``, and accepts arguments as specified by ! ``argtypes``. The function prototype can be used to construct ! several kinds of functions, depending on how the prototype is ! called. ! The prototypes returned by ``CFUNCTYPE`` or ``PYFUNCTYPE`` create ! functions that use the standard C calling convention, prototypes ! returned from ``WINFUNCTYPE`` (on Windows) use the ``__stdcall`` ! calling convention. ! Functions created by calling the ``CFUNCTYPE`` and ``WINFUNCTYPE`` ! prototypes release the Python GIL before entering the foreign ! function, and acquire it back after leaving the function code. ! ``create_string_buffer(init_or_size[, size])`` : funcdesc ! This function creates a mutable character buffer. The returned ! object is a ctypes array of ``c_char``. ! ``init_or_size`` must be an integer which specifies the size of ! the array, or a string which will be used to initialize the array ! items. ! If a string is specified as first argument, the buffer is made one ! item larger than the length of the string so that the last element ! in the array is a NUL termination character. An integer can be ! passed as second argument which allows to specify the size of the ! array if the length of the string should not be used. ! If the first parameter is a unicode string, it is converted into ! an 8-bit string according to ctypes conversion rules. ! ``create_unicode_buffer(init_or_size[, size])`` : funcdesc + This function creates a mutable unicode character buffer. The + returned object is a ctypes array of ``c_wchar``. ! ``init_or_size`` must be an integer which specifies the size of ! the array, or a unicode string which will be used to initialize ! the array items. ! If a unicode string is specified as first argument, the buffer is ! made one item larger than the length of the string so that the ! last element in the array is a NUL termination character. An ! integer can be passed as second argument which allows to specify ! the size of the array if the length of the string should not be ! used. ! If the first parameter is a 8-bit string, it is converted into an ! unicode string according to ctypes conversion rules. ! ``DllCanUnloadNow()`` : funcdesc ! Windows only: This function is a hook which allows to implement ! inprocess COM servers with ctypes. It is called from the ! DllCanUnloadNow function that the _ctypes extension dll exports. ! ``DllGetClassObject()`` : funcdesc ! Windows only: This function is a hook which allows to implement ! inprocess COM servers with ctypes. It is called from the ! DllGetClassObject function that the ``_ctypes`` extension dll exports. ! ``FormatError([code])`` : funcdesc ! Windows only: Returns a textual description of the error code. If ! no error code is specified, the last error code is used by calling ! the Windows api function GetLastError. ! ``GetLastError()`` : funcdesc ! Windows only: Returns the last error code set by Windows in the calling thread. ! ``memmove(dst, src, count)`` : funcdesc ! Same as the standard C memmove library function: copies ``count`` ! bytes from ``src`` to ``dst``. ``dst`` and ``src`` must be ! integers or ctypes instances that can be converted to pointers. ! ``memset(dst, c, count)`` : funcdesc ! Same as the standard C memset library function: fills the memory ! block at address ``dst`` with ``count`` bytes of value ! ``c``. ``dst`` must be an integer specifying an address, or a ! ctypes instance. ! ``POINTER(type)`` : funcdesc ! This factory function creates and returns a new ctypes pointer ! type. Pointer types are cached an reused internally, so calling ! this function repeatedly is cheap. type must be a ctypes type. ! ``pointer(obj)`` : funcdesc ! This function creates a new pointer instance, pointing to ``obj``. The ! returned object is of the type POINTER(type(obj)). ! Note: If you just want to pass a pointer to an object to a foreign ! function call, you should use ``byref(obj)`` which is much faster. ! ``PYFUNCTYPE(restype, *argtypes)`` : funcdesc ! TBD ! ``pythonapi()`` : funcdesc ! XXX Not a function. ! ``resize(obj, size)`` : funcdesc ! This function resizes the internal memory buffer of obj, which ! must be an instance of a ctypes type. It is not possible to make ! the buffer smaller than the native size of the objects type, as ! given by sizeof(type(obj)), but it is possible to enlarge the ! buffer. ! ``set_conversion_mode(encoding, errors)`` : funcdesc ! This function sets the rules that ctypes objects use when ! converting between 8-bit strings and unicode strings. encoding ! must be a string specifying an encoding, like ``'utf-8'`` or ! ``'mbcs'``, errors must be a string specifying the error handling ! on encoding/decoding errors. Examples of possible values are ! ``"strict"``, ``"replace"``, or ``"ignore"``. ! set_conversion_mode returns a 2-tuple containing the previous ! conversion rules. On windows, the initial conversion rules are ! ``('mbcs', 'ignore')``, on other systems ``('ascii', 'strict')``. ! ``sizeof(obj_or_type)`` : funcdesc ! Returns the size in bytes of a ctypes type or instance memory ! buffer. Does the same as the C ``sizeof()`` function. ! ``string_at(address[, size])`` : funcdesc ! This function returns the string starting at memory address ! address. If size is specified, it is used as size, otherwise the ! string is assumed to be zero-terminated. ! ``WinError(code=None, descr=None)`` : funcdesc ! Windows only: this function is probably the worst-named thing in ! ctypes. It creates an instance of WindowsError. If ``code`` is not ! specified, ``GetLastError`` is called to determine the error ! code. If ``descr`` is not spcified, ``FormatError`` is called to ! get a textual description of the error. ! ``WINFUNCTYPE(restype, *argtypes)`` : funcdesc ! TBD ! ``wstring_at(address)`` : funcdesc ! This function returns the wide character string starting at memory ! address ``address`` as unicode string. If ``size`` is specified, ! it is used as the number of characters of the string, otherwise ! the string is assumed to be zero-terminated. |