1. Ronald Oussoren
  2. pyobjc

Commits

Ronald Oussoren  committed 59ff625

- Fix compiler warning in Modules/Cocoa
- Add constants for AddressBook framework

  • Participants
  • Parent commits bf5a9b6
  • Branches pyobjc-ancient

Comments (0)

Files changed (9)

File Modules/Cocoa/_Addr_Enum.inc

View file
+/*
+ * Enumeration constants. This file is generated from files in
+ * /System/Library/Frameworks/AddressBook.framework/Headers
+ */
+static struct inttable enum_table[] = {
+
+	/* From: ABAddressBook.h */
+
+	/* From: ABAddressBookC.h */
+
+	/* From: ABGlobals.h */
+
+	/* From: ABGlobalsC.h */
+
+	/* From: ABGroup.h */
+
+	/* From: ABImageLoading.h */
+
+	/* From: ABMultiValue.h */
+
+	/* From: ABPerson.h */
+
+	/* From: ABRecord.h */
+
+	/* From: ABSearchElement.h */
+
+	/* From: ABTypedefs.h */
+	 { "kABErrorInProperty", kABErrorInProperty },
+	 { "kABStringProperty", kABStringProperty },
+	 { "kABIntegerProperty", kABIntegerProperty },
+	 { "kABRealProperty", kABRealProperty },
+	 { "kABDateProperty", kABDateProperty },
+	 { "kABArrayProperty", kABArrayProperty },
+	 { "kABDictionaryProperty", kABDictionaryProperty },
+	 { "kABDataProperty", kABDataProperty },
+	 { "kABMultiStringProperty", kABMultiStringProperty },
+	 { "kABMultiIntegerProperty", kABMultiIntegerProperty },
+	 { "kABMultiRealProperty", kABMultiRealProperty },
+	 { "kABMultiDateProperty", kABMultiDateProperty },
+	 { "kABMultiArrayProperty", kABMultiArrayProperty },
+	 { "kABMultiDictionaryProperty", kABMultiDictionaryProperty },
+	 { "kABMultiDataProperty", kABMultiDataProperty },
+	 { "kABEqual", kABEqual },
+	 { "kABNotEqual", kABNotEqual },
+	 { "kABLessThan", kABLessThan },
+	 { "kABLessThanOrEqual", kABLessThanOrEqual },
+	 { "kABGreaterThan", kABGreaterThan },
+	 { "kABGreaterThanOrEqual", kABGreaterThanOrEqual },
+	 { "kABEqualCaseInsensitive", kABEqualCaseInsensitive },
+	 { "kABContainsSubString", kABContainsSubString },
+	 { "kABContainsSubStringCaseInsensitive", kABContainsSubStringCaseInsensitive },
+	 { "kABPrefixMatch", kABPrefixMatch },
+	 { "kABPrefixMatchCaseInsensitive", kABPrefixMatchCaseInsensitive },
+	 { "kABSearchAnd", kABSearchAnd },
+	 { "kABSearchOr", kABSearchOr },
+
+	/* From: AddressBook.h */
+	{0, 0} /* Sentinel */
+};

File Modules/Cocoa/_Addr_Str.inc

View file
+/*
+ * String constants. This file is generated from files in
+ * /System/Library/Frameworks/AddressBook.framework/Headers
+ */
+static struct stringtable string_table[] = {
+
+	/* From: ABAddressBook.h */
+
+	/* From: ABAddressBookC.h */
+
+	/* From: ABGlobals.h */
+	 { "kABUIDProperty", &kABUIDProperty },
+	 { "kABCreationDateProperty", &kABCreationDateProperty },
+	 { "kABModificationDateProperty", &kABModificationDateProperty },
+	 { "kABFirstNameProperty", &kABFirstNameProperty },
+	 { "kABLastNameProperty", &kABLastNameProperty },
+	 { "kABFirstNamePhoneticProperty", &kABFirstNamePhoneticProperty },
+	 { "kABLastNamePhoneticProperty", &kABLastNamePhoneticProperty },
+	 { "kABBirthdayProperty", &kABBirthdayProperty },
+	 { "kABOrganizationProperty", &kABOrganizationProperty },
+	 { "kABJobTitleProperty", &kABJobTitleProperty },
+	 { "kABHomePageProperty", &kABHomePageProperty },
+	 { "kABEmailProperty", &kABEmailProperty },
+	 { "kABEmailWorkLabel", &kABEmailWorkLabel },
+	 { "kABEmailHomeLabel", &kABEmailHomeLabel },
+	 { "kABAddressProperty", &kABAddressProperty },
+	 { "kABAddressStreetKey", &kABAddressStreetKey },
+	 { "kABAddressCityKey", &kABAddressCityKey },
+	 { "kABAddressStateKey", &kABAddressStateKey },
+	 { "kABAddressZIPKey", &kABAddressZIPKey },
+	 { "kABAddressCountryKey", &kABAddressCountryKey },
+	 { "kABAddressCountryCodeKey", &kABAddressCountryCodeKey },
+	 { "kABAddressHomeLabel", &kABAddressHomeLabel },
+	 { "kABAddressWorkLabel", &kABAddressWorkLabel },
+	 { "kABPhoneProperty", &kABPhoneProperty },
+	 { "kABPhoneWorkLabel", &kABPhoneWorkLabel },
+	 { "kABPhoneHomeLabel", &kABPhoneHomeLabel },
+	 { "kABPhoneMobileLabel", &kABPhoneMobileLabel },
+	 { "kABPhoneMainLabel", &kABPhoneMainLabel },
+	 { "kABPhoneHomeFAXLabel", &kABPhoneHomeFAXLabel },
+	 { "kABPhoneWorkFAXLabel", &kABPhoneWorkFAXLabel },
+	 { "kABPhonePagerLabel", &kABPhonePagerLabel },
+	 { "kABAIMInstantProperty", &kABAIMInstantProperty },
+	 { "kABAIMWorkLabel", &kABAIMWorkLabel },
+	 { "kABAIMHomeLabel", &kABAIMHomeLabel },
+	 { "kABJabberInstantProperty", &kABJabberInstantProperty },
+	 { "kABJabberWorkLabel", &kABJabberWorkLabel },
+	 { "kABJabberHomeLabel", &kABJabberHomeLabel },
+	 { "kABMSNInstantProperty", &kABMSNInstantProperty },
+	 { "kABMSNWorkLabel", &kABMSNWorkLabel },
+	 { "kABMSNHomeLabel", &kABMSNHomeLabel },
+	 { "kABYahooInstantProperty", &kABYahooInstantProperty },
+	 { "kABYahooWorkLabel", &kABYahooWorkLabel },
+	 { "kABYahooHomeLabel", &kABYahooHomeLabel },
+	 { "kABICQInstantProperty", &kABICQInstantProperty },
+	 { "kABICQWorkLabel", &kABICQWorkLabel },
+	 { "kABICQHomeLabel", &kABICQHomeLabel },
+	 { "kABNoteProperty", &kABNoteProperty },
+	 { "kABMiddleNameProperty", &kABMiddleNameProperty },
+	 { "kABMiddleNamePhoneticProperty", &kABMiddleNamePhoneticProperty },
+	 { "kABTitleProperty", &kABTitleProperty },
+	 { "kABSuffixProperty", &kABSuffixProperty },
+	 { "kABNicknameProperty", &kABNicknameProperty },
+	 { "kABMaidenNameProperty", &kABMaidenNameProperty },
+	 { "kABGroupNameProperty", &kABGroupNameProperty },
+	 { "kABWorkLabel", &kABWorkLabel },
+	 { "kABHomeLabel", &kABHomeLabel },
+	 { "kABOtherLabel", &kABOtherLabel },
+	 { "kABDatabaseChangedNotification", &kABDatabaseChangedNotification },
+	 { "kABDatabaseChangedExternallyNotification", &kABDatabaseChangedExternallyNotification },
+
+	/* From: ABGlobalsC.h */
+
+	/* From: ABGroup.h */
+
+	/* From: ABImageLoading.h */
+
+	/* From: ABMultiValue.h */
+
+	/* From: ABPerson.h */
+
+	/* From: ABRecord.h */
+
+	/* From: ABSearchElement.h */
+
+	/* From: ABTypedefs.h */
+
+	/* From: AddressBook.h */
+	{0, 0} /* Sentinel */
+};

File Modules/Cocoa/_Addr_Var.inc

View file
+/*
+ * Various constants. This file is generated from files in
+ * /System/Library/Frameworks/AddressBook.framework/Headers
+ * 
+ * #Include this into the module init function
+ */
+
+	/* From: ABAddressBook.h */
+
+	/* From: ABAddressBookC.h */
+
+	/* From: ABGlobals.h */
+
+	/* From: ABGlobalsC.h */
+	if (add_CFStringRef(d, "kABUIDProperty", kABUIDProperty) < 0) return;
+	if (add_CFStringRef(d, "kABCreationDateProperty", kABCreationDateProperty) < 0) return;
+	if (add_CFStringRef(d, "kABModificationDateProperty", kABModificationDateProperty) < 0) return;
+	if (add_CFStringRef(d, "kABFirstNameProperty", kABFirstNameProperty) < 0) return;
+	if (add_CFStringRef(d, "kABLastNameProperty", kABLastNameProperty) < 0) return;
+	if (add_CFStringRef(d, "kABFirstNamePhoneticProperty", kABFirstNamePhoneticProperty) < 0) return;
+	if (add_CFStringRef(d, "kABLastNamePhoneticProperty", kABLastNamePhoneticProperty) < 0) return;
+	if (add_CFStringRef(d, "kABBirthdayProperty", kABBirthdayProperty) < 0) return;
+	if (add_CFStringRef(d, "kABOrganizationProperty", kABOrganizationProperty) < 0) return;
+	if (add_CFStringRef(d, "kABJobTitleProperty", kABJobTitleProperty) < 0) return;
+	if (add_CFStringRef(d, "kABHomePageProperty", kABHomePageProperty) < 0) return;
+	if (add_CFStringRef(d, "kABEmailProperty", kABEmailProperty) < 0) return;
+	if (add_CFStringRef(d, "kABEmailWorkLabel", kABEmailWorkLabel) < 0) return;
+	if (add_CFStringRef(d, "kABEmailHomeLabel", kABEmailHomeLabel) < 0) return;
+	if (add_CFStringRef(d, "kABAddressProperty", kABAddressProperty) < 0) return;
+	if (add_CFStringRef(d, "kABAddressStreetKey", kABAddressStreetKey) < 0) return;
+	if (add_CFStringRef(d, "kABAddressCityKey", kABAddressCityKey) < 0) return;
+	if (add_CFStringRef(d, "kABAddressStateKey", kABAddressStateKey) < 0) return;
+	if (add_CFStringRef(d, "kABAddressZIPKey", kABAddressZIPKey) < 0) return;
+	if (add_CFStringRef(d, "kABAddressCountryKey", kABAddressCountryKey) < 0) return;
+	if (add_CFStringRef(d, "kABAddressCountryCodeKey", kABAddressCountryCodeKey) < 0) return;
+	if (add_CFStringRef(d, "kABAddressHomeLabel", kABAddressHomeLabel) < 0) return;
+	if (add_CFStringRef(d, "kABAddressWorkLabel", kABAddressWorkLabel) < 0) return;
+	if (add_CFStringRef(d, "kABPhoneProperty", kABPhoneProperty) < 0) return;
+	if (add_CFStringRef(d, "kABPhoneWorkLabel", kABPhoneWorkLabel) < 0) return;
+	if (add_CFStringRef(d, "kABPhoneHomeLabel", kABPhoneHomeLabel) < 0) return;
+	if (add_CFStringRef(d, "kABPhoneMobileLabel", kABPhoneMobileLabel) < 0) return;
+	if (add_CFStringRef(d, "kABPhoneMainLabel", kABPhoneMainLabel) < 0) return;
+	if (add_CFStringRef(d, "kABPhoneHomeFAXLabel", kABPhoneHomeFAXLabel) < 0) return;
+	if (add_CFStringRef(d, "kABPhoneWorkFAXLabel", kABPhoneWorkFAXLabel) < 0) return;
+	if (add_CFStringRef(d, "kABPhonePagerLabel", kABPhonePagerLabel) < 0) return;
+	if (add_CFStringRef(d, "kABAIMInstantProperty", kABAIMInstantProperty) < 0) return;
+	if (add_CFStringRef(d, "kABAIMWorkLabel", kABAIMWorkLabel) < 0) return;
+	if (add_CFStringRef(d, "kABAIMHomeLabel", kABAIMHomeLabel) < 0) return;
+	if (add_CFStringRef(d, "kABJabberInstantProperty", kABJabberInstantProperty) < 0) return;
+	if (add_CFStringRef(d, "kABJabberWorkLabel", kABJabberWorkLabel) < 0) return;
+	if (add_CFStringRef(d, "kABJabberHomeLabel", kABJabberHomeLabel) < 0) return;
+	if (add_CFStringRef(d, "kABMSNInstantProperty", kABMSNInstantProperty) < 0) return;
+	if (add_CFStringRef(d, "kABMSNWorkLabel", kABMSNWorkLabel) < 0) return;
+	if (add_CFStringRef(d, "kABMSNHomeLabel", kABMSNHomeLabel) < 0) return;
+	if (add_CFStringRef(d, "kABYahooInstantProperty", kABYahooInstantProperty) < 0) return;
+	if (add_CFStringRef(d, "kABYahooWorkLabel", kABYahooWorkLabel) < 0) return;
+	if (add_CFStringRef(d, "kABYahooHomeLabel", kABYahooHomeLabel) < 0) return;
+	if (add_CFStringRef(d, "kABICQInstantProperty", kABICQInstantProperty) < 0) return;
+	if (add_CFStringRef(d, "kABICQWorkLabel", kABICQWorkLabel) < 0) return;
+	if (add_CFStringRef(d, "kABICQHomeLabel", kABICQHomeLabel) < 0) return;
+	if (add_CFStringRef(d, "kABNoteProperty", kABNoteProperty) < 0) return;
+	if (add_CFStringRef(d, "kABMiddleNameProperty", kABMiddleNameProperty) < 0) return;
+	if (add_CFStringRef(d, "kABMiddleNamePhoneticProperty", kABMiddleNamePhoneticProperty) < 0) return;
+	if (add_CFStringRef(d, "kABTitleProperty", kABTitleProperty) < 0) return;
+	if (add_CFStringRef(d, "kABSuffixProperty", kABSuffixProperty) < 0) return;
+	if (add_CFStringRef(d, "kABNicknameProperty", kABNicknameProperty) < 0) return;
+	if (add_CFStringRef(d, "kABMaidenNameProperty", kABMaidenNameProperty) < 0) return;
+	if (add_CFStringRef(d, "kABGroupNameProperty", kABGroupNameProperty) < 0) return;
+	if (add_CFStringRef(d, "kABWorkLabel", kABWorkLabel) < 0) return;
+	if (add_CFStringRef(d, "kABHomeLabel", kABHomeLabel) < 0) return;
+	if (add_CFStringRef(d, "kABOtherLabel", kABOtherLabel) < 0) return;
+	if (add_CFStringRef(d, "kABPersonRecordType", kABPersonRecordType) < 0) return;
+	if (add_CFStringRef(d, "kABGroupRecordType", kABGroupRecordType) < 0) return;
+	if (add_CFStringRef(d, "kABDatabaseChangedNotification", kABDatabaseChangedNotification) < 0) return;
+	if (add_CFStringRef(d, "kABDatabaseChangedExternallyNotification", kABDatabaseChangedExternallyNotification) < 0) return;
+
+	/* From: ABGroup.h */
+
+	/* From: ABImageLoading.h */
+
+	/* From: ABMultiValue.h */
+
+	/* From: ABPerson.h */
+
+	/* From: ABRecord.h */
+
+	/* From: ABSearchElement.h */
+
+	/* From: ABTypedefs.h */
+
+	/* From: AddressBook.h */

File Modules/Cocoa/_AddressBook.m

View file
+/*
+ * Mapping of static items in the AddressBook framework
+ * 
+ * - constants 
+ * - enumerations
+ */
+#include <Python.h>
+
+#import <AddressBook/AddressBook.h>
+
+#include "pyobjc-api.h"
+#include "objc_support.h"
+#include "OC_PythonObject.h"
+#include "const-table.h"
+
+static PyMethodDef addressbook_methods[] = {
+	{ 0, 0, 0, 0 }
+};
+
+
+PyDoc_STRVAR(addressbook_doc,
+"Cocoa._AddressBook defines constants, types and global functions used by "
+"Cocoa.AddressBook."
+);
+
+
+#include "_Addr_Enum.inc"
+#include "_Addr_Str.inc"
+
+void init_AddressBook(void)
+{
+	PyObject *m, *d;
+
+	m = Py_InitModule4("_AddressBook", addressbook_methods, 
+		addressbook_doc, NULL, PYTHON_API_VERSION);
+	if (!m) return;
+
+	d = PyModule_GetDict(m);
+	if (!d) return;
+
+	if (ObjC_ImportModule(m) < 0) {
+		return;
+	}
+
+	if (register_ints(d, enum_table) < 0) return;
+	if (register_strings(d, string_table) < 0) return;
+}

File Modules/Cocoa/_App_Functions.inc

View file
  * This is a generated file.
  */
 
+typedef void* PYOBJC_VOIDPTR;
+
 static inline int convert_BOOL(PyObject* object, void* pvar)
 {
     BOOL* pbool = (BOOL*)pvar;
 	id objc_modalDelegate;
 	SEL objc_didEndSelector;
 	SEL objc_didDismissSelector;
-	int objc_contextInfo;
+	PYOBJC_VOIDPTR objc_contextInfo;
 	id objc_msg;
 
 	if (PyArg_ParseTupleAndKeywords(args, kwds, "O&O&O&O&O&O&O&O&iO&:NSBeginAlertSheet", keywords, convert_id, &objc_title, convert_id, &objc_defaultButton, convert_id, &objc_alternateButton, convert_id, &objc_otherButton, convert_id, &objc_docWindow, convert_id, &objc_modalDelegate, convert_SEL, &objc_didEndSelector, convert_SEL, &objc_didDismissSelector, &objc_contextInfo, convert_id, &objc_msg) < 0) return NULL;
 	id objc_modalDelegate;
 	SEL objc_didEndSelector;
 	SEL objc_didDismissSelector;
-	int objc_contextInfo;
+	PYOBJC_VOIDPTR objc_contextInfo;
 	id objc_msg;
 
 	if (PyArg_ParseTupleAndKeywords(args, kwds, "O&O&O&O&O&O&O&O&iO&:NSBeginInformationalAlertSheet", keywords, convert_id, &objc_title, convert_id, &objc_defaultButton, convert_id, &objc_alternateButton, convert_id, &objc_otherButton, convert_id, &objc_docWindow, convert_id, &objc_modalDelegate, convert_SEL, &objc_didEndSelector, convert_SEL, &objc_didDismissSelector, &objc_contextInfo, convert_id, &objc_msg) < 0) return NULL;
 	id objc_modalDelegate;
 	SEL objc_didEndSelector;
 	SEL objc_didDismissSelector;
-	int objc_contextInfo;
+	PYOBJC_VOIDPTR objc_contextInfo;
 	id objc_msg;
 
 	if (PyArg_ParseTupleAndKeywords(args, kwds, "O&O&O&O&O&O&O&O&iO&:NSBeginCriticalAlertSheet", keywords, convert_id, &objc_title, convert_id, &objc_defaultButton, convert_id, &objc_alternateButton, convert_id, &objc_otherButton, convert_id, &objc_docWindow, convert_id, &objc_modalDelegate, convert_SEL, &objc_didEndSelector, convert_SEL, &objc_didDismissSelector, &objc_contextInfo, convert_id, &objc_msg) < 0) return NULL;

File Modules/Cocoa/_Fnd_Functions.inc

View file
  * This is a generated file.
  */
 
+typedef void* PYOBJC_VOIDPTR;
+
 static inline int convert_BOOL(PyObject* object, void* pvar)
 {
     BOOL* pbool = (BOOL*)pvar;

File Modules/Cocoa/scripts/cocoa_generator.py

View file
 FRAMEWORKS="/System/Library/Frameworks"
 FOUNDATION=os.path.join(FRAMEWORKS, "Foundation.framework")
 APPKIT=os.path.join(FRAMEWORKS, "AppKit.framework")
+ADDRESSBOOK=os.path.join(FRAMEWORKS, "AddressBook.framework")
 FOUNDATION_HDRS=os.path.join(FOUNDATION, 'Headers')
 APPKIT_HDRS=os.path.join(APPKIT, 'Headers')
+ADDRESSBOOK_HDRS=os.path.join(ADDRESSBOOK, 'Headers')
 
 enum_generator.generate(FOUNDATION_HDRS, '_Fnd_Enum.inc')
 enum_generator.generate(APPKIT_HDRS, '_App_Enum.inc')
+enum_generator.generate(ADDRESSBOOK_HDRS, '_Addr_Enum.inc')
 
 strconst_generator.generate(FOUNDATION_HDRS, '_Fnd_Str.inc')
 strconst_generator.generate(APPKIT_HDRS, '_App_Str.inc')
+strconst_generator.generate(ADDRESSBOOK_HDRS, '_Addr_Str.inc')
 
 FOUNDATION_PREFIX="FOUNDATION_EXPORT"
 FOUNDATION_IGNORE_LIST=(
     new_args = []
     for tp, name in args:
         if name == 'contextInfo':
-            tp = 'int'
+            tp = 'PYOBJC_VOIDPTR'
         new_args.append((tp, name))
     return tuple(new_args)
 func_builder.FUNC_MAP['NSBeginAlertSheet'] = BeginSheetMapper

File Modules/Cocoa/scripts/func_builder.py

View file
  * This is a generated file.
  */
 
+typedef void* PYOBJC_VOIDPTR;
+
 static inline int convert_BOOL(PyObject* object, void* pvar)
 {
     BOOL* pbool = (BOOL*)pvar;
 		'&%(varname)s',
 		None
 	),
+	'PYOBJC_VOIDPTR': (
+		"\tresult = PyInt_FromLong(%(varname)s);\n\tif (result == NULL) return NULL;",
+		'i',
+		'&%(varname)s',
+		None
+	),
 	'BOOL': (
 		"\tresult = PyBool_FromLong(%(varname)s);\n\tif (result == NULL) return NULL;",
 		'O&', 		

File setup.py

View file
         '-framework', 'AppKit'
         ]
 
+    ADDRESSBOOK_LDFLAGS=[
+        '-framework', 'AddressBook', '-framework', 'Foundation'
+    ]
+
 else:
     #
     # GNUstep
         '-l', 'objc'
         ]
 
+    ADDRESSBOOK_LDFLAGS=[]
 
 def IfFrameWork(name, packages, extensions):
     """
 # The AdressBook module is only installed when the user actually has the
 # AddressBook framework.
 AddressBookPackages, AddressBookExtensions = \
-        IfFrameWork('AddressBook.framework', [ 'AddressBook' ], [])
+        IfFrameWork('AddressBook.framework', [ 'AddressBook' ], [
+            Extension('AddressBook._AddressBook',
+                      [ 'Modules/Cocoa/_AddressBook.m' ],
+                      extra_compile_args=[
+                        '-IModules/objc',
+                      ] + CFLAGS,
+                      extra_link_args=[
+                      ] + ADDRESSBOOK_LDFLAGS),
+        ])
 
 
 def package_version():