pyobjc-dev Mailing List for PyObjC (Page 250)
Brought to you by:
ronaldoussoren
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(9) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(1) |
Feb
(2) |
Mar
(3) |
Apr
(30) |
May
(18) |
Jun
|
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2002 |
Jan
(7) |
Feb
(2) |
Mar
(1) |
Apr
|
May
|
Jun
(3) |
Jul
(13) |
Aug
|
Sep
(23) |
Oct
(180) |
Nov
(291) |
Dec
(95) |
2003 |
Jan
(338) |
Feb
(352) |
Mar
(97) |
Apr
(46) |
May
(226) |
Jun
(184) |
Jul
(145) |
Aug
(141) |
Sep
(69) |
Oct
(161) |
Nov
(96) |
Dec
(90) |
2004 |
Jan
(66) |
Feb
(87) |
Mar
(98) |
Apr
(132) |
May
(115) |
Jun
(68) |
Jul
(150) |
Aug
(92) |
Sep
(59) |
Oct
(52) |
Nov
(17) |
Dec
(75) |
2005 |
Jan
(84) |
Feb
(191) |
Mar
(133) |
Apr
(114) |
May
(158) |
Jun
(185) |
Jul
(62) |
Aug
(28) |
Sep
(36) |
Oct
(88) |
Nov
(65) |
Dec
(43) |
2006 |
Jan
(85) |
Feb
(62) |
Mar
(92) |
Apr
(75) |
May
(68) |
Jun
(101) |
Jul
(73) |
Aug
(37) |
Sep
(91) |
Oct
(65) |
Nov
(30) |
Dec
(39) |
2007 |
Jan
(24) |
Feb
(28) |
Mar
(10) |
Apr
(2) |
May
(18) |
Jun
(16) |
Jul
(21) |
Aug
(6) |
Sep
(30) |
Oct
(31) |
Nov
(153) |
Dec
(31) |
2008 |
Jan
(63) |
Feb
(70) |
Mar
(47) |
Apr
(24) |
May
(59) |
Jun
(22) |
Jul
(12) |
Aug
(7) |
Sep
(14) |
Oct
(26) |
Nov
(5) |
Dec
(5) |
2009 |
Jan
(10) |
Feb
(41) |
Mar
(70) |
Apr
(88) |
May
(49) |
Jun
(62) |
Jul
(34) |
Aug
(15) |
Sep
(55) |
Oct
(40) |
Nov
(67) |
Dec
(21) |
2010 |
Jan
(60) |
Feb
(17) |
Mar
(26) |
Apr
(26) |
May
(29) |
Jun
(4) |
Jul
(21) |
Aug
(21) |
Sep
(10) |
Oct
(12) |
Nov
(3) |
Dec
(19) |
2011 |
Jan
(3) |
Feb
(13) |
Mar
(8) |
Apr
(8) |
May
(17) |
Jun
(20) |
Jul
(21) |
Aug
(7) |
Sep
|
Oct
|
Nov
(9) |
Dec
(11) |
2012 |
Jan
(3) |
Feb
|
Mar
|
Apr
(5) |
May
(4) |
Jun
(14) |
Jul
(5) |
Aug
(2) |
Sep
(15) |
Oct
(2) |
Nov
(23) |
Dec
(1) |
2013 |
Jan
(8) |
Feb
(1) |
Mar
|
Apr
|
May
(5) |
Jun
(1) |
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(12) |
Nov
(10) |
Dec
(3) |
2014 |
Jan
(7) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(2) |
Jun
(11) |
Jul
(10) |
Aug
(4) |
Sep
|
Oct
(8) |
Nov
(1) |
Dec
(2) |
2015 |
Jan
(9) |
Feb
(7) |
Mar
(1) |
Apr
|
May
(7) |
Jun
|
Jul
(5) |
Aug
(6) |
Sep
|
Oct
(1) |
Nov
(4) |
Dec
|
2016 |
Jan
(1) |
Feb
(1) |
Mar
(4) |
Apr
(2) |
May
(1) |
Jun
|
Jul
(6) |
Aug
(8) |
Sep
(21) |
Oct
(17) |
Nov
|
Dec
(36) |
2017 |
Jan
(6) |
Feb
(2) |
Mar
(4) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(6) |
2018 |
Jan
(2) |
Feb
(3) |
Mar
(3) |
Apr
(14) |
May
(2) |
Jun
(2) |
Jul
(4) |
Aug
(3) |
Sep
(6) |
Oct
(16) |
Nov
(1) |
Dec
(6) |
2019 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
(6) |
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(2) |
Jun
(1) |
Jul
(7) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
(2) |
Dec
(1) |
2021 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
(5) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2023 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2025 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ronald O. <ous...@ci...> - 2003-03-02 06:58:56
|
On Saturday, Mar 1, 2003, at 22:39 Europe/Amsterdam, bb...@ma... wrote: > On Saturday, Mar 1, 2003, at 15:18 US/Eastern, Ronald Oussoren wrote: >> On Saturday, Mar 1, 2003, at 20:56 Europe/Amsterdam, Bob Pasker wrote: >>> this begs the question: in pyobjc, is the 'c' in a method signature >>> ONLY used for BOOL types? >> Nope, 'c' is used for 'char', hence the _C_CHR ;-) ;-). > > What does _C_BFLD mean? I had used it successfully in the past for a > BOOL, but I don't remember why it worked or what it really means. Bitfield, is is used for bitfields in structs, e.g. struct foo { int bitfield:3; }. It might be possible to teach the bridge that an 8-bit bitfield is a BOOL, but I'm not sure if the objc-runtime would like that. > >> I'm afraid this is one of the places where the bridge cannot be >> completely transparent. In Python you can use any object as a boolean >> (most are evaluated as true, some are false), but with PyObjC you'll >> have to use small integers. > > I suppose that if the method really does want a (char) vs. a (BOOL), > then typecasting and losing the implied precision would be bad. > However, for (BOOL) methods, an (int) can be passed in pure ObjC.... You can also pass any integer type in Python, as long as its value is small enough. The following should give unexecpected results in Objective-C as well: - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { return 1024; // True, isn't it? } Ronald |
From: Peter M. <zig...@po...> - 2003-03-02 06:11:02
|
I don't know if this has been asked before (I couldn't access the list archives) but has anyone thought of using PyObjC as an AppleScript replacement? Complete Open Scripting Architecture compliance (Script Editor support, etc) probably isn't worth it but what about doing something functionally similar? Something like: import osa finder = osa.getApp("Finder") finder.empty_trash() textEdit = osa.getApp("TextEdit") text = textEdit.doument[1].text print text to replace the AppleScript code: tell app "Finder" to empty trash tell app "TextEdit" theText = the text of the front document display dialog theText end tell Most of the code to do stuff like this is probably already present in PyObjC. Instead of getting class info from the ObjC runtime, you would read the application's .scriptSuite files, and instead of bridging to ObjC, you would be sending AppleEvents. Otherwise it should be pretty similar, right? So, is any of this possible? Peter |
From: <bo...@pa...> - 2003-03-02 01:53:48
|
adding this line into TableModel2 produces weird tool tips, and eventually a sigbus error: def tableView_objectValueForTableColumn_row_( self, aTableView, aTableColumn, rowIndex): + tag = aTableView.addToolTipRect_owner_userData_(aTableView.rectOfRow_(rowIndex ), "tool tip", 1234) print "tableView:objectValueForTableColumn:row: called" return "{%s, %d}"%(aTableColumn.identifier(), rowIndex) changing it to: + tag = aTableView.addToolTipRect_owner_userData_(aTableView.rectOfRow_(rowIndex ), self, 1234) works (and produces a nice <PyModel > message), but add a description() method works even better: def description(self): return NSString.stringWithString_("tool tip") arent literal strings in a constant pool? or do they have to be retained? any ideas why the first solution fails? thanks, bob bo...@pa... |
From: <bo...@pa...> - 2003-03-02 00:53:03
|
for - (NSToolTipTag)addToolTipRect:(NSRect)aRect owner:(id)anObject userData:(void *)userData this invocation fails: self.theTableView.addToolTipRect_owner_userData_(self.theTableView.rectO fRow_(rowIndex), self, None) but this one succeeds: self.theTableView.addToolTipRect_owner_userData_(self.theTableView.rectO fRow_(rowIndex), self, 5) however, nothing gets passed to stringForToolTip in userData # - (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point userData:(void *)data def view_stringForToolTip_point_userData_(self, view, tag, point, userData): print self print view print tag print point print userData print "----" return "bar" <MyAppDelegate: 0xa0d890> <NSTableView: 0x9fa1c0> 70 (564.0, 8.0) None ---- --bob pasker bo...@pa... |
From: <bo...@pa...> - 2003-03-02 00:34:44
|
never mind about the argument count being wrong. i forgot the view. --bob - (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point userData:(void *)userData On Saturday, March 1, 2003, at 04:27 PM, Bob Pasker wrote: > > i still think there's a problem with the argument counts. my first pass > at the signature was: > > def view_stringForToolTip_point_userData_(self, tag, point, > userData): > > but the it complaied about not enough arguments, so i changed it to > > def view_stringForToolTip_point_userData_(self, tag, point, > userData, someVoid): |
From: <bo...@pa...> - 2003-03-02 00:27:43
|
NSToolTipOwner = _objc.informal_protocol( 'NSToolTipOwner', [ _objc.selector( None, selector='view:stringForToolTip:point:userData:', signature='@@:@i{_NSPoint=ff}i^v', required=1 ), ] ) should be signature='@@:@i{_NSPoint=ff}n^v' i still think there's a problem with the argument counts. my first pass at the signature was: def view_stringForToolTip_point_userData_(self, tag, point, userData): but the it complaied about not enough arguments, so i changed it to def view_stringForToolTip_point_userData_(self, tag, point, userData, someVoid): and that works. --bob |
From: <bo...@pa...> - 2003-03-01 22:12:16
|
when i used the wrong number of formal parameters in an informal protocol, i got this message: TypeError: view_stringForToolTip_point_userData_() takes exactly 4 arguments (6 given) os i added a fifth argument, and got: TypeError: view_stringForToolTip_point_userData_() takes exactly 5 arguments (6 given) i think this means the 4 and the 6 are backwards, it should read: TypeError: view_stringForToolTip_point_userData_() takes exactly 6 arguments (4 given) wanted to fix it, but couldn't find where it's generated from. --bob [mudroommac:/sw/lib/python2.2] rbp% find . -type f -name '*' -exec grep -H "takes %s %d argument%s" {} \; Binary file ./config/libpython2.2.a matches Binary file ./config/libpython2.2.dylib matches |
From: <bo...@pa...> - 2003-03-01 22:07:11
|
On Saturday, March 1, 2003, at 01:42 PM, bb...@ma... wrote: > The compiler generates the signatures at compile time. They > signatures 090astored in the OBJC segments within the mach-o > executable. thanks for the explanation. it makes sense now. --bob |
From: <bb...@ma...> - 2003-03-01 21:42:43
|
On Saturday, Mar 1, 2003, at 16:08 US/Eastern, Bob Pasker wrote: > i see, you mean _C_CHR is used when an objc method has a > unadorned char in the signature. > > why not define "_C_BOOL", which is special-cased in the pythonify/ > depythonify routines to handled any range of integer, strings, > None/not None, etc., akin _C_[U]LNGLNG. The various _C_* types are defined by Objective-C itself. See /usr/include/objc/objc-class.h. They are used to figure out how to convert the various arguments of an ObjC method to/from Python. Every ObjC method has a selector and a signature. The selector is the name of the method -- "setObject:forKey:" or "arrayWithArray:" or "hash". The signature contains the type information for the arguments and return value. A signature of "c@:@@i" means: - return a char - arg 0 is an object (self) - arg 1 is a selector (_cmd -- the name of the method being invoked... very handy, that) - arg 2 and 3 are objects - arg 4 is an integer The compiler generates the signatures at compile time. They signatures 090astored in the OBJC segments within the mach-o executable. b.bum |
From: <bb...@ma...> - 2003-03-01 21:39:18
|
On Saturday, Mar 1, 2003, at 15:18 US/Eastern, Ronald Oussoren wrote: > On Saturday, Mar 1, 2003, at 20:56 Europe/Amsterdam, Bob Pasker wrote: >> this begs the question: in pyobjc, is the 'c' in a method signature >> ONLY used for BOOL types? > Nope, 'c' is used for 'char', hence the _C_CHR ;-) ;-). What does _C_BFLD mean? I had used it successfully in the past for a BOOL, but I don't remember why it worked or what it really means. > I'm afraid this is one of the places where the bridge cannot be > completely transparent. In Python you can use any object as a boolean > (most are evaluated as true, some are false), but with PyObjC you'll > have to use small integers. I suppose that if the method really does want a (char) vs. a (BOOL), then typecasting and losing the implied precision would be bad. However, for (BOOL) methods, an (int) can be passed in pure ObjC.... b.bum |
From: <bo...@pa...> - 2003-03-01 21:08:35
|
i see, you mean _C_CHR is used when an objc method has a unadorned char in the signature. why not define "_C_BOOL", which is special-cased in the pythonify/ depythonify routines to handled any range of integer, strings, None/not None, etc., akin _C_[U]LNGLNG. --bob On Saturday, March 1, 2003, at 12:18 PM, Ronald Oussoren wrote: > > On Saturday, Mar 1, 2003, at 20:56 Europe/Amsterdam, Bob Pasker wrote: > >> this begs the question: in pyobjc, is the 'c' in a method signature >> ONLY used for BOOL types? > Nope, 'c' is used for 'char', hence the _C_CHR ;-) ;-). |
From: Ronald O. <ous...@ci...> - 2003-03-01 20:26:37
|
This checkin also involves some user-visible semantic changes: 1) The conversion to native C types no longer cuts of the most significant bits if they wouldn't fit into the C type. 2) At the same time the bridge tries harder to convert the argument to a proper type, the bridge now calls int() when it wants to convert to a C integer type and float() when it wants to convert to a C floating point type. The conversion to integer types now always accept python longs as well as Python ints. This should make us more consistent with the rest of python. The conversion code could do with some refactoring, there is too much code duplication at the moment. Ronald On Saturday, Mar 1, 2003, at 21:07 Europe/Amsterdam, Ronald Oussoren wrote: > Update of /cvsroot/pyobjc/pyobjc/Modules/objc > In directory sc8-pr-cvs1:/tmp/cvs-serv5997/Modules/objc > > Modified Files: > OC_PythonObject.m informal-protocol.m libffi_support.m > module.m objc_support.m pyobjc-api.h pyobjc.h selector.m > Log Message: > - PyObjC_HAVE_PYTHON_BOOL was defined when we didn't have a Python > bool type > - Fix for BOOL return types of Python methods, Examples/TableModel > contains > a NSTableView where every other row is disabled. > - informal_protocols can be inspected from python (__name__ and > selectors) > - removed some compile-time warnings (the only ones left are caused by > libffi, > not under our control) > - Expanded unittests for basic message passing from Python to > Objective-C, > and fixed the bugs that were uncovered by this. The unittests are > not yet > complete, and the route from Objective-C to Python is not yet > tested, but > were getting closer. > - INSTALL mentions you have to install libffi first > > > Index: OC_PythonObject.m > =================================================================== > RCS file: /cvsroot/pyobjc/pyobjc/Modules/objc/OC_PythonObject.m,v > retrieving revision 1.10 > retrieving revision 1.11 > diff -C2 -d -r1.10 -r1.11 > *** OC_PythonObject.m 23 Feb 2003 08:58:42 -0000 1.10 > --- OC_PythonObject.m 1 Mar 2003 20:06:58 -0000 1.11 > *************** > *** 222,226 **** > unsigned int i; > unsigned int argcount; > - PyCodeObject* func_code; > int retsize = objc_sizeof_type (rettype); > char* retbuffer; > --- 222,225 ---- > > Index: informal-protocol.m > =================================================================== > RCS file: /cvsroot/pyobjc/pyobjc/Modules/objc/informal-protocol.m,v > retrieving revision 1.3 > retrieving revision 1.4 > diff -C2 -d -r1.3 -r1.4 > *** informal-protocol.m 6 Jan 2003 21:15:18 -0000 1.3 > --- informal-protocol.m 1 Mar 2003 20:06:59 -0000 1.4 > *************** > *** 5,8 **** > --- 5,9 ---- > */ > #include <Python.h> > + #include "structmember.h" /* needed for PyMemberDef */ > #include "pyobjc.h" > #include "objc_support.h" > *************** > *** 72,75 **** > --- 73,81 ---- > } > > + selectors = PySequence_Tuple(selectors); > + if (selectors == NULL) { > + return NULL; > + } > + > result = (ObjCInformalProtocol*)PyObject_New( > ObjCInformalProtocol, &ObjCInformalProtocol_Type); > *************** > *** 79,83 **** > > Py_XINCREF(name); > - Py_XINCREF(selectors); > > return (PyObject*)result; > --- 85,88 ---- > *************** > *** 96,99 **** > --- 101,122 ---- > } > > + static PyMemberDef proto_members[] = { > + { > + "__name__", > + T_OBJECT, > + offsetof(ObjCInformalProtocol, name), > + READONLY, > + NULL > + }, > + { > + "selectors", > + T_OBJECT, > + offsetof(ObjCInformalProtocol, selectors), > + READONLY, > + NULL > + }, > + > + { 0, 0, 0, 0, 0 } > + }; > > PyTypeObject ObjCInformalProtocol_Type = { > *************** > *** 128,132 **** > 0, /* tp_iternext */ > 0, /* tp_methods */ > ! 0, /* tp_members */ > 0, /* proto_getset , */ /* tp_getset */ > 0, /* tp_base */ > --- 151,155 ---- > 0, /* tp_iternext */ > 0, /* tp_methods */ > ! proto_members, /* tp_members */ > 0, /* proto_getset , */ /* tp_getset */ > 0, /* tp_base */ > > Index: libffi_support.m > =================================================================== > RCS file: /cvsroot/pyobjc/pyobjc/Modules/objc/libffi_support.m,v > retrieving revision 1.15 > retrieving revision 1.16 > diff -C2 -d -r1.15 -r1.16 > *** libffi_support.m 23 Feb 2003 16:15:32 -0000 1.15 > --- libffi_support.m 1 Mar 2003 20:06:59 -0000 1.16 > *************** > *** 72,75 **** > --- 72,141 ---- > > static ffi_type* > + array_to_ffi_type(const char* argtype) > + { > + static PyObject* array_types = NULL; > + PyObject* v; > + ffi_type* type; > + int field_count; > + int i; > + > + if (array_types == NULL) { > + array_types = PyDict_New(); > + if (array_types == NULL) return NULL; > + } > + > + v = PyDict_GetItemString(array_types, (char*)argtype); > + if (v != NULL) { > + return (ffi_type*)PyCObject_AsVoidPtr(v); > + } > + > + /* We don't have a type description yet, dynamicly > + * create it. > + */ > + field_count = atoi(argtype+1); > + > + type = malloc(sizeof(*type)); > + if (type == NULL) { > + PyErr_NoMemory(); > + return NULL; > + } > + type->size = 0; > + type->alignment = 0; > + > + /* Libffi doesn't really know about arrays as part of larger > + * data-structres (e.g. struct foo { int field[3]; };). We fake it > + * by treating the nested array as a struct. These seems to work > + * fine on MacOS X. > + */ > + type->type = FFI_TYPE_STRUCT; > + type->elements = malloc((1+field_count) * sizeof(*type->elements)); > + if (type->elements == NULL) { > + free(type); > + PyErr_NoMemory(); > + return NULL; > + } > + > + while (isdigit(*++argtype)); > + type->elements[0] = signature_to_ffi_type(argtype); > + for (i = 1; i < field_count; i++) { > + type->elements[i] = type->elements[0]; > + } > + type->elements[field_count] = 0; > + > + v = PyCObject_FromVoidPtr(type, free_type); > + if (v == NULL) { > + free_type(type); > + return NULL; > + } > + > + PyDict_SetItemString(array_types, (char*)argtype, v); > + if (PyErr_Occurred()) { > + Py_DECREF(v); > + return NULL; > + } > + return type; > + } > + > + static ffi_type* > struct_to_ffi_type(const char* argtype) > { > *************** > *** 150,153 **** > --- 216,220 ---- > return type; > } > + > static ffi_type* > signature_to_ffi_return_type(const char* argtype) > *************** > *** 185,189 **** > case _C_CHARPTR: return &ffi_type_pointer; > case _C_PTR: return &ffi_type_pointer; > ! case _C_ARY_B: return &ffi_type_pointer; > case _C_IN: case _C_OUT: case _C_INOUT: case _C_CONST: > return signature_to_ffi_type(argtype+1); > --- 252,257 ---- > case _C_CHARPTR: return &ffi_type_pointer; > case _C_PTR: return &ffi_type_pointer; > ! case _C_ARY_B: > ! return array_to_ffi_type(argtype); > case _C_IN: case _C_OUT: case _C_INOUT: case _C_CONST: > return signature_to_ffi_type(argtype+1); > *************** > *** 370,374 **** > int i; > const char* rettype; > - char buf[2]; > > methinfo = [NSMethodSignature signatureWithObjCTypes:signature]; > --- 438,441 ---- > *************** > *** 514,518 **** > int itemSize; > int itemAlign; > - char tpBuf[2]; > > if (meth->sel_oc_signature) { > --- 581,584 ---- > *************** > *** 782,786 **** > case _C_CONST: > > ! if (argbuf[1] == _C_PTR) { > /* Allocate space and encode */ > argbuf_cur = align(argbuf_cur, objc_alignof_type(argtype+2)); > --- 848,852 ---- > case _C_CONST: > > ! if (argtype[1] == _C_PTR) { > /* Allocate space and encode */ > argbuf_cur = align(argbuf_cur, objc_alignof_type(argtype+2)); > *************** > *** 794,798 **** > > arglist[arglistOffset + i] = &ffi_type_pointer; > ! values[arglistOffset + i] = arg; > > } else { > --- 860,864 ---- > > arglist[arglistOffset + i] = &ffi_type_pointer; > ! values[arglistOffset + i] = byref + i; > > } else { > > Index: module.m > =================================================================== > RCS file: /cvsroot/pyobjc/pyobjc/Modules/objc/module.m,v > retrieving revision 1.20 > retrieving revision 1.21 > diff -C2 -d -r1.20 -r1.21 > *** module.m 23 Feb 2003 08:58:43 -0000 1.20 > --- module.m 1 Mar 2003 20:06:59 -0000 1.21 > *************** > *** 431,468 **** > } > > ! PyObject* func_setArgv0(PyObject* self, PyObject* args, PyObject* > kwds) > { > ! typedef struct { > ! @defs(NSProcessInfo) > ! } NSProcessInfoStruct; > ! > ! static char* keywords[] = { "argv0", NULL }; > ! char* argv0; > ! NSProcessInfo *processInfo = [NSProcessInfo processInfo]; > ! NSMutableArray *argv = [NSMutableArray arrayWithArray: > ! ((NSProcessInfoStruct *)processInfo)->arguments]; > ! [argv retain]; > > if (!PyArg_ParseTupleAndKeywords(args, kwds, > ! "s:setArgv0", > ! keywords, &argv0)) { > return NULL; > } > > ! > ! //[argv replaceObjectAtIndex:0 withObject: [NSString > stringWithUTF8String:argv0]]; > ! [argv insertObject: [NSString stringWithUTF8String:argv0] > atIndex:0]; > ! ((NSProcessInfoStruct *)processInfo)->arguments = argv; > > ! Py_INCREF(Py_None); > ! return Py_None; > } > > static PyMethodDef meta_methods[] = { > { > ! "setArgv0", > ! (PyCFunction)func_setArgv0, > METH_VARARGS|METH_KEYWORDS, > ! NULL > }, > { > --- 431,488 ---- > } > > ! PyDoc_STRVAR(objc_splitSignature_doc, > ! "splitSignature(signature) -> list\n" > ! "\n" > ! "Split a signature string into a list of items." > ! ); > ! PyObject* > ! objc_splitSignature(PyObject* self, PyObject* args, PyObject* kwds) > { > ! static char* keywords[] = { "signature", NULL }; > ! const char* signature; > ! const char* end; > ! PyObject* result; > > if (!PyArg_ParseTupleAndKeywords(args, kwds, > ! "s:splitSignature", > ! keywords, &signature)) { > return NULL; > } > > ! result = PyList_New(0); > ! if (result == NULL) return NULL; > ! > ! while (*signature != 0) { > ! PyObject* str; > > ! end = objc_skip_typespec(signature); > ! if (end == NULL) { > ! Py_DECREF(result); > ! return NULL; > ! } > ! > ! str = PyString_FromStringAndSize(signature, end - signature); > ! if (str == NULL) { > ! Py_DECREF(result); > ! return NULL; > ! } > ! > ! if (PyList_Append(result, str) == -1) { > ! Py_DECREF(result); > ! return NULL; > ! } > ! > ! signature = end; > ! } > ! return result; > } > > + > static PyMethodDef meta_methods[] = { > { > ! "splitSignature", > ! (PyCFunction)objc_splitSignature, > METH_VARARGS|METH_KEYWORDS, > ! objc_splitSignature_doc > }, > { > > Index: objc_support.m > =================================================================== > RCS file: /cvsroot/pyobjc/pyobjc/Modules/objc/objc_support.m,v > retrieving revision 1.29 > retrieving revision 1.30 > diff -C2 -d -r1.29 -r1.30 > *** objc_support.m 28 Feb 2003 10:20:40 -0000 1.29 > --- objc_support.m 1 Mar 2003 20:06:59 -0000 1.30 > *************** > *** 415,419 **** > { > PyObject *ret; > ! unsigned int nitems, offset, itemidx, sizeofitem; > > nitems = atoi (type+1); > --- 415,420 ---- > { > PyObject *ret; > ! unsigned int nitems, itemidx, sizeofitem; > ! unsigned char* curdatum; > > nitems = atoi (type+1); > *************** > *** 426,433 **** > if (!ret) return NULL; > > ! for (offset=itemidx=0; itemidx < nitems; itemidx++) { > PyObject *pyitem = NULL; > > ! pyitem = pythonify_c_value (type, datum+offset); > > if (pyitem) { > --- 427,435 ---- > if (!ret) return NULL; > > ! curdatum = datum; > ! for (itemidx=0; itemidx < nitems; itemidx++) { > PyObject *pyitem = NULL; > > ! pyitem = pythonify_c_value (type, curdatum); > > if (pyitem) { > *************** > *** 438,442 **** > } > > ! offset += sizeofitem; > } > > --- 440,444 ---- > } > > ! curdatum += sizeofitem; > } > > *************** > *** 488,497 **** > depythonify_c_array (const char *type, PyObject *arg, void *datum) > { > ! unsigned int nitems, offset, itemidx, sizeofitem; > > nitems = atoi (type+1); > while (isdigit (*++type)) > ; > ! sizeofitem = objc_sizeof_type (type); > if (sizeofitem == -1) { > ObjCErr_Set(ObjCExc_error, > --- 490,500 ---- > depythonify_c_array (const char *type, PyObject *arg, void *datum) > { > ! unsigned int nitems, itemidx, sizeofitem; > ! unsigned char* curdatum; > > nitems = atoi (type+1); > while (isdigit (*++type)) > ; > ! sizeofitem = objc_aligned_size (type); > if (sizeofitem == -1) { > ObjCErr_Set(ObjCExc_error, > *************** > *** 507,518 **** > } > > ! for (offset=itemidx=0; itemidx < nitems; itemidx++) { > PyObject *pyarg = PyTuple_GetItem (arg, itemidx); > int err; > > ! err = depythonify_c_value (type, pyarg, datum+offset); > if (err == -1) return err; > > ! offset += sizeofitem; > } > > --- 510,522 ---- > } > > ! curdatum = datum; > ! for (itemidx=0; itemidx < nitems; itemidx++) { > PyObject *pyarg = PyTuple_GetItem (arg, itemidx); > int err; > > ! err = depythonify_c_value (type, pyarg, curdatum); > if (err == -1) return err; > > ! curdatum += sizeofitem; > } > > *************** > *** 564,577 **** > > switch (*type) { > - case _C_ULNGLNG: > - retobject = (PyObject*)PyLong_FromUnsignedLongLong(*(unsigned long > long*)datum); > - break; > - > - case _C_LNGLNG: > - retobject = (PyObject*)PyLong_FromLongLong(*(long long*)datum); > - break; > - > case _C_CHR: > ! /* XXX: Why not return a string of length 1 */ > retobject = (PyObject*)PyInt_FromLong ((int)(*(char*)datum)); > break; > --- 568,574 ---- > > switch (*type) { > case _C_CHR: > ! // We don't return a string because BOOL is an alias for > ! // char (at least on MacOS X) > retobject = (PyObject*)PyInt_FromLong ((int)(*(char*)datum)); > break; > *************** > *** 631,634 **** > --- 628,639 ---- > break; > > + case _C_ULNGLNG: > + retobject = (PyObject*)PyLong_FromUnsignedLongLong(*(unsigned long > long*)datum); > + break; > + > + case _C_LNGLNG: > + retobject = (PyObject*)PyLong_FromLongLong(*(long long*)datum); > + break; > + > case _C_FLT: > retobject = (PyObject *) PyFloat_FromDouble (*(float*) datum); > *************** > *** 757,761 **** > > switch(*type) { > ! case _C_CHR: case _C_SHT: > return pythonify_c_value(intType, datum); > case _C_UCHR: case _C_USHT: > --- 762,767 ---- > > switch(*type) { > ! case _C_CHR: > ! case _C_SHT: > return pythonify_c_value(intType, datum); > case _C_UCHR: case _C_USHT: > *************** > *** 772,775 **** > --- 778,783 ---- > /* TODO: Examine whether using PyArg_Parse would be usefull to > translate > * basic types (range checking for free!) > + * > + * This function is way too large! > */ > int > *************** > *** 784,837 **** > > switch (*type) { > - case _C_ULNGLNG: > - if (PyInt_Check(argument)) { > - long value = PyInt_AsLong(argument); > - if (value < 0) { > - ObjCErr_Set(ObjCExc_error, > - "depythonifying 'unsigned long long'," > - "got negative %s", > - argument->ob_type->tp_name); > - return -1; > - } > - *(unsigned long long*)datum = (unsigned long long)value; > - } else if (PyLong_Check(argument)) { > - *(unsigned long long*)datum = > - PyLong_AsUnsignedLongLong(argument); > - if (PyErr_Occurred()) { > - ObjCErr_Set(ObjCExc_error, > - "depythonifying 'unsigned long long'," > - "got %s of wrong magnitude", > - argument->ob_type->tp_name); > - return -1; > - } > - } else { > - ObjCErr_Set(ObjCExc_error, > - "depythonifying 'unsigned long long', got %s", > - argument->ob_type->tp_name); > - return -1; > - } > - break; > - > - case _C_LNGLNG: > - if (PyInt_Check(argument)) { > - *(long long*)datum = PyInt_AsLong(argument); > - } else if (PyLong_Check(argument)) { > - *(long long*)datum = > - PyLong_AsLongLong(argument); > - if (PyErr_Occurred()) { > - ObjCErr_Set(ObjCExc_error, > - "depythonifying 'long long'," > - "got %s of wrong magnitude", > - argument->ob_type->tp_name); > - return -1; > - } > - } else { > - ObjCErr_Set(ObjCExc_error, > - "depythonifying 'long long', got %s", > - argument->ob_type->tp_name); > - return -1; > - } > - break; > - > case _C_CHR: > if (PyInt_Check (argument)) { > --- 792,795 ---- > *************** > *** 839,843 **** > if (temp < CHAR_MIN || temp > CHAR_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 797,801 ---- > if (temp < CHAR_MIN || temp > CHAR_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 849,853 **** > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 807,811 ---- > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 857,861 **** > if (temp < CHAR_MIN || temp > CHAR_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 815,819 ---- > if (temp < CHAR_MIN || temp > CHAR_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 867,872 **** > *(char *) datum = PyString_AsString (argument)[0]; > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got %s of %d", > argument->ob_type->tp_name, > PyString_Size(argument)); > --- 825,841 ---- > *(char *) datum = PyString_AsString (argument)[0]; > } else { > + PyObject* tmp = PyNumber_Int(argument); > + if (tmp != NULL) { > + long temp = PyInt_AsLong(tmp); > + Py_DECREF(tmp); > + > + if (temp >= CHAR_MIN && temp <= CHAR_MAX) { > + *(char *) datum = temp; > + return 0; > + } > + } > + > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got '%s' of %d", > argument->ob_type->tp_name, > PyString_Size(argument)); > *************** > *** 881,885 **** > if (temp < 0 || temp > UCHAR_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 850,854 ---- > if (temp < 0 || temp > UCHAR_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 893,897 **** > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 862,866 ---- > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 901,905 **** > if (temp < 0 || temp > UCHAR_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 870,874 ---- > if (temp < 0 || temp > UCHAR_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'char', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 912,917 **** > PyString_AsString (argument)[0]; > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned char', got %s of %d", > argument->ob_type->tp_name, > PyString_Size(argument)); > --- 881,900 ---- > PyString_AsString (argument)[0]; > } else { > + PyObject* tmp = PyNumber_Int(argument); > + if (tmp != NULL) { > + > + if (PyInt_Check(tmp)) { > + long temp = PyInt_AsLong(tmp); > + Py_DECREF(tmp); > + if (temp >= 0 && temp <= UCHAR_MAX) { > + *(unsigned char *) datum = temp; > + return 0; > + } > + } else { > + Py_DECREF(tmp); > + } > + } > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned char', got '%s' of %d", > argument->ob_type->tp_name, > PyString_Size(argument)); > *************** > *** 923,927 **** > if (!PyString_Check (argument) && argument != Py_None) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'charptr', got %s", > argument->ob_type->tp_name); > return -1; > --- 906,910 ---- > if (!PyString_Check (argument) && argument != Py_None) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'charptr', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 944,948 **** > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'int', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 927,931 ---- > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'int', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 952,956 **** > if (temp < INT_MIN || temp > INT_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'int', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 935,939 ---- > if (temp < INT_MIN || temp > INT_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'int', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 960,965 **** > *(long*) datum = temp; > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'int', got %s", > argument->ob_type->tp_name); > return -1; > --- 943,958 ---- > *(long*) datum = temp; > } else { > + PyObject* tmp = PyNumber_Int(argument); > + if (tmp != NULL) { > + if (PyInt_Check(tmp)) { > + *(int*) datum = PyInt_AsLong(tmp); > + Py_DECREF(tmp); > + return 0; > + } else { > + Py_DECREF(tmp); > + } > + } > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'int', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 973,977 **** > if (temp < SHRT_MIN || temp > SHRT_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'short', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 966,970 ---- > if (temp < SHRT_MIN || temp > SHRT_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'short', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 985,989 **** > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'short', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 978,982 ---- > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'short', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 993,997 **** > if (temp < SHRT_MIN || temp > SHRT_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'short', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 986,990 ---- > if (temp < SHRT_MIN || temp > SHRT_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'short', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 1001,1006 **** > *(short*) datum = temp; > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'short', got %s", > argument->ob_type->tp_name); > return -1; > --- 994,1013 ---- > *(short*) datum = temp; > } else { > + PyObject* tmp = PyNumber_Int(argument); > + if (tmp != NULL) { > + if (PyInt_Check(tmp)) { > + long temp = PyInt_AsLong(tmp); > + Py_DECREF(tmp); > + if (temp >= SHRT_MIN && > + temp <= SHRT_MAX) { > + *(short*) datum = temp; > + return 0; > + } > + } else { > + Py_DECREF(tmp); > + } > + } > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'short', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1014,1018 **** > if (temp < 0) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned int', got %s " > "of wrong magnitude", > argument->ob_type->tp_name); > --- 1021,1025 ---- > if (temp < 0) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned int', got '%s' " > "of wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 1026,1030 **** > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned int', got %s " > "of wrong magnitude", > argument->ob_type->tp_name); > --- 1033,1037 ---- > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned int', got '%s' " > "of wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 1034,1038 **** > if (temp > UINT_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned int', got %s " > "of wrong magnitude", > argument->ob_type->tp_name); > --- 1041,1045 ---- > if (temp > UINT_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned int', got '%s' " > "of wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 1042,1047 **** > *(unsigned int*) datum = temp; > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned int', got %s", > argument->ob_type->tp_name); > return -1; > --- 1049,1084 ---- > *(unsigned int*) datum = temp; > } else { > + PyObject* tmp = PyNumber_Int(argument); > + if (tmp != NULL) { > + if (PyInt_Check(tmp)) { > + long temp = PyInt_AsLong(tmp); > + Py_DECREF(tmp); > + if (temp >= 0) { > + *(unsigned int *) datum = temp; > + return 0; > + } > + } else if (PyLong_Check(tmp)) { > + long long temp = PyLong_AsLongLong(tmp); > + Py_DECREF(tmp); > + if (temp >= 0 && temp <= ULONG_MAX) { > + *(unsigned int*) datum = temp; > + return 0; > + } > + } else { > + Py_DECREF(tmp); > + } > + } > + tmp = PyNumber_Long(argument); > + if (tmp != NULL) { > + long long temp = PyLong_AsLongLong(tmp); > + Py_DECREF(tmp); > + if (!PyErr_Occurred() && temp >= 0) { > + *(unsigned int*) datum = temp; > + return 0; > + } > + } > + > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned int', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1056,1060 **** > ObjCErr_Set(ObjCExc_error, > "depythonifying 'unsigned short', " > ! "got %s of wrong magnitude", > argument->ob_type->tp_name); > return -1; > --- 1093,1097 ---- > ObjCErr_Set(ObjCExc_error, > "depythonifying 'unsigned short', " > ! "got '%s' of wrong magnitude", > argument->ob_type->tp_name); > return -1; > *************** > *** 1068,1072 **** > ObjCErr_Set(ObjCExc_error, > "depythonifying 'unsigned short', " > ! "got %s of wrong magnitude", > argument->ob_type->tp_name); > return -1; > --- 1105,1109 ---- > ObjCErr_Set(ObjCExc_error, > "depythonifying 'unsigned short', " > ! "got '%s' of wrong magnitude", > argument->ob_type->tp_name); > return -1; > *************** > *** 1076,1080 **** > ObjCErr_Set(ObjCExc_error, > "depythonifying 'unsigned short', " > ! "got %s of wrong magnitude", > argument->ob_type->tp_name); > return -1; > --- 1113,1117 ---- > ObjCErr_Set(ObjCExc_error, > "depythonifying 'unsigned short', " > ! "got '%s' of wrong magnitude", > argument->ob_type->tp_name); > return -1; > *************** > *** 1083,1088 **** > *(unsigned short*) datum = temp; > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned short', got %s", > argument->ob_type->tp_name); > return -1; > --- 1120,1139 ---- > *(unsigned short*) datum = temp; > } else { > + PyObject* tmp = PyNumber_Int(argument); > + if (tmp != NULL) { > + if (PyInt_Check(tmp)) { > + long temp = PyInt_AsLong(tmp); > + Py_DECREF(tmp); > + if (temp >= 0 && temp <= USHRT_MAX) { > + *(unsigned short *) datum = temp; > + return 0; > + } > + } else { > + Py_DECREF(tmp); > + } > + } > + > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned short', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1099,1103 **** > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'long', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 1150,1154 ---- > if (PyErr_Occurred()) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'long', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 1107,1111 **** > if (temp < LONG_MIN || temp > LONG_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'long', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > --- 1158,1162 ---- > if (temp < LONG_MIN || temp > LONG_MAX) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'long', got '%s' of " > "wrong magnitude", > argument->ob_type->tp_name); > *************** > *** 1115,1120 **** > *(long*) datum = temp; > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'long', got %s", > argument->ob_type->tp_name); > return -1; > --- 1166,1181 ---- > *(long*) datum = temp; > } else { > + PyObject* tmp = PyNumber_Int(argument); > + if (tmp != NULL) { > + if (PyInt_Check(tmp)) { > + *(long*) datum = PyInt_AsLong(tmp); > + Py_DECREF(tmp); > + return 0; > + } else { > + Py_DECREF(tmp); > + } > + } > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'long', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1132,1136 **** > ObjCErr_Set(ObjCExc_error, > "depythonifying 'unsigned long', " > ! "got %s of wrong magnitude", > argument->ob_type->tp_name); > return -1; > --- 1193,1197 ---- > ObjCErr_Set(ObjCExc_error, > "depythonifying 'unsigned long', " > ! "got '%s' of wrong magnitude", > argument->ob_type->tp_name); > return -1; > *************** > *** 1140,1144 **** > ObjCErr_Set(ObjCExc_error, > "depythonifying 'unsigned long', " > ! "got %s of wrong magnitude", > argument->ob_type->tp_name); > return -1; > --- 1201,1205 ---- > ObjCErr_Set(ObjCExc_error, > "depythonifying 'unsigned long', " > ! "got '%s' of wrong magnitude", > argument->ob_type->tp_name); > return -1; > *************** > *** 1147,1152 **** > *(unsigned long*) datum = temp; > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned long', got %s", > argument->ob_type->tp_name); > return -1; > --- 1208,1283 ---- > *(unsigned long*) datum = temp; > } else { > + PyObject* tmp = PyNumber_Int(argument); > + if (tmp != NULL) { > + if (PyInt_Check(tmp)) { > + long temp = PyInt_AsLong(tmp); > + Py_DECREF(tmp); > + if (temp >= 0) { > + *(unsigned long *) datum = temp; > + return 0; > + } > + } else if (PyLong_Check(tmp)) { > + unsigned long long temp = > + PyLong_AsUnsignedLongLong(tmp); > + Py_DECREF(tmp); > + if (!PyErr_Occurred() && temp <= ULONG_MAX) { > + *(unsigned long*) datum = temp; > + return 0; > + } > + } else { > + Py_DECREF(tmp); > + } > + } > + tmp = PyNumber_Long(argument); > + if (tmp != NULL) { > + unsigned long long temp = > + PyLong_AsUnsignedLongLong(tmp); > + Py_DECREF(tmp); > + if (!PyErr_Occurred() && temp <= ULONG_MAX) { > + *(unsigned long*) datum = temp; > + return 0; > + } > + } > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned long', got '%s'", > ! argument->ob_type->tp_name); > ! return -1; > ! } > ! break; > ! > ! case _C_ULNGLNG: > ! if (PyInt_Check(argument)) { > ! long value = PyInt_AsLong(argument); > ! if (value < 0) { > ! ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned long long'," > ! "got negative '%s'", > ! argument->ob_type->tp_name); > ! return -1; > ! } > ! *(unsigned long long*)datum = (unsigned long long)value; > ! } else if (PyLong_Check(argument)) { > ! *(unsigned long long*)datum = > ! PyLong_AsUnsignedLongLong(argument); > ! if (PyErr_Occurred()) { > ! ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned long long'," > ! "got '%s' of wrong magnitude", > ! argument->ob_type->tp_name); > ! return -1; > ! } > ! } else { > ! PyObject* tmp = PyNumber_Long(argument); > ! if (tmp != NULL) { > ! unsigned long long temp = > ! PyLong_AsUnsignedLongLong(tmp); > ! Py_DECREF(tmp); > ! if (!PyErr_Occurred()) { > ! *(unsigned long long *) datum = temp; > ! return 0; > ! } > ! } > ! ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'unsigned long long', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1154,1157 **** > --- 1285,1319 ---- > break; > > + case _C_LNGLNG: > + if (PyInt_Check(argument)) { > + *(long long*)datum = PyInt_AsLong(argument); > + } else if (PyLong_Check(argument)) { > + *(long long*)datum = > + PyLong_AsLongLong(argument); > + if (PyErr_Occurred()) { > + ObjCErr_Set(ObjCExc_error, > + "depythonifying 'long long'," > + "got '%s' of wrong magnitude", > + argument->ob_type->tp_name); > + return -1; > + } > + } else { > + PyObject* tmp = PyNumber_Long(argument); > + if (tmp != NULL) { > + long long temp = PyLong_AsLongLong(tmp); > + Py_DECREF(tmp); > + if (!PyErr_Occurred()) { > + *(long long*) datum = temp; > + return 0; > + } > + } > + ObjCErr_Set(ObjCExc_error, > + "depythonifying 'long long', got '%s'", > + argument->ob_type->tp_name); > + return -1; > + } > + break; > + > + > case _C_ID: > if (argument == Py_None) { > *************** > *** 1179,1183 **** > "strict"); > if (as_unicode == NULL) { > ! ObjCErr_Set(ObjCExc_error, > "depythonifying 'id', got " > "a string with a non-default " > --- 1341,1345 ---- > "strict"); > if (as_unicode == NULL) { > ! ObjCErr_Set(PyExc_UnicodeError, > "depythonifying 'id', got " > "a string with a non-default " > *************** > *** 1257,1261 **** > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'Class', got %s", > argument->ob_type->tp_name); > return -1; > --- 1419,1423 ---- > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'Class', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1276,1280 **** > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'SEL', got cannot " > "register string with runtime"); > return -1; > --- 1438,1442 ---- > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'SEL', cannot " > "register string with runtime"); > return -1; > *************** > *** 1282,1286 **** > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'SEL', got %s", > argument->ob_type->tp_name); > return -1; > --- 1444,1448 ---- > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'SEL', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1302,1307 **** > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'pointer', got %s", > argument->ob_type->tp_name); > return -1; > } > --- 1464,1470 ---- > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'pointer', got '%s'", > argument->ob_type->tp_name); > + abort(); > return -1; > } > *************** > *** 1314,1319 **** > *(float *) datum = (float) PyInt_AsLong (argument); > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'float', got %s", > argument->ob_type->tp_name); > return -1; > --- 1477,1490 ---- > *(float *) datum = (float) PyInt_AsLong (argument); > } else { > + PyObject* tmp = PyNumber_Float(argument); > + if (tmp != NULL) { > + double temp = PyFloat_AsDouble(tmp); > + Py_DECREF(tmp); > + *(float*) datum = temp; > + return 0; > + } > + > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'float', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1327,1332 **** > *(double *) datum = (double) PyInt_AsLong (argument); > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'double', got %s", > argument->ob_type->tp_name); > return -1; > --- 1498,1511 ---- > *(double *) datum = (double) PyInt_AsLong (argument); > } else { > + PyObject* tmp = PyNumber_Float(argument); > + if (tmp != NULL) { > + double temp = PyFloat_AsDouble(tmp); > + Py_DECREF(tmp); > + *(double*) datum = temp; > + return 0; > + } > + > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'double', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1357,1361 **** > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'union', got %s", > argument->ob_type->tp_name); > return -1; > --- 1536,1540 ---- > } else { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'union', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1366,1370 **** > if (! PyTuple_Check (argument)) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'struct', got %s", > argument->ob_type->tp_name); > return -1; > --- 1545,1549 ---- > if (! PyTuple_Check (argument)) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'struct', got '%s'", > argument->ob_type->tp_name); > return -1; > *************** > *** 1377,1381 **** > if (! PyTuple_Check (argument)) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'array', got %s", > argument->ob_type->tp_name); > return -1; > --- 1556,1560 ---- > if (! PyTuple_Check (argument)) { > ObjCErr_Set(ObjCExc_error, > ! "depythonifying 'array', got '%s'", > argument->ob_type->tp_name); > return -1; > > Index: pyobjc-api.h > =================================================================== > RCS file: /cvsroot/pyobjc/pyobjc/Modules/objc/pyobjc-api.h,v > retrieving revision 1.8 > retrieving revision 1.9 > diff -C2 -d -r1.8 -r1.9 > *** pyobjc-api.h 26 Feb 2003 14:26:36 -0000 1.8 > --- pyobjc-api.h 1 Mar 2003 20:07:00 -0000 1.9 > *************** > *** 32,38 **** > /* PyBool_Type was introduced in Python 2.3 */ > > - #define PyObjC_HAVE_PYTHON_BOOL > #define PyBool_Check(_x_) (0) > #define PyBool_FromLong(_x_) PyInt_FromLong(_x_) > > #endif /* Python < 2.3.0a */ > --- 32,41 ---- > /* PyBool_Type was introduced in Python 2.3 */ > > #define PyBool_Check(_x_) (0) > #define PyBool_FromLong(_x_) PyInt_FromLong(_x_) > + > + #else > + > + #define PyObjC_HAVE_PYTHON_BOOL > > #endif /* Python < 2.3.0a */ > > Index: pyobjc.h > =================================================================== > RCS file: /cvsroot/pyobjc/pyobjc/Modules/objc/pyobjc.h,v > retrieving revision 1.22 > retrieving revision 1.23 > diff -C2 -d -r1.22 -r1.23 > *** pyobjc.h 26 Feb 2003 14:26:37 -0000 1.22 > --- pyobjc.h 1 Mar 2003 20:07:00 -0000 1.23 > *************** > *** 32,35 **** > --- 32,38 ---- > #define PyBool_Check(_x_) (0) > #define PyBool_FromLong(_x_) PyInt_FromLong(_x_) > + > + #else > + > #define PyObjC_HAVE_PYTHON_BOOL > > > Index: selector.m > =================================================================== > RCS file: /cvsroot/pyobjc/pyobjc/Modules/objc/selector.m,v > retrieving revision 1.18 > retrieving revision 1.19 > diff -C2 -d -r1.18 -r1.19 > *** selector.m 23 Feb 2003 08:58:44 -0000 1.18 > --- selector.m 1 Mar 2003 20:07:00 -0000 1.19 > *************** > *** 490,496 **** > { > PyObject* pyself = self->sel_self; > - Class pyself_class; > ObjC_CallFunc_t execute = NULL; > int is_super_call = 0; > PyObject* res; > > --- 490,498 ---- > { > PyObject* pyself = self->sel_self; > ObjC_CallFunc_t execute = NULL; > + #if !(defined(OC_WITH_LIBFFI) && defined(OC_USE_FFI_SHORTCUTS)) > + Class pyself_class; > int is_super_call = 0; > + #endif > PyObject* res; > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > pyobjc-checkins mailing list > pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-checkins > |
From: Ronald O. <ous...@ci...> - 2003-03-01 20:19:16
|
On Saturday, Mar 1, 2003, at 20:56 Europe/Amsterdam, Bob Pasker wrote: > this begs the question: in pyobjc, is the 'c' in a method signature > ONLY used for BOOL types? Nope, 'c' is used for 'char', hence the _C_CHR ;-) ;-). > if so, then maybe the right answer is to > put the test in obj_support.m, ie, change > > case _C_CHR: case _C_SHT: > return pythonify_c_value(intType, datum); > > to something like: > > case _C_SHT: > return pythonify_c_value(intType, datum); > case _C_CHR: > return (pythonify_c_value(intType, datum) != 0); > > in general, the programmer should return an expression that evaluates > to > 0 or 1 for objc bool parameters. but most languages without a true > boolean type permit integer types to be used as boolean > expression without a boolean operator operators. python falls into > this category, and using the bridge should not require a special > idiom for booleans ("always return/pass a boolean expression, not > an int"). I'm afraid this is one of the places where the bridge cannot be completely transparent. In Python you can use any object as a boolean (most are evaluated as true, some are false), but with PyObjC you'll have to use small integers. Let's hope someone sees this as his/her cue to come up with a very clever solution. Ronald |
From: <bo...@pa...> - 2003-03-01 20:05:38
|
sorry, this is wrong, it should be an analogous change to depythonify_c_return_value(). --b On Saturday, March 1, 2003, at 11:56 AM, Bob Pasker wrote: > > case _C_CHR: case _C_SHT: > return pythonify_c_value(intType, datum); > > to something like: > > case _C_SHT: > return pythonify_c_value(intType, datum); > case _C_CHR: > return (pythonify_c_value(intType, datum) != 0); |
From: <bo...@pa...> - 2003-03-01 19:56:47
|
this begs the question: in pyobjc, is the 'c' in a method signature ONLY used for BOOL types? if so, then maybe the right answer is to put the test in obj_support.m, ie, change case _C_CHR: case _C_SHT: return pythonify_c_value(intType, datum); to something like: case _C_SHT: return pythonify_c_value(intType, datum); case _C_CHR: return (pythonify_c_value(intType, datum) != 0); in general, the programmer should return an expression that evaluates to 0 or 1 for objc bool parameters. but most languages without a true boolean type permit integer types to be used as boolean expression without a boolean operator operators. python falls into this category, and using the bridge should not require a special idiom for booleans ("always return/pass a boolean expression, not an int"). i agree that returning only the low 8 bits would be wrong. --bob Python 2.2.2 (#1, 02/20/03, 15:23:05) [GCC Apple cpp-precomp 6.14] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> print 0==0 1 >>> print 0==1 0 >>> print 999999==0 0 >>> print 999999==123123 0 >>> print 999999!=123123 1 >>> if (0): print "true" ... else: print "false" ... false >>> if (5000000000): print "true" # greater than 2^32-1 ... else: print "false" ... true On Saturday, March 1, 2003, at 11:27 AM, Ronald Oussoren wrote: > Boy am I glad I didn't apply a change I was thinking of ;-). I thought > BOOL is an unsigned char and was thinking about changing the result of > pythonifying a 'char' to a string of lenght 1 (what basicly is the > corresponding "type" in Python). > > I don't think masking of all but the bottom 8 bits would be a right > idea. What if you want to return False from a method of a list of > items is empty and True otherwise. The obvious mostly-pythonic way > would be: > def myMethod(self): > return len(someList) > > This would fail if the length of the list is a multiple of 256. > > The right solution for this user-education, too bad we don't have a > FAQ yet. > > Ronald > |
From: Ronald O. <ous...@ci...> - 2003-03-01 19:36:56
|
On Saturday, Mar 1, 2003, at 19:02 Europe/Amsterdam, David Eppstein wrote: > According to Cocoa Developer Documentation > File, Resource, and > Process Management > File Management > Low-level File Management, > >> The Foundation Kit defines the following functions to convert between >> a >> classic HFS file type and an encoded string: >> >> NSString *NSFileTypeForHFSTypeCode(OSType hfsTypeCode); >> OSType NSHFSTypeCodeFromFileType(NSString *fileType); >> NSString *NSHFSTypeOfFile(NSString *filePath); > > However, I can't find these functions, > That doesn't surprise me, the generator scripts don't know about OSType and nobody got around to implementing these manually. BTW. The last function is present in package Foundation. Adding the other two shouldn't be two hard. Unless someone beats me to it, I'll add them early next week. Note to self: Use PyMac_GetOSType and PyMac_BuildOSType for translating OSType to/from a python value (for compatibility with MacPython). Ronald |
From: Ronald O. <ous...@ci...> - 2003-03-01 19:28:18
|
On Saturday, Mar 1, 2003, at 19:35 Europe/Amsterdam, Bob Pasker wrote: > if you try to pass an int whose magnitude is greater than can > be stored in a char (-256/+255), then you will get > > objc.error: depythonifying 'char', got int of wrong magnitude > > for example, with a table with greater than 255 rows, the following > will fail: > > self.theButton.setEnabled_(self.theTableView.numberOfRows()) > > but > > self.theButton.setEnabled_(self.theTableView.numberOfRows() != 0) > > works as expected. i assume (but haven't tested), that (say) delegate > methods > which return a BOOL will also fail if the return value is outside the > range. > > also, one things i've done in my version of obj_support.m is to change > identical > messages to different ones, e.g., changing 'depythonifying' to > 'depythonifyingN' > so i can tell which constraint failed: > > ObjCErr_Set(ObjCExc_error, > "depythonifying3 'char', got %s of " > "wrong magnitude", > argument->ob_type->tp_name); > > since python doesnt have a char datatype, one alternative is to relax > the > constraint (in obj_support.m) that _C_CHR parameters must be within > range, > and instead mask off all but the bottom 8 bits. Boy am I glad I didn't apply a change I was thinking of ;-). I thought BOOL is an unsigned char and was thinking about changing the result of pythonifying a 'char' to a string of lenght 1 (what basicly is the corresponding "type" in Python). I don't think masking of all but the bottom 8 bits would be a right idea. What if you want to return False from a method of a list of items is empty and True otherwise. The obvious mostly-pythonic way would be: def myMethod(self): return len(someList) This would fail if the length of the list is a multiple of 256. The right solution for this user-education, too bad we don't have a FAQ yet. Ronald |
From: David E. <epp...@ic...> - 2003-03-01 18:41:18
|
According to Cocoa Developer Documentation > File, Resource, and Process Management > File Management > Low-level File Management, > The Foundation Kit defines the following functions to convert between a > classic HFS file type and an encoded string: > > NSString *NSFileTypeForHFSTypeCode(OSType hfsTypeCode); > OSType NSHFSTypeCodeFromFileType(NSString *fileType); > NSString *NSHFSTypeOfFile(NSString *filePath); However, I can't find these functions, >>> from Foundation import NSHFSTypeCodeFromFileType Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: cannot import name NSHFSTypeCodeFromFileType appending an underscore also fails. Are they missing from pyobjc or am I looking in the wrong place? I guess it wouldn't be too hard to roll my own but using the standard functions would be better... -- David Eppstein http://www.ics.uci.edu/~eppstein/ Univ. of California, Irvine, School of Information & Computer Science |
From: <bo...@pa...> - 2003-03-01 18:36:15
|
if you try to pass an int whose magnitude is greater than can be stored in a char (-256/+255), then you will get objc.error: depythonifying 'char', got int of wrong magnitude for example, with a table with greater than 255 rows, the following will fail: self.theButton.setEnabled_(self.theTableView.numberOfRows()) but self.theButton.setEnabled_(self.theTableView.numberOfRows() != 0) works as expected. i assume (but haven't tested), that (say) delegate methods which return a BOOL will also fail if the return value is outside the range. also, one things i've done in my version of obj_support.m is to change identical messages to different ones, e.g., changing 'depythonifying' to 'depythonifyingN' so i can tell which constraint failed: ObjCErr_Set(ObjCExc_error, "depythonifying3 'char', got %s of " "wrong magnitude", argument->ob_type->tp_name); since python doesnt have a char datatype, one alternative is to relax the constraint (in obj_support.m) that _C_CHR parameters must be within range, and instead mask off all but the bottom 8 bits. --bob pasker bo...@pa... |
From: Ronald O. <ous...@ci...> - 2003-03-01 07:18:42
|
On Saturday, Mar 1, 2003, at 01:02 Europe/Amsterdam, Jack Jansen wrote: > > On vrijdag, feb 28, 2003, at 18:41 Europe/Amsterdam, Ronald Oussoren > wrote: >>> That's indeed not so bad. What worries me more is that they all seem >>> hand-rolled. Would it be possible -- in theory at least -- to >>> generate >>> them from header files? >> >> Not without giving up at least some functionality. > > And what if we don't parse the normal ObjC .h files, but the files > that are used > to build the Java-ObjC bridge (and that I always forget both the name > and > location of:-)? Do you mean the .jobs files? That doesn't help, that also doesn't contain information about the 'requiredness' of methods. Worst of all, it also doesn't include information about argument types. Ronald |
From: Jack J. <Jac...@or...> - 2003-03-01 00:02:15
|
On vrijdag, feb 28, 2003, at 18:41 Europe/Amsterdam, Ronald Oussoren wrote: >> That's indeed not so bad. What worries me more is that they all seem >> hand-rolled. Would it be possible -- in theory at least -- to generate >> them from header files? > > Not without giving up at least some functionality. And what if we don't parse the normal ObjC .h files, but the files that are used to build the Java-ObjC bridge (and that I always forget both the name and location of:-)? -- - Jack Jansen <Jac...@or...> http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman - |
From: Bill B. <bb...@co...> - 2003-02-28 19:49:21
|
On Friday, Feb 28, 2003, at 14:25 US/Eastern, Chris Ryland wrote: > Can you expand on this thought a bit for a Cocoa/PyObjC newbie? > > I guess I'm not sure what the informal protocols are used for, and why > they're interesting... Sure -- "informal protocol" is really just a made up term that refers to a collection of methods that fulfill some particular purpose. For example, NSTableView has three informal protocols -- one for handling of notifications, one for delegation, and one for the data source. A formal protocol is like an interface in Java; a class that declares compliance with a formal protocol or interface must implement all methods in the protocol or interface. An informal protocol typically has methods that are purely optional. Some methods -- like a couple of the methods in the data source -- may be required. An example of an informal protocol: @interface NSObject(NSTableViewDelegate) - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(int)row; - (BOOL)tableView:(NSTableView *)tableView shouldEditTableColumn:(NSTableColumn *)tableColumn row:(int)row; - (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTableView; - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row; - (BOOL)tableView:(NSTableView *)tableView shouldSelectTableColumn:(NSTableColumn *)tableColumn; - (void) tableView:(NSTableView*)tableView mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn; - (void) tableView:(NSTableView*)tableView didClickTableColumn:(NSTableColumn *)tableColumn; - (void) tableView:(NSTableView*)tableView didDragTableColumn:(NSTableColumn *)tableColumn; @end In Objective-C, the above declaration is not backed by any implementation. It is just a declaration mostly for the benefit of the developer. If the above declaration were missing, it wouldn't affect anything -- not at compile time, not at runtime. The reason why we have to declare the methods in PyObjC is because of the types. Because methods like the above are typically implemented on some class where none of the superclasses implement the method, then there is no way for the PyObjC bridge to know that the 'row' parameter should be handled as an (int) and not an (id). Initially, you had to declare the types of the method when implementing the method. I.e.: def selectionShouldChangeInTableView_(self, aTableView): return YES selectionShouldChangeInTableView_ = objc.selector("selectionShouldChangeInTableView:", signature="c@:@") Obviously, that is very ugly. Instead, Ronald created the mechanism we use today that allows you to declare that a class will be a target of an informal protocol in this fashion: class MyFooTableController(NSObject, NSTableDataSource, NSTableViewDelegate): def selectionShouldChangeInTableView_(self, aTableView): return YES This allows the PyObjC runtime to automatically deduce that selectionShouldChangeInTableView_() really needs to return a BOOl or that one of the methods that takes an (int) argument really wants an (int) and not an object. But there is an added benefit. Ronald added a feature to the informal protocol creation mechanism such that you can mark a method as being required. As such, if you declare that an object will be implementing some/all of the methods of an NSTableDataSource, the PyObjC bridge will automatically determine if your class is compliant by checking to see if you have implemented the one or two methods that are required if your class is going to truly act as an NSTableDataSource. b.bum |
From: Chris R. <cp...@em...> - 2003-02-28 19:25:15
|
Bill-- Can you expand on this thought a bit for a Cocoa/PyObjC newbie? I guess I'm not sure what the informal protocols are used for, and why they're interesting... Thanks for any explanation. On Friday, February 28, 2003, at 12:46 PM, Bill Bumgarner wrote: > On Friday, Feb 28, 2003, at 12:41 US/Eastern, Ronald Oussoren wrote: >> The current versions of the informal_protocol definitions also list >> whether methods are optional or not, and that cannot be inferred from >> the header files. Not having the additional information wouldn't be >> too bad, I'm sure Cocoa will complain loudly if an object doesn't >> implement the required parts of a protocol. > > Yes. It does... but not as loudly or as elegantly as PyObjC. Having > whipped off about a dozen little PyObjC apps to make my world a more > sane place, I can say with enthusiasm that the informal protocol > validation done by PyObjC is a huge boon! It'd be even better if it > spewed a method definition that could just be copied/pasted and even > better if there were a command line tool that could be used to dump > all the decls for a particular informal protocol. > > I would hate to see that functionality lost -- given that the > protocols don't change over time, I will volunteer for the tedious > task of making sure that there are decls for all of 'em based on my > previous emails analaysis of what needs to be wrapped. Then it is > just a matter of updating them over time based on the release notes > coming from Apple -- given that there have been no major API changes > except with major releases of the OS and *that* has only been > additions, it should not be hard to stay on top of this stuff. Cheers! --Chris Ryland / Em Software, Inc. / www.emsoftware.com |
From: Ronald O. <ous...@ci...> - 2003-02-28 18:02:25
|
On Friday, Feb 28, 2003, at 18:46 Europe/Amsterdam, Bill Bumgarner wrote: > On Friday, Feb 28, 2003, at 12:41 US/Eastern, Ronald Oussoren wrote: >> The current versions of the informal_protocol definitions also list >> whether methods are optional or not, and that cannot be inferred from >> the header files. Not having the additional information wouldn't be >> too bad, I'm sure Cocoa will complain loudly if an object doesn't >> implement the required parts of a protocol. > > Yes. It does... but not as loudly or as elegantly as PyObjC. Having > whipped off about a dozen little PyObjC apps to make my world a more > sane place, I can say with enthusiasm that the informal protocol > validation done by PyObjC is a huge boon! It'd be even better if it > spewed a method definition that could just be copied/pasted and even > better if there were a command line tool that could be used to dump > all the decls for a particular informal protocol. That should be easy enough. I thought we already had the necessary machinery, but I seem to have forgotten to give Python code (read-only) access to the list of methods in informal_protocols. > > I would hate to see that functionality lost -- given that the > protocols don't change over time, I will volunteer for the tedious > task of making sure that there are decls for all of 'em based on my > previous emails analaysis of what needs to be wrapped. Then it is > just a matter of updating them over time based on the release notes > coming from Apple -- given that there have been no major API changes > except with major releases of the OS and *that* has only been > additions, it should not be hard to stay on top of this stuff. It should be possible to write a script to extracts informal protocols from the header files and merges that with the current list of informal protocols. I'm not sure if that is worth the trouble. Ronald |
From: Bill B. <bb...@co...> - 2003-02-28 17:46:38
|
On Friday, Feb 28, 2003, at 12:41 US/Eastern, Ronald Oussoren wrote: > The current versions of the informal_protocol definitions also list > whether methods are optional or not, and that cannot be inferred from > the header files. Not having the additional information wouldn't be > too bad, I'm sure Cocoa will complain loudly if an object doesn't > implement the required parts of a protocol. Yes. It does... but not as loudly or as elegantly as PyObjC. Having whipped off about a dozen little PyObjC apps to make my world a more sane place, I can say with enthusiasm that the informal protocol validation done by PyObjC is a huge boon! It'd be even better if it spewed a method definition that could just be copied/pasted and even better if there were a command line tool that could be used to dump all the decls for a particular informal protocol. I would hate to see that functionality lost -- given that the protocols don't change over time, I will volunteer for the tedious task of making sure that there are decls for all of 'em based on my previous emails analaysis of what needs to be wrapped. Then it is just a matter of updating them over time based on the release notes coming from Apple -- given that there have been no major API changes except with major releases of the OS and *that* has only been additions, it should not be hard to stay on top of this stuff. b.bum |