pyobjc-dev Mailing List for PyObjC (Page 20)
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
(1) |
Nov
|
Dec
(2) |
|
From: Ronald O. <ron...@ma...> - 2011-08-02 08:34:06
|
On 1 Aug, 2011, at 16:40, Ludovic Marcotte wrote: > Hello, > > Over the past few days, we've ported PyObjC (trunk) to GNUstep. It's known to compile and work on: > GCC Objective-C runtime < 4.6 > GCC Objective-C runtime >= 4.6 > GNUstep Objective-C runtime (libobjc-2-1.5). > To get this to work, you need GNUstep base and corebase from trunk. > > We've also integrated successfully PyObjC in the SOGo code (www.sogo.nu) - so it's now possible to fully extend SOGo's code using Python. > > Here is the patch - which could hopefully be included. The patch is a lot smaller than I'd expect given earlier attempts to port to GNUstep. I haven't reviewed the patch yet, but at first glance it looks clean enough. Given that the patch is a working port to GNUstep I'll likely commit this patch, possibly after some cleanup. Ronald |
|
From: Ludovic M. <lma...@in...> - 2011-08-01 14:41:03
|
Index: PyObjCTest/test_nsdate_proxy.py
===================================================================
--- PyObjCTest/test_nsdate_proxy.py (revision 2606)
+++ PyObjCTest/test_nsdate_proxy.py (working copy)
@@ -7,6 +7,7 @@
# these have a custom proxy class.
def testFormattingForDate(self):
+ return
# This is jus a round-about way of testing that the right proxy
# object is created
formatter = NSDateFormatter.alloc().initWithDateFormat_allowNaturalLanguage_(
@@ -22,6 +23,7 @@
def testFormattingForDateTime(self):
+ return
# This is jus a round-about way of testing that the right proxy
# object is created
formatter = NSDateFormatter.alloc().initWithDateFormat_allowNaturalLanguage_(
Index: PyObjCTest/test_number_proxy.py
===================================================================
--- PyObjCTest/test_number_proxy.py (revision 2606)
+++ PyObjCTest/test_number_proxy.py (working copy)
@@ -11,7 +11,10 @@
import objc
OC_PythonNumber = objc.lookUpClass("OC_PythonNumber")
-NSCFNumber = objc.lookUpClass("NSCFNumber")
+try:
+ NSCFNumber = objc.lookUpClass("NSCFNumber")
+except objc.nosuchclass_error as msg:
+ NSCFNumber = objc.lookUpClass("NSNumber")
NSOrderedAscending = -1
NSOrderedSame = 0
@@ -202,7 +205,10 @@
# The booleans True and False must be proxied as the corresponding
# NSNumber constants, otherwise lowlevel Cocoa/CoreFoundation code
# get's upset.
- boolClass = objc.lookUpClass('NSCFBoolean')
+ try:
+ boolClass = objc.lookUpClass('NSCFBoolean')
+ except objc.nosuchclass_error as msg:
+ boolClass = objc.lookUpClass('NSNumber')
for v in (True, False):
self.assertIs(OC_TestNumber.numberClass_(v), boolClass)
self.assertIs(objc.repythonify(v), v)
Index: PyObjCTest/test_hidden_selector.py
===================================================================
--- PyObjCTest/test_hidden_selector.py (revision 2606)
+++ PyObjCTest/test_hidden_selector.py (working copy)
@@ -57,6 +57,7 @@
def boolMethod(self):
return 0
+ boolMethod = objc.selector(boolMethod, signature=objc._C_NSBOOL + b'@:')
class TestHiddenSelector (TestCase):
def testHiddenInClassDef(self):
Index: PyObjCTest/test_copying.py
===================================================================
--- PyObjCTest/test_copying.py (revision 2606)
+++ PyObjCTest/test_copying.py (working copy)
@@ -242,7 +242,7 @@
a = NSMutableArray.arrayWithArray_(['a', 'b', 'c'])
self.assertIsInstance(a, NSMutableArray)
- b = copy.copy(a)
+ b = copy.mutableCopy(a)
self.assertIsInstance(b, NSMutableArray)
self.assertEqual(list(a), list(b))
Index: setup.py
===================================================================
--- setup.py (revision 2606)
+++ setup.py (working copy)
@@ -25,6 +25,8 @@
# on 10.6 and running on an earlier release)
USE_SYSTEM_LIBXML = False
+USE_GNUSTEP = False
+
if sys.version_info < MIN_PYTHON:
vstr = '.'.join(map(str, MIN_PYTHON))
raise SystemExit('PyObjC: Need at least Python ' + vstr)
@@ -266,17 +268,45 @@
return packages, extensions
return [], []
+CFLAGS=[ ]
+
# Double-check
-if sys.platform != 'darwin':
- print("You're not running on MacOS X, and don't use GNUstep")
- print("I don't know how to build PyObjC on such a platform.")
- print("Please read the ReadMe.")
- print("")
- raise SystemExit("ObjC runtime not found")
+if sys.platform == 'darwin':
+ CFLAGS.extend([
+ "-DMACOSX",
+ "-DPyObjC_BUILD_RELEASE=%02d%02d"%(tuple(map(int, platform.mac_ver()[0].split('.')[:2])))
+ ])
+ OBJC_LDFLAGS = frameworks('CoreFoundation', 'Foundation', 'Carbon')
+else:
+ # Try to run the gnustep-config command to get build requirements on non-Mac platforms
+ # This is the version for a release build, uncomment the line below for debug builds
+ #GNUSTEP_CFLAGS = str(subprocess.Popen(["gnustep-config", "--objc-flags"], stdout=subprocess.PIPE).communicate()[0]).split()
+ GNUSTEP_CFLAGS = str(subprocess.Popen(["gnustep-config", "--debug-flags"], stdout=subprocess.PIPE).communicate()[0]).split()
+ if "" == GNUSTEP_CFLAGS:
+ print("You're not running on MacOS X, and don't use GNUstep")
+ print("I don't know how to build PyObjC on such a platform.")
+ print("Please read the ReadMe.")
+ print("")
+ raise SystemExit("ObjC runtime not found")
+ # Don't add the Mac OS X version to the release number, if we're not building on OS X
+ # FIXME: Do actually use something sensible instead
+ CFLAGS.extend([
+ "-DPyObjC_BUILD_RELEASE=1"
+ ])
+ CFLAGS.extend(GNUSTEP_CFLAGS)
+ #CFLAGS.extend(["-O0", "-g", "-fno-inline"])
+ USE_GNUSTEP = True
+ # On non-Darwin platforms, we always want to use the system libraries.
+ USE_SYSTEM_FFI = True
+ USE_SYSTEM_LIBXML = True
+ # Load order is important here. Linking -corebase after -base causes a
+ # crash trying to register for a notification with a string that is not yet
+ # initialized.
+ OBJC_LDFLAGS = ["-lgnustep-corebase"]
+ OBJC_LDFLAGS.extend(str(subprocess.Popen(["gnustep-config", "--base-libs"], stdout=subprocess.PIPE).communicate()[0]).split())
from distutils.sysconfig import get_config_var
-CFLAGS=[ ]
# Enable 'PyObjC_STRICT_DEBUGGING' to enable some costly internal
# assertions.
@@ -288,14 +318,14 @@
# The following flags are an attempt at getting rid of /usr/local
# in the compiler search path.
"-DPyObjC_STRICT_DEBUGGING",
- "-DMACOSX", # For libffi
- "-DPyObjC_BUILD_RELEASE=%02d%02d"%(tuple(map(int, platform.mac_ver()[0].split('.')[:2]))),
- "-no-cpp-precomp",
- "-DMACOSX",
+# "-no-cpp-precomp",
+# Uncomment the line below for gcc >= 4.6. It has to be commented
+# for gcc < 4.6
+ "-D__OBJC2__=1"
"-g",
"-fexceptions",
+ "-fobjc-exceptions",
-
# Loads of warning flags
"-Wall", "-Wstrict-prototypes", "-Wmissing-prototypes",
"-Wformat=2", "-W",
@@ -306,7 +336,6 @@
"-Wno-long-long",
"-Wno-import",
- "-DPyObjC_BUILD_RELEASE=%02d%02d"%(tuple(map(int, get_os_level().split('.')))),
])
## Arghh, a stupid compiler flag can cause problems. Don't
@@ -317,11 +346,9 @@
print ("Change -O0 to -O1")
CFLAGS.append('-O1')
-OBJC_LDFLAGS = frameworks('CoreFoundation', 'Foundation', 'Carbon')
+#if not os.path.exists('/usr/include/objc/runtime.h'):
+ #CFLAGS.append('-DNO_OBJC2_RUNTIME')
-if not os.path.exists('/usr/include/objc/runtime.h'):
- CFLAGS.append('-DNO_OBJC2_RUNTIME')
-
# Force compilation with the local SDK, compilation of PyObC will result in
# a binary that runs on other releases of the OS without using a particular SDK.
CFLAGS.extend(['-isysroot', '/'])
@@ -379,6 +406,7 @@
ExtensionList = [
Extension("objc._objc",
list(glob.glob(os.path.join('Modules', 'objc', '*.m'))),
+ # FIXME: Use pkg_config to get flags for ffi
extra_compile_args=CFLAGS + ["-I/usr/include/ffi"],
extra_link_args=OBJC_LDFLAGS + ["-lffi"],
depends=list(glob.glob(os.path.join('Modules', 'objc', '*.h'))),
Index: Lib/PyObjCTools/TestSupport.py
===================================================================
--- Lib/PyObjCTools/TestSupport.py (revision 2606)
+++ Lib/PyObjCTools/TestSupport.py (working copy)
@@ -85,6 +85,8 @@
global _os_release
if _os_release is not None:
return _os_release
+ # FIXME: This should do something sensible with GNUstep!
+ return '10.5'
pl = _pl.readPlist('/System/Library/CoreServices/SystemVersion.plist')
v = pl['ProductVersion']
Index: Modules/objc/OC_PythonData.m
===================================================================
--- Modules/objc/OC_PythonData.m (revision 2606)
+++ Modules/objc/OC_PythonData.m (working copy)
@@ -1,6 +1,10 @@
#include "pyobjc.h"
#import "OC_PythonData.h"
+#ifndef NSUIntegerMax
+# define NSUIntegerMax UINTPTR_MAX
+#endif
+
@implementation OC_PythonData
+ dataWithPythonObject:(PyObject*)v;
Index: Modules/objc/method-imp.m
===================================================================
--- Modules/objc/method-imp.m (revision 2606)
+++ Modules/objc/method-imp.m (working copy)
@@ -1,4 +1,5 @@
#include "pyobjc.h"
+#include "msg_send_compat.h"
typedef struct {
PyObject_HEAD
@@ -379,7 +380,7 @@
}
PyObjC_DURING
- retval = (IMP)objc_msgSend(PyObjCClass_GetClass(self),
+ retval = objc_impMsgSendPtr(PyObjCClass_GetClass(self),
PyObjCSelector_GetSelector(method),
selector);
PyObjC_HANDLER
@@ -455,7 +456,7 @@
objc_superSetClass(super, object_getClass(objc_superGetReceiver(super)));
PyObjC_DURING
- retval = (IMP)objc_msgSendSuper(&super,
+ retval = objc_impMsgSendSuperPtr(&super,
PyObjCSelector_GetSelector(method),
selector);
PyObjC_HANDLER
Index: Modules/objc/closure_pool.m
===================================================================
--- Modules/objc/closure_pool.m (revision 2606)
+++ Modules/objc/closure_pool.m (working copy)
@@ -12,6 +12,9 @@
static freelist* closure_freelist = NULL;
+#ifndef PAGE_SIZE
+# define PAGE_SIZE 4096
+#endif
static freelist* allocate_block(void)
{
Index: Modules/objc/formal-protocol.m
===================================================================
--- Modules/objc/formal-protocol.m (revision 2606)
+++ Modules/objc/formal-protocol.m (working copy)
@@ -9,14 +9,37 @@
*/
#include "pyobjc.h"
+#ifndef __APPLE__
+#if !(defined(__GNUSTEP_RUNTIME__) || defined(__GNU_LIBOBJC__))
+struct objc_method_description
+{
+ const char *name;
+ const char *types;
+};
+#endif
+struct objc_method_description_list
+{
+ int count;
+ struct objc_method_description list[0];
+};
+struct objc_protocol_list
+{
+ struct objc_protocol_list *next;
+ size_t count;
+ Protocol *list[1];
+};
+#endif
+
+
/*
* FIXME: Looking in the Protocol structure is a rather crude hack, especially with the Objective-C 2.0
* runtime API. Too bad there is no real API for doing what we want...
*/
struct Protocol_struct {
-#ifndef __OBJC2__
+#if !defined(__OBJC2__) && defined(__APPLE__)
@defs(Protocol);
#else
+ id isa;
char *protocol_name;
struct objc_protocol_list *protocol_list;
struct objc_method_description_list *instance_methods, *class_methods;
Index: Modules/objc/objc-class.m
===================================================================
--- Modules/objc/objc-class.m (revision 2606)
+++ Modules/objc/objc-class.m (working copy)
@@ -1801,6 +1801,7 @@
PyObject*
PyObjCClass_ListProperties(PyObject* aClass)
{
+#if defined(__APPLE__) || defined(__GNUSTEP__RUNTME__)
Class cls = Nil;
Protocol* proto = nil;
@@ -2003,6 +2004,7 @@
free(props);
}
Py_XDECREF(result);
+#endif
return NULL;
}
Index: Modules/objc/socketsupport.m
===================================================================
--- Modules/objc/socketsupport.m (revision 2606)
+++ Modules/objc/socketsupport.m (working copy)
@@ -144,7 +144,9 @@
sinaddr = (struct sockaddr_in *)addr_ret;
memset((void *) sinaddr, '\0', sizeof(*sinaddr));
sinaddr->sin_family = AF_INET;
+#ifndef __linux__
sinaddr->sin_len = sizeof(*sinaddr);
+#endif
sinaddr->sin_addr.s_addr = INADDR_BROADCAST;
return sizeof(sinaddr->sin_addr);
}
@@ -157,7 +159,9 @@
((long) d1 << 24) | ((long) d2 << 16) |
((long) d3 << 8) | ((long) d4 << 0));
sinaddr->sin_family = AF_INET;
+#ifndef __linux__
sinaddr->sin_len = sizeof(*sinaddr);
+#endif
return 4;
}
memset(&hints, 0, sizeof(hints));
Index: Modules/objc/OC_PythonDictionary.m
===================================================================
--- Modules/objc/OC_PythonDictionary.m (revision 2606)
+++ Modules/objc/OC_PythonDictionary.m (working copy)
@@ -6,6 +6,10 @@
#include "pyobjc.h"
#import "OC_PythonDictionary.h"
+#ifndef NSUIntegerMax
+# define NSUIntegerMax UINTPTR_MAX
+#endif
+
static PyObject* mapTypes = NULL;
/*
Index: Modules/objc/fsref.h
===================================================================
--- Modules/objc/fsref.h (revision 2606)
+++ Modules/objc/fsref.h (working copy)
@@ -4,8 +4,11 @@
#ifndef PyObjC_FSREF_H
#define PyObjC_FSREF_H
+#ifdef __APPLE__
#define IS_FSREF(typestr) \
(strncmp(typestr, @encode(FSRef), sizeof(@encode(FSRef))-1) == 0)
+#else
+#define IS_FSREF(x) 0
extern int PyObjC_encode_fsref(PyObject*, void*);
extern PyObject* PyObjC_decode_fsref(void*);
@@ -14,4 +17,7 @@
#define PyObjC_FSRefCheck(value) \
PyObject_TypeCheck(value, &PyObjC_FSRefType)
+
+#endif
+
#endif /* PyObjC_FSREF_H */
Index: Modules/objc/pyobjc-compat.h
===================================================================
--- Modules/objc/pyobjc-compat.h (revision 2606)
+++ Modules/objc/pyobjc-compat.h (working copy)
@@ -46,18 +46,20 @@
#define unlikely(x) __builtin_expect (!!(x), 0)
#define likely(x) __builtin_expect (!!(x), 1)
#else
+#define unlikely(x) x
#define likely(x) x
-#define likely(x) x
#endif
-#import <AvailabilityMacros.h>
+#ifdef __APPLE__
+# import <AvailabilityMacros.h>
/* On 10.1 there are no defines for the OS version. */
-#ifndef MAC_OS_X_VERSION_10_1
-#define MAC_OS_X_VERSION_10_1 1010
-#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_1
+# ifndef MAC_OS_X_VERSION_10_1
+# define MAC_OS_X_VERSION_10_1 1010
+# define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_1
-#error "MAC_OS_X_VERSION_10_1 not defined. You aren't running 10.1 are you?"
+# error "MAC_OS_X_VERSION_10_1 not defined. You aren't running 10.1 are you?"
+# endif
#endif
@@ -151,7 +153,7 @@
#define PyErr_Format PyObjCErr_Format
-extern PyObject* PyObjCErr_Format(PyObject* exception, const char* format, ...);
+PyObject* PyObjCErr_Format(PyObject* exception, const char* format, ...);
#define PyText_Check PyString_Check
#define PyText_FromFormat PyString_FromFormat
Index: Modules/objc/fsref.m
===================================================================
--- Modules/objc/fsref.m (revision 2606)
+++ Modules/objc/fsref.m (working copy)
@@ -2,6 +2,7 @@
* A custom wrapper for the (opaque) FSRef structure.
*/
#include "pyobjc.h"
+#ifdef __APPLE__
#import <CoreServices/CoreServices.h>
@@ -239,3 +240,4 @@
result->ref = *(FSRef*)buffer;
return (PyObject*)result;
}
+#endif
Index: Modules/objc/ObjCPointer.m
===================================================================
--- Modules/objc/ObjCPointer.m (revision 2606)
+++ Modules/objc/ObjCPointer.m (working copy)
@@ -138,8 +138,6 @@
const char *typeend = PyObjCRT_SkipTypeSpec (t);
PyObjCPointer *self;
- NSLog(@"PyObjCPointer created: at %p of type %s", p, t);
-
if (size == -1) {
return NULL;
}
Index: Modules/objc/module.m
===================================================================
--- Modules/objc/module.m (revision 2606)
+++ Modules/objc/module.m (working copy)
@@ -4,9 +4,21 @@
*/
#include "pyobjc.h"
#include "OC_NSBundleHack.h"
-#include <objc/Protocol.h>
+#import <objc/Protocol.h>
+#ifdef __APPLE__
#include <objc/objc-sync.h>
+#else
+// GNU runtimes do not expose ABI functions in headers.
+int objc_sync_enter(id obj);
+int objc_sync_exit(id obj);
+enum
+{
+ OBJC_SYNC_SUCCESS = 0
+};
+#endif
+
+
#include <stddef.h>
#include <ctype.h>
#include <sys/socket.h>
@@ -17,9 +29,11 @@
#import <Foundation/NSProcessInfo.h>
#import <Foundation/NSString.h>
+#ifdef __APPLE__
#import <mach-o/dyld.h>
#import <mach-o/getsect.h>
#import <mach-o/loader.h>
+#endif
#import <objc/Protocol.h>
int PyObjC_VerboseLevel = 0;
@@ -2049,12 +2063,14 @@
if (PyType_Ready(&PyObjC_VarList_Type) < 0) {
PyObjC_INITERROR();
}
+#ifdef __APPLE__
if (PyType_Ready(&PyObjC_FSRefType) < 0) {
PyObjC_INITERROR();
}
if (PyType_Ready(&PyObjC_FSSpecType) < 0) {
PyObjC_INITERROR();
}
+#endif
PyObjCSuper_Type.tp_doc = PySuper_Type.tp_doc;
PyObjCSuper_Type.tp_init = PySuper_Type.tp_init;
@@ -2098,12 +2114,14 @@
if (PyDict_SetItemString(d, "selector", (PyObject*)&PyObjCSelector_Type) < 0) {
PyObjC_INITERROR();
}
+#ifdef __APPLE__
if (PyDict_SetItemString(d, "FSRef", (PyObject*)&PyObjC_FSRefType) < 0) {
PyObjC_INITERROR();
}
if (PyDict_SetItemString(d, "FSSpec", (PyObject*)&PyObjC_FSSpecType) < 0) {
PyObjC_INITERROR();
}
+#endif
if (PyDict_SetItemString(d, "ivar", (PyObject*)&PyObjCInstanceVariable_Type) < 0) {
PyObjC_INITERROR();
}
Index: Modules/objc/libffi_support.m
===================================================================
--- Modules/objc/libffi_support.m (revision 2606)
+++ Modules/objc/libffi_support.m (working copy)
@@ -20,7 +20,7 @@
#ifdef __ppc64__
extern bool ffi64_stret_needs_ptr(const ffi_type* inType,
unsigned short*, unsigned short*);
-#endif;
+#endif
/*
* Define SMALL_STRUCT_LIMIT as the largest struct that will be returned
@@ -30,7 +30,7 @@
static const char gCharEncoding[] = { _C_CHR, 0 };
static const char gCFRangeEncoding[1024] = { 0 };
-#if defined(__ppc__)
+#if defined(__ppc__) || defined(PPC)
# define SMALL_STRUCT_LIMIT 4
@@ -3796,6 +3796,7 @@
}
useStret = 0;
+#ifdef __APPLE__
if (*rettype == _C_STRUCT_B &&
#ifdef __ppc64__
ffi64_stret_needs_ptr(signature_to_ffi_return_type(rettype), NULL, NULL)
@@ -3824,6 +3825,7 @@
useStret = 1;
}
+#endif
superPtr = &super;
arglist[ 0] = &ffi_type_pointer;
values[ 0] = &superPtr;
@@ -3868,6 +3870,7 @@
msgResult, values);
} else {
+#ifdef __APPLE__
if (useStret) {
ffi_call(&cif, FFI_FN(objc_msgSendSuper_stret),
msgResult, values);
@@ -3876,6 +3879,13 @@
msgResult, values);
}
+#else
+ // GNU runtimes do not provide message sending trampolines, so we
+ // must look up the IMP and then call it directly.
+ IMP method = objc_msg_lookup_super(superPtr, theSel);
+ values[0] = &self_obj;
+ ffi_call(&cif, FFI_FN(method), msgResult, values);
+#endif
}
PyObjC_HANDLER
Index: Modules/objc/pyobjc-api.h
===================================================================
--- Modules/objc/pyobjc-api.h (revision 2606)
+++ Modules/objc/pyobjc-api.h (working copy)
@@ -120,7 +120,7 @@
-#include <objc/objc-runtime.h>
+#include <objc/objc.h>
/* On 10.1 there are no defines for the OS version. */
#ifndef MAC_OS_X_VERSION_10_1
Index: Modules/objc/class-builder.m
===================================================================
--- Modules/objc/class-builder.m (revision 2606)
+++ Modules/objc/class-builder.m (working copy)
@@ -5,6 +5,7 @@
#include "pyobjc.h"
#import <Foundation/NSInvocation.h>
+#include "msg_send_compat.h"
PyObject* PyObjC_class_setup_hook = NULL;
@@ -1361,7 +1362,7 @@
"c@::",
object_method_respondsToSelector);
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4
+#if !defined(GNUSTEP) && (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4)
if (_KVOHackLevel() == BROKEN_KVO) {
METH(
"willChangeValueForKey_",
@@ -1458,13 +1459,17 @@
Method meth;
int is_override = 0;
IMP imp;
+ const char *signature = PyObjCSelector_GetNativeSignature(value);
meth = class_getInstanceMethod(super_class,
PyObjCSelector_GetSelector(value));
if (meth) {
is_override = 1;
+ signature = method_getTypeEncoding(meth);
if (!same_signature(method_getTypeEncoding(meth),
PyObjCSelector_GetNativeSignature(value))) {
+ NSLog(@"Method encoding is: %s", method_getTypeEncoding(meth));
+ NSLog(@"Selector encoding is: %s", PyObjCSelector_GetNativeSignature(value));
PyErr_Format(PyObjCExc_BadPrototypeError,
"%R has signature that is not compatible with super-class",
@@ -1482,7 +1487,7 @@
}
if (!preclass_addMethod(new_class, PyObjCSelector_GetSelector(value), imp,
- PyObjCSelector_GetNativeSignature(value))) {
+ signature)) {
goto error_cleanup;
}
}
@@ -1498,15 +1503,20 @@
Method meth;
int is_override = 0;
IMP imp;
+ const char *signature = PyObjCSelector_GetNativeSignature(value);
meth = class_getClassMethod(super_class, PyObjCSelector_GetSelector(value));
if (meth) {
is_override = 1;
+ signature = method_getTypeEncoding(meth);
+
if (!same_signature(method_getTypeEncoding(meth),
PyObjCSelector_GetNativeSignature(value))) {
+ NSLog(@"Method encoding is: %s", method_getTypeEncoding(meth));
+ NSLog(@"Selector encoding is: %s", PyObjCSelector_GetNativeSignature(value));
PyErr_Format(PyObjCExc_BadPrototypeError,
"%R has signature that is not compatible with super-class",
value);
@@ -1537,6 +1547,13 @@
Py_XDECREF(instance_variables); instance_variables = NULL;
Py_XDECREF(instance_methods); instance_methods = NULL;
Py_XDECREF(class_methods); class_methods = NULL;
+#ifdef __GNU_LIBOBJC__
+ // The GCC runtime is broken. We are forced to register the class now, or
+ // subsequent calls to class_getSuperclass() will return Nil instead of the
+ // superclass.
+#warning Enabling hacks to work around bugs in the GCC Objective-C runtime. A better solution is to migrate to the GNUstep Objective-C runtime.
+ objc_registerClassPair(new_class);
+#endif
/*
* NOTE: Class is not registered yet, we do that as lately as possible
@@ -1789,7 +1806,7 @@
objc_superSetClass(spr, (Class)userdata);
objc_superSetReceiver(spr, self);
- copy = objc_msgSendSuper(&spr, _meth, zone);
+ copy = objc_msgSendSuperPtr(&spr, _meth, zone);
if (copy == nil) {
*(id*)resp = nil;
@@ -1884,7 +1901,7 @@
objc_superSetClass(spr, (Class)userdata);
objc_superSetReceiver(spr, self);
- *pres = ((int(*)(struct objc_super*, SEL, SEL))objc_msgSendSuper)(&spr, _meth, aSelector);
+ *pres = objc_intMsgSendSuperPtr(&spr, _meth, aSelector);
return;
}
@@ -1911,7 +1928,7 @@
objc_superSetReceiver(spr, self);
NS_DURING
- *presult = objc_msgSendSuper(&spr, _meth, aSelector);
+ *presult = objc_msgSendSuperPtr(&spr, _meth, aSelector);
NS_HANDLER
*presult = nil;
NS_ENDHANDLER
@@ -2020,7 +2037,7 @@
objc_superSetClass(spr, (Class)userdata);
objc_superSetReceiver(spr, self);
PyGILState_Release(state);
- objc_msgSendSuper(&spr, _meth, invocation);
+ objc_msgSendSuperPtr(&spr, _meth, invocation);
return;
}
@@ -2396,7 +2413,7 @@
NS_DURING
objc_superSetClass(spr, (Class)userdata);
objc_superSetReceiver(spr, self);
- *((id *)retval) = (id)objc_msgSendSuper(&spr, _meth, key);
+ *((id *)retval) = objc_msgSendSuperPtr(&spr, _meth, key);
NS_HANDLER
/* Parent doesn't know the key, try to create in the
@@ -2470,13 +2487,13 @@
if (_UseKVO(self, key, isSet)) {
objc_superSetClass(spr, (Class)userdata);
objc_superSetReceiver(spr, self);
- (void)objc_msgSendSuper(&spr, _meth, key);
+ (void)objc_msgSendSuperPtr(&spr, _meth, key);
}
#else
objc_superSetClass(spr, (Class)userdata);
objc_superSetReceiver(spr, self);
- (void)objc_msgSendSuper(&spr, _meth, key);
+ (void)objc_msgSendSuperPtr(&spr, _meth, key);
#endif
}
@@ -2516,7 +2533,7 @@
// First check super
objc_superSetClass(spr, (Class)userdata);
objc_superSetReceiver(spr, self);
- (void)objc_msgSendSuper(&spr, _meth, value, key);
+ (void)objc_msgSendSuperPtrPtr(&spr, _meth, value, key);
NS_HANDLER
/* Parent doesn't know the key, try to create in the
* python side, just like for plain python objects.
Index: Modules/objc/parsexml.m
===================================================================
--- Modules/objc/parsexml.m (revision 2606)
+++ Modules/objc/parsexml.m (working copy)
@@ -10,7 +10,11 @@
#include "pyobjc.h"
#include <dlfcn.h>
+#ifndef RTLD_DEFAULT
+# define RTLD_DEFAULT ((void*)0)
+#endif
+
/* Use the libxml2 parser */
/* XXX: these are needed to avoid problems when using the system version
Index: Modules/objc/coder-category.m
===================================================================
--- Modules/objc/coder-category.m (revision 2606)
+++ Modules/objc/coder-category.m (working copy)
@@ -7,6 +7,7 @@
* to avoid creating circular dependencies.
*/
#import <Foundation/Foundation.h>
+#include <stdbool.h>
@implementation NSCoder (pyobjc)
Index: Modules/objc/OC_PythonUnicode.m
===================================================================
--- Modules/objc/OC_PythonUnicode.m (revision 2606)
+++ Modules/objc/OC_PythonUnicode.m (working copy)
@@ -157,11 +157,8 @@
length:(NSUInteger)length
freeWhenDone:(BOOL)flag
{
-#ifndef PyObjC_UNICODE_FAST_PATH
-# error "Wide UNICODE builds are not supported at the moment"
-#endif
PyObjC_BEGIN_WITH_GIL
- value = PyUnicode_FromUnicode((Py_UNICODE*)characters, length);
+ value = PyUnicode_DecodeUTF16((const char*)characters, length, NULL, 0);
if (value == NULL) {
PyObjC_GIL_FORWARD_EXC();
}
@@ -176,7 +173,9 @@
-initWithBytes:(void*)bytes length:(NSUInteger)length encoding:(NSStringEncoding)encoding
{
#ifndef PyObjC_UNICODE_FAST_PATH
-# error "Wide UNICODE builds are not supported at the moment"
+#warning "Wide UNICODE builds are not supported at the moment"
+ [NSException raise: @"NSNotImplementedException"
+ format: @"[%@ %@] not supported]", [self class], NSStringFromSelector(_cmd)];
#endif
NSString* tmpval = [[NSString alloc] initWithBytes:bytes length:length encoding:encoding];
Py_ssize_t charcount = [tmpval length];
Index: Modules/objc/objc_support.m
===================================================================
--- Modules/objc/objc_support.m (revision 2606)
+++ Modules/objc/objc_support.m (working copy)
@@ -16,7 +16,7 @@
*/
#include "pyobjc.h"
-#include <objc/Protocol.h>
+#import <objc/Protocol.h>
#include <unistd.h>
#include <sys/socket.h>
Index: Modules/objc/corefoundation.h
===================================================================
--- Modules/objc/corefoundation.h (revision 2606)
+++ Modules/objc/corefoundation.h (working copy)
@@ -1,6 +1,8 @@
#ifndef PyObjC_COREFOUNDATION_H
#define PyObjC_COREFOUNDATION_H
+#include <CoreFoundation/CoreFoundation.h>
+
extern PyObject* PyObjC_NSCFTypeClass;
extern int PyObjCCFType_Setup(void);
Index: Modules/objc/objc-runtime-compat.h
===================================================================
--- Modules/objc/objc-runtime-compat.h (revision 2606)
+++ Modules/objc/objc-runtime-compat.h (working copy)
@@ -22,7 +22,14 @@
* the preclass_* functions, not the regular ones because it isn't possible
* to emulate the entire ObjC 2.0 API on Tiger.
*/
-#include <objc/objc-runtime.h>
+#ifdef GNUSTEP
+# ifndef __strong
+# define __strong
+# endif
+# include <stdbool.h>
+#else
+# include <objc/runtime.h>
+#endif
#include <objc/Protocol.h>
#define _C_CONST 'r'
@@ -70,7 +77,7 @@
BOOL PyObjC_class_isSubclassOf(Class child, Class parent);
#define class_isSubclassOf PyObjC_class_isSubclassOf
-#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) && !defined(__OBJC2__)
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) && !defined(__OBJC2__) && defined(__APPLE__)
#define preclass_addIvar PyObjC_preclass_addIvar
#define preclass_addMethod PyObjC_preclass_addMethod
Index: Modules/objc/fsspec.h
===================================================================
--- Modules/objc/fsspec.h (revision 2606)
+++ Modules/objc/fsspec.h (working copy)
@@ -4,9 +4,14 @@
#ifndef PyObjC_FSSPEC_H
#define PyObjC_FSSPEC_H
+#ifdef __APPLE__
#define IS_FSSPEC(typestr) \
(strncmp(typestr, @encode(FSSpec), sizeof(@encode(FSSpec))-1) == 0)
+#else
+#define IS_FSSPEC(typestr) 0
+#endif
+
extern int PyObjC_encode_fsspec(PyObject*, void*);
extern PyObject* PyObjC_decode_fsspec(void*);
Index: Modules/objc/objc-runtime-compat.m
===================================================================
--- Modules/objc/objc-runtime-compat.m (revision 2606)
+++ Modules/objc/objc-runtime-compat.m (working copy)
@@ -11,7 +11,7 @@
-#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) &&!defined(__OBJC2__)
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5) &&!defined(__OBJC2__) && defined(__APPLE__)
BOOL PyObjC_class_isSubclassOf(Class child, Class parent)
{
Index: Modules/objc/selector.m
===================================================================
--- Modules/objc/selector.m (revision 2606)
+++ Modules/objc/selector.m (working copy)
@@ -799,7 +799,7 @@
}
if (Object_class == nil) {
- Object_class = [Object class];
+ Object_class = NSClassFromString(@"Object");
}
if (name[0] == '_' && name[1] == '_') {
@@ -956,6 +956,7 @@
result->sel_selector = selector;
result->sel_python_signature = signature;
result->sel_native_signature = PyObjCUtil_Strdup(signature);
+
if (result->sel_native_signature == NULL) {
Py_DECREF(result);
return NULL;
Index: Modules/objc/fsspec.m
===================================================================
--- Modules/objc/fsspec.m (revision 2606)
+++ Modules/objc/fsspec.m (working copy)
@@ -1,6 +1,7 @@
/*
* A custom wrapper for the (opaque) FSSpec structure.
*/
+#ifdef __APPLE__
#include "pyobjc.h"
#import <CoreServices/CoreServices.h>
@@ -168,3 +169,5 @@
result->ref = *(FSSpec*)buffer;
return (PyObject*)result;
}
+
+#endif // __APPLE__
Index: Modules/objc/test/locking.m
===================================================================
--- Modules/objc/test/locking.m (revision 2606)
+++ Modules/objc/test/locking.m (working copy)
@@ -24,6 +24,7 @@
-(void)threadFunc:(NSObject*)object
{
int i;
+ id pool = [NSAutoreleasePool new];
for (i = 0; i < 6; i++) {
usleep(500000);
@synchronized(object) {
@@ -38,6 +39,7 @@
[object setLocked:[NSNumber numberWithBool:NO]];
}
}
+ [pool drain];
}
@end
Index: Modules/objc/test/testbndl2.m
===================================================================
--- Modules/objc/test/testbndl2.m (revision 2606)
+++ Modules/objc/test/testbndl2.m (working copy)
@@ -12,6 +12,7 @@
#import "Python.h"
#import "pyobjc-api.h"
#import <limits.h>
+#import <stdbool.h>
#import <Foundation/Foundation.h>
Index: Modules/objc/test/corefoundation.m
===================================================================
--- Modules/objc/test/corefoundation.m (revision 2606)
+++ Modules/objc/test/corefoundation.m (working copy)
@@ -4,6 +4,7 @@
* XXX: add a second type that isn't tollfree bridged to check that the
* default behaviour works as well.
*/
+#ifdef __APPLE__
#include "Python.h"
#include "pyobjc-api.h"
@@ -178,3 +179,5 @@
INITDONE();
}
+
+#endif // __APPLE__
Index: Modules/objc/test/specialtypecodes.m
===================================================================
--- Modules/objc/test/specialtypecodes.m (revision 2606)
+++ Modules/objc/test/specialtypecodes.m (working copy)
@@ -7,6 +7,8 @@
#import <Foundation/Foundation.h>
+#define UniChar unichar
+
#ifndef NSINTEGER_DEFINED
typedef unsigned int NSUInteger;
Index: Modules/objc/test/cfsocket.m
===================================================================
--- Modules/objc/test/cfsocket.m (revision 2606)
+++ Modules/objc/test/cfsocket.m (working copy)
@@ -1,6 +1,7 @@
/*
* This module is used in the unittests for object identity.
*/
+#ifdef __APPLE__
#include "Python.h"
#include "pyobjc-api.h"
@@ -80,3 +81,4 @@
INITDONE();
}
+#endif
Index: Modules/objc/test/fsref.m
===================================================================
--- Modules/objc/test/fsref.m (revision 2606)
+++ Modules/objc/test/fsref.m (working copy)
@@ -1,6 +1,7 @@
/*
* This module is used for tests dealing with FSRef "objects"
*/
+#ifdef __APPLE__
#include "Python.h"
#include "pyobjc-api.h"
@@ -128,3 +129,4 @@
INITDONE();
}
+#endif
Index: Modules/objc/test/ctests.m
===================================================================
--- Modules/objc/test/ctests.m (revision 2606)
+++ Modules/objc/test/ctests.m (working copy)
@@ -6,6 +6,7 @@
*/
#include "pyobjc-api.h"
#include "pyobjc-compat.h"
+#include <stdbool.h>
#if PY_VERSION_HEX >= 0x03000000
#define PyInt_AsLong PyLong_AsLong
Index: Modules/objc/OC_PythonString.m
===================================================================
--- Modules/objc/OC_PythonString.m (revision 2606)
+++ Modules/objc/OC_PythonString.m (working copy)
@@ -133,7 +133,8 @@
freeWhenDone:(BOOL)flag
{
#ifndef PyObjC_UNICODE_FAST_PATH
-# error "Wide UNICODE builds are not supported at the moment"
+# warning "Wide UNICODE builds are not supported at the moment"
+ [self doesNotRecognize: _cmd];
#endif
PyObjC_BEGIN_WITH_GIL
PyObject* v;
Index: Modules/objc/pointer-support.m
===================================================================
--- Modules/objc/pointer-support.m (revision 2606)
+++ Modules/objc/pointer-support.m (working copy)
@@ -344,6 +344,7 @@
{
int r = 0;
+#ifdef __APPLE__
r = PyObjCPointerWrapper_RegisterCF(@encode(CFURLRef));
if (r == -1) return -1;
@@ -360,6 +361,7 @@
r = PyObjCPointerWrapper_RegisterCF(@encode(CFRunLoopRef));
if (r == -1) return -1;
+#endif // __APPLE__
r = PyObjCPointerWrapper_Register(@encode(PyObject*),
PyObjectPtr_New, PyObjectPtr_Convert);
Index: Modules/objc/objc_util.m
===================================================================
--- Modules/objc/objc_util.m (revision 2606)
+++ Modules/objc/objc_util.m (working copy)
@@ -1027,7 +1027,8 @@
#if defined(PyObjC_UNICODE_FAST_PATH)
result = PyUnicode_FromUnicode((Py_UNICODE*)array, size);
#else
-# error "Sorry, Wide Unicode builds not supported at the moment"
+# warning "Sorry, Wide Unicode builds not supported at the moment"
+ abort();
#endif
return result;
}
@@ -1143,7 +1144,11 @@
#if defined(PyObjC_UNICODE_FAST_PATH)
result = PyUnicode_FromUnicode((Py_UNICODE*)array, size);
#else
-# error "Sorry, Wide Unicode builds not supported at the moment"
+# warning "Sorry, Wide Unicode builds not supported at the moment"
+ // This is a quick hack so that we just fail tests, we don't abort when
+ // we get to them.
+ return Py_None;
+ abort();
#endif
return result;
}
Index: Modules/objc/OC_PythonNumber.m
===================================================================
--- Modules/objc/OC_PythonNumber.m (revision 2606)
+++ Modules/objc/OC_PythonNumber.m (working copy)
@@ -13,8 +13,11 @@
- initWithPythonObject:(PyObject*)v;
{
+ // NSNumber's -init destroys self on GNUstep. This is fixed in trunk.
+#ifndef GNUSTEP
self = [super init];
if (unlikely(self == nil)) return nil;
+#endif
Py_INCREF(v);
Py_XDECREF(value);
Index: Modules/objc/alloc_hack.m
===================================================================
--- Modules/objc/alloc_hack.m (revision 2606)
+++ Modules/objc/alloc_hack.m (working copy)
@@ -2,6 +2,7 @@
* alloc_hack.m -- Implementation of alloc_hack.h
*/
#include "pyobjc.h"
+#include "msg_send_compat.h"
static PyObject*
call_NSObject_alloc(PyObject* method,
Index: Modules/objc/pyobjc.h
===================================================================
--- Modules/objc/pyobjc.h (revision 2606)
+++ Modules/objc/pyobjc.h (working copy)
@@ -1,6 +1,13 @@
+#include <stdbool.h>
+
+#ifndef __strong
+# define __strong
+#endif
+
#ifndef PyObjC_H
#define PyObjC_H
+
/*
* Central include file for PyObjC.
*/
@@ -12,6 +19,62 @@
#define PYOBJC_EXPECTED_CLASS_COUNT 3000
#define PY_SSIZE_T_CLEAN
+#ifdef GNUSTEP
+# ifdef __OBJC2__
+# include <objc/runtime.h>
+#if (defined(__GNU_LIBOBJC__) && (__GNU_LIBOBJC__ >= 20100911))
+struct objc_super
+ {
+ id receiver;
+ Class super_class;
+ };
+#endif
+# else
+# import <ObjectiveC2/runtime.h>
+# define __objc_INCLUDE_GNU
+# define __objc_api_INCLUDE_GNU
+# define __object_INCLUDE_GNU
+# define __encoding_INCLUDE_GNU
+# undef objc_msgSendSuper
+# undef objc_msgSend
+@interface Object { Class isa; } @end
+typedef void* arglist_t;
+#define _C_ID '@'
+#define _C_CLASS '#'
+#define _C_SEL ':'
+#define _C_CHR 'c'
+#define _C_UCHR 'C'
+#define _C_SHT 's'
+#define _C_USHT 'S'
+#define _C_INT 'i'
+#define _C_UINT 'I'
+#define _C_LNG 'l'
+#define _C_ULNG 'L'
+#define _C_LNG_LNG 'q'
+#define _C_ULNG_LNG 'Q'
+#define _C_FLT 'f'
+#define _C_DBL 'd'
+#define _C_BFLD 'b'
+#define _C_BOOL 'B'
+#define _C_VOID 'v'
+#define _C_UNDEF '?'
+#define _C_PTR '^'
+#define _C_CHARPTR '*'
+#define _C_ATOM '%'
+#define _C_ARY_B '['
+#define _C_ARY_E ']'
+#define _C_UNION_B '('
+#define _C_UNION_E ')'
+#define _C_STRUCT_B '{'
+#define _C_STRUCT_E '}'
+#define _C_VECTOR '!'
+#define _C_COMPLEX 'j'
+# endif
+#else
+# include <objc/objc-runtime.h>
+# include <objc/objc.h>
+#endif
+
#include <Python.h>
#include "structmember.h"
#include "pyobjc-compat.h"
@@ -26,14 +89,11 @@
#define PyObjC_ERROR_ABORT 1
-#include <objc/objc-runtime.h>
-#include <objc/objc.h>
-
// how do we make this dependent on sizeof(unichar)??
#if Py_UNICODE_SIZE == 2
#define PyObjC_UNICODE_FAST_PATH
#else
-#error "Py_UNICODE_SIZE != 2 is not supported"
+//#error "Py_UNICODE_SIZE != 2 is not supported"
#endif
#include "objc-runtime-compat.h"
|
|
From: Ronald O. <ron...@ma...> - 2011-07-24 15:47:58
|
On 22 Jul, 2011, at 9:13, Greg Ewing wrote: > I found out what was causing this. Turns out it was blocked > importing encodings.ascii, trying to acquire the import lock. > > The reason it couldn't acquire the import lock is that the > main module of my application was a stub that imported the > real main module, which in turn started the event loop > directly from the module code. > > So the whole app was running inside an import statement, > holding on to the import lock. Once I fixed that, everything > was fine. Ouch. That can be a hard one to debug. Thank you for reporting back on the cause of your problem, Ronald > > -- > Greg > > > ------------------------------------------------------------------------------ > 10 Tips for Better Web Security > Learn 10 ways to better secure your business today. Topics covered include: > Web security, SSL, hacker attacks & Denial of Service (DoS), private keys, > security Microsoft Exchange, secure Instant Messaging, and much more. > http://www.accelacomm.com/jaw/sfnl/114/51426210/ > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
|
From: Diez B. R. <de...@we...> - 2011-07-22 07:40:36
|
On Jul 22, 2011, at 9:13 AM, Greg Ewing wrote: > I found out what was causing this. Turns out it was blocked > importing encodings.ascii, trying to acquire the import lock. > > The reason it couldn't acquire the import lock is that the > main module of my application was a stub that imported the > real main module, which in turn started the event loop > directly from the module code. > > So the whole app was running inside an import statement, > holding on to the import lock. Once I fixed that, everything > was fine. Nice catch... Diez |
|
From: Greg E. <gre...@ca...> - 2011-07-22 07:13:14
|
I found out what was causing this. Turns out it was blocked importing encodings.ascii, trying to acquire the import lock. The reason it couldn't acquire the import lock is that the main module of my application was a stub that imported the real main module, which in turn started the event loop directly from the module code. So the whole app was running inside an import statement, holding on to the import lock. Once I fixed that, everything was fine. -- Greg |
|
From: Ronald O. <ron...@ma...> - 2011-07-17 14:59:54
|
On 16 Jul, 2011, at 4:46, Greg Ewing wrote:
> This is getting extremely weird. It turns out that the
> thread is hanging on the following line in httplib.py:
>
> host_enc = self.host.encode("ascii")
>
> where the string being encoded in my test case is
> '127.0.0.1'.
>
> I can't for the life of me imagine what the ascii codec
> could be doing to cause a thread to block.
>
> Can anyone with more knowledge of the codec system
> shed any light?
Not really. Have you tried getting a C stacktrace using gdb? The only obvious reason for blocking is the GIL: if for some reason the main thread doesn't release the GIL at some point you'll get a hang in the secondary threads. That's pretty unlikely though given that the secondary thread does some work before it hangs.
Debugging would be easier if you had a smallish sample program (a dependency on PyGUI would be fine)
Ronald
|
|
From: Greg E. <gre...@ca...> - 2011-07-16 07:25:28
|
PyGUI 2.5.3 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Clipboard access now implemented on MacOSX, plus a few bug fixes. What is PyGUI? -------------- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing gre...@ca... http://www.cosc.canterbury.ac.nz/greg.ewing/ |
|
From: Greg E. <gre...@ca...> - 2011-07-16 02:46:37
|
This is getting extremely weird. It turns out that the
thread is hanging on the following line in httplib.py:
host_enc = self.host.encode("ascii")
where the string being encoded in my test case is
'127.0.0.1'.
I can't for the life of me imagine what the ascii codec
could be doing to cause a thread to block.
Can anyone with more knowledge of the codec system
shed any light?
Some more data points:
* It doesn't happen when Cocoa is used in a simple way
(just create an NSApplication and call its run() method).
* It also doesn't happen if I just create a PyGUI Application
object and call its run() method.
So it's something about my big complicated PyGUI app... :-(
> Speaking of Cocoa. I don't know if you're doing anything that really requires
> threaded programming or python networking. If not, consider using the
> asynchronous Cocoa networking APIs.
This needs to be cross-platform, so I can't rely on anything
Cocoa-specific.
--
Greg
|
|
From: Jonathan S. <sa...@gm...> - 2011-07-15 13:13:54
|
You might also consider adding a run loop to each thread you fork. I'm not sure how things are handled by pyobjc (eg if it manages run loops in threads for you, I would tend to doubt it), but many networking API in Cocoa require a run loop or Bad Things Happen (TM), where "Bad Things" are usually silent failures or stuck threads. http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html Speaking of Cocoa. I don't know if you're doing anything that really requires threaded programming or python networking. If not, consider using the asynchronous Cocoa networking APIs. They'll keep you out of threaded programming land. Look at NSHttp* and NSURL* classes. YMMV, etc. Cheers, Jonathan Saggau <http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html> On Fri, Jul 15, 2011 at 4:42 AM, Ronald Oussoren <ron...@ma...>wrote: > > On 15 Jul, 2011, at 3:43, Greg Ewing wrote: > > > I'm trying to use httplib to send an http request in > > a background thread. It works fine on its own, but when > > I do it inside a Cocoa application, the thread hangs > > as soon as it tries to send the request. > > > > It doesn't seem to be a GIL problem, because I can do > > other things in the thread leading up to that point. > > It's just sending the request that seems to block. > > > > Is there anything I should be aware of when using > > the threading module in conjunction with pyobjc? > > This should work. One thing you could try is redefining urllib. > proxy_bypass_macosx_sysconf and urllib.getproxies_macosx_sysconf > > def getproxies_macosx_sysconf(): > return {} > > def proxy_bypass_macosx_sysconf(host): > return True > > urllib. getproxies_macosx_sysconf = getproxies_macosx_sysconf > urllib.proxy_bypass_macosx_sysconf = proxy_bypass_macosx_sysconf > > This ensures that urllib doesn't use the OSX specific code for getting the > HTTP proxy configuration. That code should work just fine in a Cocoa > program, but it does call into Apple's frameworks and hence might cause > problems in some way. > > Ronald > > -- > > Greg > > > > > ------------------------------------------------------------------------------ > > AppSumo Presents a FREE Video for the SourceForge Community by Eric > > Ries, the creator of the Lean Startup Methodology on "Lean Startup > > Secrets Revealed." This video shows you how to validate your ideas, > > optimize your ideas and identify your business strategy. > > http://p.sf.net/sfu/appsumosfdev2dev > > _______________________________________________ > > Pyobjc-dev mailing list > > Pyo...@li... > > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > > > ------------------------------------------------------------------------------ > AppSumo Presents a FREE Video for the SourceForge Community by Eric > Ries, the creator of the Lean Startup Methodology on "Lean Startup > Secrets Revealed." This video shows you how to validate your ideas, > optimize your ideas and identify your business strategy. > http://p.sf.net/sfu/appsumosfdev2dev > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > -- Jonathan Saggau jonathansaggau.com This amusement engaged me so much that [friends] were obliged to force me from it; and thus it is with every inclination I give into, it continues to augment, till at length it becomes so powerful, that I lose sight of everything except the favorite amusement. - Rousseau |
|
From: Ronald O. <ron...@ma...> - 2011-07-15 08:43:03
|
On 15 Jul, 2011, at 3:43, Greg Ewing wrote:
> I'm trying to use httplib to send an http request in
> a background thread. It works fine on its own, but when
> I do it inside a Cocoa application, the thread hangs
> as soon as it tries to send the request.
>
> It doesn't seem to be a GIL problem, because I can do
> other things in the thread leading up to that point.
> It's just sending the request that seems to block.
>
> Is there anything I should be aware of when using
> the threading module in conjunction with pyobjc?
This should work. One thing you could try is redefining urllib. proxy_bypass_macosx_sysconf and urllib.getproxies_macosx_sysconf
def getproxies_macosx_sysconf():
return {}
def proxy_bypass_macosx_sysconf(host):
return True
urllib. getproxies_macosx_sysconf = getproxies_macosx_sysconf
urllib.proxy_bypass_macosx_sysconf = proxy_bypass_macosx_sysconf
This ensures that urllib doesn't use the OSX specific code for getting the HTTP proxy configuration. That code should work just fine in a Cocoa program, but it does call into Apple's frameworks and hence might cause problems in some way.
Ronald
> --
> Greg
>
> ------------------------------------------------------------------------------
> AppSumo Presents a FREE Video for the SourceForge Community by Eric
> Ries, the creator of the Lean Startup Methodology on "Lean Startup
> Secrets Revealed." This video shows you how to validate your ideas,
> optimize your ideas and identify your business strategy.
> http://p.sf.net/sfu/appsumosfdev2dev
> _______________________________________________
> Pyobjc-dev mailing list
> Pyo...@li...
> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
|
|
From: Ronald O. <ron...@ma...> - 2011-07-15 08:36:40
|
On 8 Jul, 2011, at 2:50, Greg Ewing wrote: > Ronald Oussoren wrote: > >> To be honest I'm more likely to work on a fork of CPython where a PyObject* >> is toll-free bridged to an Objective-C class, that would solve some problems were >> currently having and might open up other interesting avenues. > > That sounds interesting, but I hope it won't come at the > expense of a version of PyObjC that works with standard > CPython. I don't have plans to work on such a fork, and even with such a fork the regular CPython version PyObjC will be supported. Ronald |
|
From: Diez B. R. <de...@we...> - 2011-07-15 06:53:22
|
On Jul 15, 2011, at 3:43 AM, Greg Ewing wrote: > I'm trying to use httplib to send an http request in > a background thread. It works fine on its own, but when > I do it inside a Cocoa application, the thread hangs > as soon as it tries to send the request. > > It doesn't seem to be a GIL problem, because I can do > other things in the thread leading up to that point. > It's just sending the request that seems to block. > > Is there anything I should be aware of when using > the threading module in conjunction with pyobjc? I've used threads + Cocoa without a hitch, so without more information I can only assume it's something you do. Diez |
|
From: Greg E. <gre...@ca...> - 2011-07-15 01:43:47
|
I'm trying to use httplib to send an http request in a background thread. It works fine on its own, but when I do it inside a Cocoa application, the thread hangs as soon as it tries to send the request. It doesn't seem to be a GIL problem, because I can do other things in the thread leading up to that point. It's just sending the request that seems to block. Is there anything I should be aware of when using the threading module in conjunction with pyobjc? -- Greg |
|
From: <end...@gm...> - 2011-07-11 03:58:36
|
Hi.
I'd like to inform you that I was finally able to access the camera and
take photo programatically.
Let me know if you are interested in more details.
I will post a working port of my iCam project written in PyObjC, relying
on this module, at http://mobile-revival.110mb.com/ReVival/ (alias
http://go.to/slog) in the following days.
iCam is a cross platform video surveillance application using camera phones
that I worked on for more than 1 year.
The project transforms a mobile phone in a surveillance camera with
motion detection.
One can also create a network of such devices connected via Bluetooth or
WiFi, where the master phone transmits via 3G/GSM. The photo/video
information can be uploaded on YouTube, Picasa, etc.
The phone application can be controlled remotely via Internet.
This project is deployed and in use for almost 1 year.
Best regards.
On Thu, Jun 30, 2011 at 1:48 AM, <end...@gm...> wrote:
> Hi.
> I am trying to implement in PyObjC the program available at
>
> https://github.com/erica/iphone-3.0-cookbook-/tree/b8ca8905d17015839a0917e1dcd407d055890236/C07-Images/04-Snapping%20Images.
>
> Although I am a "beginner" in PyObjC, I spent a couple of days trying to
> very seriously translate this script to PyObjC and tried my best to find out
> all errors.
> However, it doesn't work: the application doesn't execute normally after
> entering viewDidLoad() - it doesn't change appearance of UI as specified
> there. I guess it has to do with the fact I am not loading (or using the
> specification) of the TestBedViewController.xib file, which describes
> properties of TestBedViewController - I translated only the main.m and did
> not use by any means the TestBedViewController.xib - I do not know how can I
> load this file in PyObjC on iOS...
> Please find the PyObjC code I wrote so far here:
> http://mobile-revival.110mb.com/ReVival/HelloPython.py .
>
> I run my PyObjC scripts on iOS version 3.1.2. PyObjC is version 1946-4,
> Python is version 2.5.1-5 (obtained with Cydia 1.1.1; and libffi is version
> 130618-4).
>
> Best regards.
> Alex
>
>
|
|
From: <end...@gm...> - 2011-07-10 20:55:26
|
Hi.
I'd like to inform you that I found what the problem was. Basically it
had to do with the fact I didn't start properly the camera viewfinder.
Let me know if you are interested in more details.
I will post a working port of my iCam project written in PyObjC, relying
on this module, at http://mobile-revival.110mb.com/ReVival/ (alias
http://go.to/slog) in the following days.
iCam is a cross platform video surveillance application using camera phones
that I worked on for more than 1 year.
The project transforms a mobile phone in a surveillance camera with
motion detection.
One can also create a network of such devices connected via Bluetooth or
WiFi, where the master phone transmits via 3G/GSM. The photo/video
information can be uploaded on YouTube, Picasa, etc.
The phone application can be controlled remotely via Internet.
This project is deployed and in use for almost 1 year.
Best regards.
On Sat, Jul 9, 2011 at 12:54 AM, <...> wrote:
> Hi.
> When I load UIKit with
> myUIKit = objc.loadBundle("UIKit", globals(),
> "/System/Library/Frameworks/UIKit.framework")
> I import a lot of symbols, but a few protocols such as
> UIImagePickerControllerDelegate and UINavigationControllerDelegate are not
> loaded with this occasion (probably because they are not used in any any
> other place).
>
> Could you please tell me if you have an idea on what goes wrong when
> using UIImagePickerController with UIImagePickerControllerDelegate in the
> code below.
> The symptom is the following: none of the methods of MyDelegate don't
> get called, although ipc.takePicture() should call them.
> Documentation on how to use UIImagePickerController at:
> -
> http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/CameraAndPhotoLib_TopicsForIOS/Articles/TakingPicturesAndMovies.html#//apple_ref/doc/uid/TP40010406
> -
> http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html#//apple_ref/occ/cl/UIImagePickerController
>
> """
> Following
> http://pyobjc.sourceforge.net/documentation/pyobjc-core/wrapping.html:
> "If the framework defines any (informal) protocols you should add
> objc.informal_protocol objects for those protocols to your module. These can
> be defined in a submodule, as long as you arrange for that module to be
> loaded whenever someone imports your package."
> """
> UIImagePickerControllerDelegate =
> objc.informal_protocol("UIImagePickerControllerDelegate", [
> #- (void)imagePickerController:(UIImagePickerController *)picker
> didFinishPickingMediaWithInfo:(NSDictionary *)info
> objc.selector(None,
> selector="imagePickerController:didFinishPickingMediaWithInfo:",
> signature="v@:@@"),
> #- (void)imagePickerControllerDidCancel:(UIImagePickerController
> *)picker
> objc.selector(None, selector="imagePickerControllerDidCancel:",
> signature="v@:@"),
> #- (void) imagePickerController:(UIImagePickerController *)picker
> didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary
> *)editingInfo
> objc.selector(None,
> selector="imagePickerController:didFinishPickingImage:editingInfo:",
> signature="v@:@@@")
> #objc.selector(None, selector="testMethod", signature="I@:",
> isRequired=1), #isClassMethod=1
> ])
> UINavigationControllerDelegate =
> objc.formal_protocol("UINavigationControllerDelegate",
> (objc.protocolNamed("NSObject"), ), [
> #The protocol defines methods that the delegate CAN implement (NOT
> mandatory)
> #- (void)navigationController:(UINavigationController
> *)navigationController didShowViewController:(UIViewController
> *)viewController animated:(BOOL)animated
> #- (void)navigationController:(UINavigationController
> *)navigationController willShowViewController:(UIViewController
> *)viewController animated:(BOOL)animated
> ])
>
> #class MyDelegate(UINavigationControllerDelegate): #function takes at most
> 1 argument (3 given). ANYHOW BAD BECAUSE I MISTAKED AND USED
> UINavigationControllerDelegate
> class MyDelegate(NSObject, UIImagePickerControllerDelegate):
> #- (void) imagePickerController:(UIImagePickerController *)picker
> didFinishPickingMediaWithInfo:(NSDictionary *)info
> @objc.signature("v@:@@")
> def imagePickerController_didFinishPickingMediaWithInfo_(self, picker,
> info):
> try:
> print "Entered
> imagePickerController_didFinishPickingMediaWithInfo_(self, picker = %s, info
> = %s)." % (str(picker), str(info))
> sys.stdout.flush()
>
> picker.release()
> except:
> traceback.print_exc()
> sys.stderr.flush()
>
> #Provide 2.x compliance
> #- (void) imagePickerController:(UIImagePickerController *)picker
> didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary
> *)editingInfo
> @objc.signature("v@:@@@")
> def imagePickerController_didFinishPickingImage_editingInfo_(self,
> picker, image, editingInfo):
> try:
> print "Entered
> imagePickerController_didFinishPickingImage_editingInfo_(self, picker = %s,
> image = %s, editingInfo = %s)." % (str(picker), str(image),
> str(editingInfo))
> sys.stdout.flush()
>
> #NSDictionary *dict = [NSDictionary dictionaryWithObject:image
> forKey:@"UIImagePickerControllerOriginalImage"];
>
> self.imagePickerController_didFinishPickingMediaWithInfo_(picker, dict)
> except:
> traceback.print_exc()
> sys.stderr.flush()
>
> #- (void) imagePickerControllerDidCancel:
> @objc.signature("v@:@")
> def imagePickerControllerDidCancel_(self, picker):
> try:
> print "Entered imagePickerControllerDidCancel_(self, picker =
> %s)." % (str(picker))
> sys.stdout.flush()
>
> self.dismissModalViewControllerAnimated_(objc.YES)
> picker.release()
> except:
> traceback.print_exc()
> sys.stderr.flush()
>
> ipcDelegate = MyDelegate.alloc().init()
>
> ...
> ipc = UIImagePickerController.alloc().init()
> ...
> ipc.takePicture()
>
>
> Thank you.
>
>
|
|
From: <end...@gm...> - 2011-07-08 21:54:27
|
Hi.
When I load UIKit with
myUIKit = objc.loadBundle("UIKit", globals(),
"/System/Library/Frameworks/UIKit.framework")
I import a lot of symbols, but a few protocols such as
UIImagePickerControllerDelegate and UINavigationControllerDelegate are not
loaded with this occasion (probably because they are not used in any any
other place).
Could you please tell me if you have an idea on what goes wrong when
using UIImagePickerController with UIImagePickerControllerDelegate in the
code below.
The symptom is the following: none of the methods of MyDelegate don't
get called, although ipc.takePicture() should call them.
Documentation on how to use UIImagePickerController at:
-
http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/CameraAndPhotoLib_TopicsForIOS/Articles/TakingPicturesAndMovies.html#//apple_ref/doc/uid/TP40010406
-
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html#//apple_ref/occ/cl/UIImagePickerController
"""
Following
http://pyobjc.sourceforge.net/documentation/pyobjc-core/wrapping.html:
"If the framework defines any (informal) protocols you should add
objc.informal_protocol objects for those protocols to your module. These can
be defined in a submodule, as long as you arrange for that module to be
loaded whenever someone imports your package."
"""
UIImagePickerControllerDelegate =
objc.informal_protocol("UIImagePickerControllerDelegate", [
#- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
objc.selector(None,
selector="imagePickerController:didFinishPickingMediaWithInfo:",
signature="v@:@@"),
#- (void)imagePickerControllerDidCancel:(UIImagePickerController
*)picker
objc.selector(None, selector="imagePickerControllerDidCancel:",
signature="v@:@"),
#- (void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary
*)editingInfo
objc.selector(None,
selector="imagePickerController:didFinishPickingImage:editingInfo:",
signature="v@:@@@")
#objc.selector(None, selector="testMethod", signature="I@:",
isRequired=1), #isClassMethod=1
])
UINavigationControllerDelegate =
objc.formal_protocol("UINavigationControllerDelegate",
(objc.protocolNamed("NSObject"), ), [
#The protocol defines methods that the delegate CAN implement (NOT
mandatory)
#- (void)navigationController:(UINavigationController
*)navigationController didShowViewController:(UIViewController
*)viewController animated:(BOOL)animated
#- (void)navigationController:(UINavigationController
*)navigationController willShowViewController:(UIViewController
*)viewController animated:(BOOL)animated
])
#class MyDelegate(UINavigationControllerDelegate): #function takes at most 1
argument (3 given). ANYHOW BAD BECAUSE I MISTAKED AND USED
UINavigationControllerDelegate
class MyDelegate(NSObject, UIImagePickerControllerDelegate):
#- (void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
@objc.signature("v@:@@")
def imagePickerController_didFinishPickingMediaWithInfo_(self, picker,
info):
try:
print "Entered
imagePickerController_didFinishPickingMediaWithInfo_(self, picker = %s, info
= %s)." % (str(picker), str(info))
sys.stdout.flush()
picker.release()
except:
traceback.print_exc()
sys.stderr.flush()
#Provide 2.x compliance
#- (void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary
*)editingInfo
@objc.signature("v@:@@@")
def imagePickerController_didFinishPickingImage_editingInfo_(self,
picker, image, editingInfo):
try:
print "Entered
imagePickerController_didFinishPickingImage_editingInfo_(self, picker = %s,
image = %s, editingInfo = %s)." % (str(picker), str(image),
str(editingInfo))
sys.stdout.flush()
#NSDictionary *dict = [NSDictionary dictionaryWithObject:image
forKey:@"UIImagePickerControllerOriginalImage"];
self.imagePickerController_didFinishPickingMediaWithInfo_(picker, dict)
except:
traceback.print_exc()
sys.stderr.flush()
#- (void) imagePickerControllerDidCancel:
@objc.signature("v@:@")
def imagePickerControllerDidCancel_(self, picker):
try:
print "Entered imagePickerControllerDidCancel_(self, picker =
%s)." % (str(picker))
sys.stdout.flush()
self.dismissModalViewControllerAnimated_(objc.YES)
picker.release()
except:
traceback.print_exc()
sys.stderr.flush()
ipcDelegate = MyDelegate.alloc().init()
...
ipc = UIImagePickerController.alloc().init()
...
ipc.takePicture()
Thank you.
|
|
From: Greg E. <gre...@ca...> - 2011-07-08 00:51:17
|
Ronald Oussoren wrote: > To be honest I'm more likely to work on a fork of CPython where a PyObject* > is toll-free bridged to an Objective-C class, that would solve some problems were > currently having and might open up other interesting avenues. That sounds interesting, but I hope it won't come at the expense of a version of PyObjC that works with standard CPython. -- Greg |
|
From: Ronald O. <ron...@ma...> - 2011-07-07 08:14:12
|
On 5 Jul, 2011, at 17:50, Leonardo Santagada wrote: > On Tue, Jul 5, 2011 at 12:21 PM, Lawrence Akka > <la...@us...> wrote: >> 4) Clang: interesting. I have been playing with clang compilation of >> PyObjC generally, today. Had a couple of problems with libxml though. > > Any chance that while rewriting you do a pure python version of > pyobjc? pyglet is using a pure python bridge to objective-c because > getting pyobjc compiled is a pain. And specially now that pypy can run > ctypes faster than python c extensions I would say it is time to think > about it. It is unlikely that I'll rewrite PyObjC using ctypes anytime soon. Porting to PyPy would need some rearchitecturing anyway as the current implementation is pretty tightly bound to the CPython implementation anyway. To be honest I'm more likely to work on a fork of CPython where a PyObject* is toll-free bridged to an Objective-C class, that would solve some problems were currently having and might open up other interesting avenues. BTW. What problems are you haveing with compiling PyObjC? Would those be solved by having a single archive with an install script that compiles the various bit of PyObjC in the right order? Ronald |
|
From: Ronald O. <ron...@ma...> - 2011-07-07 08:04:54
|
On 5 Jul, 2011, at 17:21, Lawrence Akka wrote: > > > On Tue, 05 Jul 2011 17:02 +0200, "Ronald Oussoren" > <ron...@ma...> wrote: >> >> On 19 Jun, 2011, at 12:39, Lawrence Akka wrote: >> >>> I notice that at the end of last year Ronald said he intended to >>> move the PyObjC repository from SVN to mercurial, to join py2app and >>> friends which have already been transferred. >>> >>> In an attempt to be helpful and for my own purposes I have >>> successfully (I hope) created a copy of the PyObjC SVN repository >>> using mercurial at bitbucket: https://bitbucket.org/lakka/pyobjc >>> >>> All history/branches/tags have been preserved (though some of them >>> might usefully be closed off), but please open an issue if you find >>> any problems. I would be delighted if Ronald wanted to move/clone >>> this into his account! >>> >>> I hope soon to be able to contribute to the project some work I have >>> done reorganising the Sphinx documentation and updating the >>> examples. >> >> Cool, the documentation definitely needs work. I also want to redo >> the website, I have to update the scripts to generate the site >> anyway because of the move to sphinx and the site design needs some >> love as well. >> >> >> I already have a mercurial repository on my machine, but haven't >> uploaded that to bitbucket yet. >> >> BTW. I've started the port to Lion, but that's going slower than I'd >> want. I've decided to rewrite my metadata generator using the python >> bindings to clang, the current heap of regular expressions barely >> works and causes to much problems. From what I've seen so far it >> should be fairly easy to using clang.cindex as the parser. >> >> Ronald >> > > 1) Bitbucket: By all means clone mine and become the 'master' > repository if that is easier. I have done some optimisation to > shrink the size of the repo, but there remains some work to do to > close off unneeded branches etc. Alternatively, once you upload your > version, I'll delete my own conversion. I've already closed unnecessary branches in my copy, I just need to upload it. > > 2) Docs: Work has begun! I have reorganized/deduplicated and edited some > of what exists at the moment, and started to write additions. At the > moment, I am keeping this in a private patch queue, but once the > definitive repo has been set up, I will move over to public clone. > > 3) Sphinx: I have also updated the docs to use the newest Sphinx, and > had in mind seeing what I could do to generate the entire website > using Sphinx if you would like me to. I would only be able to turn > to that after the bulk of the docs have been written, though. > > 4) Clang: interesting. I have been playing with clang compilation of > PyObjC generally, today. Had a couple of problems with libxml though. I've also been playing with clang, and have fixed a number of bugs in my tree thanks to its static analyzer. Adding support for Py_INCREF/Py_DECREF to that analyzer would be a neat project for anyone that wants to do some easy-ish compiler hacking ;-) I haven't run into issues with libxml because I've recently removed libxml from my tree: I'm now "compiling" the XML file into a python file and use that to lazily initialize the wrapper modules. The intention is to improve PyObjC's startup speed and memory usage by reducing the amount of work that's done up front, and the implementation seems to to that if you use 'import Cocoa' instead of 'from Cocoa import *'. Ronald > > Lawrence > > ------------------------------------------------------------------------------ > All of the data generated in your IT infrastructure is seriously valuable. > Why? It contains a definitive record of application performance, security > threats, fraudulent activity, and more. Splunk takes this data and makes > sense of it. IT sense. And common sense. > http://p.sf.net/sfu/splunk-d2d-c2 > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev |
|
From: Leonardo S. <san...@gm...> - 2011-07-05 15:50:59
|
On Tue, Jul 5, 2011 at 12:21 PM, Lawrence Akka <la...@us...> wrote: > 4) Clang: interesting. I have been playing with clang compilation of > PyObjC generally, today. Had a couple of problems with libxml though. Any chance that while rewriting you do a pure python version of pyobjc? pyglet is using a pure python bridge to objective-c because getting pyobjc compiled is a pain. And specially now that pypy can run ctypes faster than python c extensions I would say it is time to think about it. -- Leonardo Santagada |
|
From: Lawrence A. <la...@us...> - 2011-07-05 15:21:32
|
On Tue, 05 Jul 2011 17:02 +0200, "Ronald Oussoren" <ron...@ma...> wrote: > > On 19 Jun, 2011, at 12:39, Lawrence Akka wrote: > > > I notice that at the end of last year Ronald said he intended to > > move the PyObjC repository from SVN to mercurial, to join py2app and > > friends which have already been transferred. > > > > In an attempt to be helpful and for my own purposes I have > > successfully (I hope) created a copy of the PyObjC SVN repository > > using mercurial at bitbucket: https://bitbucket.org/lakka/pyobjc > > > > All history/branches/tags have been preserved (though some of them > > might usefully be closed off), but please open an issue if you find > > any problems. I would be delighted if Ronald wanted to move/clone > > this into his account! > > > > I hope soon to be able to contribute to the project some work I have > > done reorganising the Sphinx documentation and updating the > > examples. > > Cool, the documentation definitely needs work. I also want to redo > the website, I have to update the scripts to generate the site > anyway because of the move to sphinx and the site design needs some > love as well. > > > I already have a mercurial repository on my machine, but haven't > uploaded that to bitbucket yet. > > BTW. I've started the port to Lion, but that's going slower than I'd > want. I've decided to rewrite my metadata generator using the python > bindings to clang, the current heap of regular expressions barely > works and causes to much problems. From what I've seen so far it > should be fairly easy to using clang.cindex as the parser. > > Ronald > 1) Bitbucket: By all means clone mine and become the 'master' repository if that is easier. I have done some optimisation to shrink the size of the repo, but there remains some work to do to close off unneeded branches etc. Alternatively, once you upload your version, I'll delete my own conversion. 2) Docs: Work has begun! I have reorganized/deduplicated and edited some of what exists at the moment, and started to write additions. At the moment, I am keeping this in a private patch queue, but once the definitive repo has been set up, I will move over to public clone. 3) Sphinx: I have also updated the docs to use the newest Sphinx, and had in mind seeing what I could do to generate the entire website using Sphinx if you would like me to. I would only be able to turn to that after the bulk of the docs have been written, though. 4) Clang: interesting. I have been playing with clang compilation of PyObjC generally, today. Had a couple of problems with libxml though. Lawrence |
|
From: Ronald O. <ron...@ma...> - 2011-07-05 15:02:50
|
On 19 Jun, 2011, at 12:39, Lawrence Akka wrote: > I notice that at the end of last year Ronald said he intended to move the PyObjC repository from SVN to mercurial, to join py2app and friends which have already been transferred. > > In an attempt to be helpful and for my own purposes I have successfully (I hope) created a copy of the PyObjC SVN repository using mercurial at bitbucket: https://bitbucket.org/lakka/pyobjc > > All history/branches/tags have been preserved (though some of them might usefully be closed off), but please open an issue if you find any problems. I would be delighted if Ronald wanted to move/clone this into his account! > > I hope soon to be able to contribute to the project some work I have done reorganising the Sphinx documentation and updating the examples. Cool, the documentation definitely needs work. I also want to redo the website, I have to update the scripts to generate the site anyway because of the move to sphinx and the site design needs some love as well. I already have a mercurial repository on my machine, but haven't uploaded that to bitbucket yet. BTW. I've started the port to Lion, but that's going slower than I'd want. I've decided to rewrite my metadata generator using the python bindings to clang, the current heap of regular expressions barely works and causes to much problems. From what I've seen so far it should be fairly easy to using clang.cindex as the parser. Ronald |
|
From: Ronald O. <ron...@ma...> - 2011-07-05 14:43:43
|
On 18 Jun, 2011, at 7:05, Greg Ewing wrote: > Invisible Bob wrote: >> I am on the PyObjC list and got this email, will it work on an >> i-(phone/touch)? > > I have absolutely no idea. Someone will have to try it to find out. It is unlikely that pyobjc will work on iOS because the included copy of libffi doesn't work with the ARM platform used in iOS devices. I also have no intention of supporting iOS at the moment. Ronald |
|
From: <end...@gm...> - 2011-06-29 22:48:27
|
Hi. I am trying to implement in PyObjC the program available at https://github.com/erica/iphone-3.0-cookbook-/tree/b8ca8905d17015839a0917e1dcd407d055890236/C07-Images/04-Snapping%20Images. Although I am a "beginner" in PyObjC, I spent a couple of days trying to very seriously translate this script to PyObjC and tried my best to find out all errors. However, it doesn't work: the application doesn't execute normally after entering viewDidLoad() - it doesn't change appearance of UI as specified there. I guess it has to do with the fact I am not loading (or using the specification) of the TestBedViewController.xib file, which describes properties of TestBedViewController - I translated only the main.m and did not use by any means the TestBedViewController.xib - I do not know how can I load this file in PyObjC on iOS... Please find the PyObjC code I wrote so far here: http://mobile-revival.110mb.com/ReVival/HelloPython.py . I run my PyObjC scripts on iOS version 3.1.2. PyObjC is version 1946-4, Python is version 2.5.1-5 (obtained with Cydia 1.1.1; and libffi is version 130618-4). Best regards. Alex |
|
From: Lawrence A. <la...@us...> - 2011-06-29 22:27:22
|
On 29 Jun 2011, at 23:04, Diez B. Roggisch wrote: > > On Jun 29, 2011, at 11:23 PM, Thomas Cool wrote: > >> Hello, >> I'm starting with PyObjC and am having some trouble creating windows >> I am not a beginner at either python or cocoa by the way. >> >> Here is what i am trying (both with macports python 2.6 and builtin python 2.6) on 10.6.8 >> >> from AppKit import * >> a=NSWindow.alloc().init() >> >> simply this returns an error: >> >> Wed Jun 29 16:23:09 TCi7.local python[10060] <Error>: kCGErrorInvalidConnection: CGSGetCurrentCursorLocation: Invalid connection >> Wed Jun 29 16:23:09 TCi7.local python[10060] <Error>: kCGErrorInvalidConnection: CGSNewWindowWithOpaqueShape: Invalid connection >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> objc.error: NSInternalInconsistencyException - Error (1002) creating CGSWindow > > > Let me guess, you just wrote that into a script, and executed it? > > It won't work in Objective-C either, if all you do is just to create a simple executable. > > Instead, you need to create an application bundle, using py2app. Otherwise, the window-server refuses to accept connections. I never really bothered to get to know the gory details, but see e.g. this discussion: > > http://stackoverflow.com/questions/3704629/why-cant-i-use-cocoa-classes-from-my-python-script > > And especially the related tech-note. > > Diez You need to create an application object first. Try something like this. #!/usr/bin/env python # encoding: utf-8 import sys import os # We need to import the relvant object definitions from PyObjC from AppKit import * from PyObjCTools import AppHelper # Cocoa prefers composition to inheritance. The members of an object's # delegate will be called upon the happening of certain events. Once we define # methods with particular names, they will be called automatically class Delegate (NSObject): def applicationDidFinishLaunching_(self, aNotification): '''Called automatically when the application has launched''' print "Hello, World!" def windowWillClose_(self, aNotification): '''Called automatically when the window is closed''' print "Window has been closed" # Terminate the application NSApp().terminate_(self) def main(): # Create a new application instance ... a=NSApplication.sharedApplication() # ... and create its delgate. Note the use of the # Objective C constructors below, because Delegate # is a subcalss of an Objective C class, NSObject delegate = Delegate.alloc().init() # Tell the application which delegate object to use. a.setDelegate_(delegate) # Now we can can start to create the window ... frame = ((200.0, 300.0), (250.0, 100.0)) # (Don't worry about these parameters for the moment. They just specify # the type of window, its size and position etc) w = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(frame, 15, 2, 0) # ... tell it which delegate object to use (here it happens # to be the same delegate as the application is using)... w.setDelegate_(delegate) # ... and set some properties. Unicode strings are preferred. w.setTitle_(u'Hello, World!') # All set. Now we can show the window ... w.orderFrontRegardless() # ... and start the application AppHelper.runEventLoop() if __name__ == '__main__': main() |