Commits

Ronald Oussoren committed 9845aef

* descriptors: actually export the new namedSelector
* pyobjc-api.h: re-add PyObjCObject_Convert, remove pyobjc-compat.h definitions
* export pyobjc-api.h and pyobjc-compat.h in the pyobjc egg-file, to make
it easier to use the right headers in the framework wrappers.
(This does require updates to the setup files of those wrappers)

Comments (0)

Files changed (5)

pyobjc-core/Lib/objc/_descriptors.py

 This module defines the core interfaces of the Python<->Objective-C bridge.
 """
 
-__all__ = ['IBOutlet', 'IBAction', 'accessor', 'Accessor', 'typedAccessor', 'callbackFor', 'selectorFor', 'synthesize', 'namedselector', 'typedSelector' ]
+__all__ = ['IBOutlet', 'IBAction', 'accessor', 'Accessor', 'typedAccessor', 'callbackFor', 'selectorFor', 'synthesize', 'namedselector', 'typedSelector', 'namedSelector' ]
 
 from objc._objc import ivar, selector, _makeClosure, selector, _C_SEL, _C_ID
 import sys, textwrap
 
 def namedselector(name, signature=None):
     import warnings
-    warnings.warn("use objc.namedSelector instead of objc.namedselector")
+    warnings.warn("use objc.namedSelector instead of objc.namedselector", stacklevel=2)
     return namedSelector(name, signature)
 
 def typedAccessor(typeSignature):

pyobjc-core/Modules/objc/pyobjc-api.h

 
 #import <Foundation/Foundation.h>
 
+#include "pyobjc-compat.h"
+
 #ifndef CGFLOAT_DEFINED
 
 #ifdef __LP64__
 #endif
 
 
-#ifndef PyObjC_COMPAT_H
-#if (PY_VERSION_HEX < 0x02050000)
-typedef int Py_ssize_t;
-#define PY_FORMAT_SIZE_T ""
-#define Py_ARG_SIZE_T "i"
-#define PY_SSIZE_T_MAX INT_MAX
-
-#else
-
-#define Py_ARG_SIZE_T "n"
-#endif
-#endif
-
 #import <Foundation/NSException.h>
 
 struct PyObjC_WeakLink {
 	int (*is_ascii_string)(PyObject* unicode_string, const char* ascii_string);
 	int (*is_ascii_prefix)(PyObject* unicode_string, const char* ascii_string, size_t n);
 
+	int (*pyobjcobject_convert)(PyObject*,void*);
 };
 
 #ifndef PYOBJC_BUILD
 #define PyObjC_NULL		  (*(PyObjC_API->pyobjc_null))
 #define PyObjC_DepythonifyCArray  (PyObjC_API->dep_c_array_count)
 #define PyObjC_VarList_New  (PyObjC_API->varlistnew)
+#define PyObjCObject_Convert (PyObjC_API->pyobjcobject_convert)
+
 
 
 #ifndef PYOBJC_METHOD_STUB_IMPL

pyobjc-core/Modules/objc/pyobjc-api.m

 #undef PyObjCObject_GetObject
 #endif
 
+
 static void do_weaklink(PyObject* module_dict, struct PyObjC_WeakLink* funcs)
 {
 	while (funcs->name) {
 	PyObjC_VarList_New,		/* PyObjC_VarList_New */
 	PyObjC_is_ascii_string,
 	PyObjC_is_ascii_prefix,
-
+	PyObjCObject_Convert,
 };
 
 int PyObjCAPI_Register(PyObject* module)

pyobjc-core/NEWS.txt

 Version 2.3a0
 -------------
 
+- The PyObjC egg now includes the header files that should be used to
+  compile to compile the extensions in the framework wrappers, which makes
+  it a lot easier to access those headers.
+
+- BUGFIX: The definition for Py_ARG_SIZE_T was incorrect, which causes
+  problems in 64-bit code.
 
 - Initial port to Python 3.x
 

pyobjc-core/setup.py

             
             unittest.main(None, None, [unittest.__file__]+self.test_args)
 
+from setuptools.command import egg_info as orig_egg_info
+
+def write_header(cmd, basename, filename):
+    data = open(os.path.join('Modules/objc/', os.path.basename(basename)), 'rU').read()
+    if not cmd.dry_run:
+        if not os.path.exists(os.path.dirname(filename)):
+            os.makedirs(os.path.dirname(filename))
+
+    cmd.write_file(basename, filename, data)
+
+
+# This is a workaround for a bug in setuptools: I'd like
+# to use the 'egg_info.writers' entry points in the setup()
+# call, but those don't work when also using a package_base
+# argument as we do.
+# (issue 123 in the distribute tracker)
+class egg_info (orig_egg_info.egg_info):
+    def run(self):
+        orig_egg_info.egg_info.run(self)
+
+        for hdr in ("pyobjc-compat.h", "pyobjc-api.h"):
+            fn = os.path.join("include", hdr)
+
+            write_header(self, fn, os.path.join(self.egg_info, fn))
 
 if sys.version_info[0] == 3:
     # FIXME: add custom test command that does the work.
 Topic :: Software Development :: User Interfaces
 """.splitlines())
 
+
 dist = setup(
     name = "pyobjc-core", 
     version = package_version(),
     namespace_packages = ['PyObjCTools'],
     package_dir = { '': 'Lib', 'PyObjCTest': 'PyObjCTest' },
     extra_path = "PyObjC",
-    cmdclass = {'build_ext': pyobjc_build_ext, 'install_lib': pyobjc_install_lib, 'build_py': oc_build_py, 'test': oc_test },
+    cmdclass = {'build_ext': pyobjc_build_ext, 'install_lib': pyobjc_install_lib, 'build_py': oc_build_py, 'test': oc_test, 'egg_info':egg_info },
     options = {'egg_info': {'egg_base': 'Lib'}},
     classifiers = CLASSIFIERS,
     license = 'MIT License',
     download_url = 'http://pyobjc.sourceforge.net/software/index.php',
     test_suite='PyObjCTest.loader.makeTestSuite',
     zip_safe = False,
+#    entry_points = {
+#        "egg_info.writers": [
+#            "include/pyobjc-api.h = __main__:write_header",
+#            "include/pyobjc-compat.h = __main__:write_header",
+#        ],
+#    },
     **extra_args
 )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.