[PyObjC-svn] r1984 - in trunk/pyobjc/pyobjc-core: . Lib/objc/test Modules/objc Modules/objc/test

[email protected]
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Sun Jan 20 09:30:31 2008
New Revision: 1984

Log:
This checking adds the class OC_PythonDate as the proxy
class for instances of datetime.date and datetime.datetime.




Added:
   trunk/pyobjc/pyobjc-core/Lib/objc/test/test_nsdate_proxy.py   (contents, props changed)
   trunk/pyobjc/pyobjc-core/Modules/objc/OC_PythonDate.h   (contents, props changed)
   trunk/pyobjc/pyobjc-core/Modules/objc/OC_PythonDate.m
Modified:
   trunk/pyobjc/pyobjc-core/Modules/objc/OC_PythonObject.m
   trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc-api.h
   trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc-compat.h
   trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc.h
   trunk/pyobjc/pyobjc-core/Modules/objc/test/testbndl.m
   trunk/pyobjc/pyobjc-core/NEWS.txt

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/OC_PythonObject.m
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/OC_PythonObject.m	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/OC_PythonObject.m	Sun Jan 20 09:30:31 2008
@@ -247,6 +247,15 @@
 		if (PyErr_Occurred()) {
 			PyObjC_GIL_FORWARD_EXC();
 		}
+		
+		/* Check if the object is "datetime-like" */
+		instance = [OC_PythonDate depythonifyObject:obj];
+		if (instance != nil) {
+			PyObjC_GIL_RETURN(instance);
+		} 
+		if (PyErr_Occurred()) {
+			PyObjC_GIL_FORWARD_EXC();
+		}
 
 		/* If all else fails use the generic proxy */
 		instance = [[self alloc] initWithObject:obj];

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc-api.h
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc-api.h	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc-api.h	Sun Jan 20 09:30:31 2008
@@ -32,14 +32,6 @@
 #endif
 #endif
 
-#ifndef NSUInteger
-# define NSUInteger unsigned int
-#endif
-#ifndef NSInteger
-# define NSInteger int
-#endif
-
-
 #import <Foundation/NSException.h>
 
 struct PyObjC_WeakLink {

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc-compat.h
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc-compat.h	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc-compat.h	Sun Jan 20 09:30:31 2008
@@ -60,9 +60,12 @@
 
 #else
 
+#ifndef Py_ARG_SIZE_T
 #define Py_ARG_SIZE_T "n"
 #endif
 
+#endif
+
 
 /* NSInteger and friends are available on Leopard and later, define them here
  * for compatibility with earlier versions.

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc.h
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc.h	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/pyobjc.h	Sun Jan 20 09:30:31 2008
@@ -36,6 +36,7 @@
 #include "OC_PythonUnicode.h"
 #include "OC_PythonString.h"
 #include "OC_PythonEnumerator.h"
+#include "OC_PythonDate.h"
 #include "method-signature.h"
 #include "objc_util.h"
 #include "objc-class.h"

Modified: trunk/pyobjc/pyobjc-core/Modules/objc/test/testbndl.m
==============================================================================
--- trunk/pyobjc/pyobjc-core/Modules/objc/test/testbndl.m	(original)
+++ trunk/pyobjc/pyobjc-core/Modules/objc/test/testbndl.m	Sun Jan 20 09:30:31 2008
@@ -15,6 +15,7 @@
 
 #include <Python.h>
 #include <pyobjc-api.h>
+#include <pyobjc-compat.h>
 
 #import <Foundation/Foundation.h>
 

Modified: trunk/pyobjc/pyobjc-core/NEWS.txt
==============================================================================
--- trunk/pyobjc/pyobjc-core/NEWS.txt	(original)
+++ trunk/pyobjc/pyobjc-core/NEWS.txt	Sun Jan 20 09:30:31 2008
@@ -7,6 +7,10 @@
 Version 2.1 (...)
 -----------------
 
+- There now is a custom proxy class for instances of ``datetime.date`` and
+  ``datetime.datetime``, which takes away the need to manually convert these
+  instances before using them from Objective-C (such as using an 
+  ``NSDateFormatter``)
 
 - PyObjC can now run in 64-bit mode.
 
@@ -14,8 +18,8 @@
   haven't tried running real programs yet and hence there might be issues 
   lurking below the surface.
 
-  NOTE2: PPC64 support is completely untested, aka "it compiles and therefore 
-  must work".
+  NOTE: 64-bit support does not yet work on PPC due to a bug in libffi which
+  prefents catching Objective-C exceptions.
 
   This requires Leopard (OSX 10.5), earlier version of the OS don't have a 
   64-bit Objective-C runtime at all.  This currently also requires a copy of 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.