[CalendarServer-changes] [15204] OSXFrameworks/trunk

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 21 13:02:01 PDT 2015


Revision: 15204
          http://trac.calendarserver.org//changeset/15204
Author:   cdaboo at apple.com
Date:     2015-10-21 13:02:01 -0700 (Wed, 21 Oct 2015)
Log Message:
-----------
Initial commit.

Added Paths:
-----------
    OSXFrameworks/trunk/LICENSE
    OSXFrameworks/trunk/README
    OSXFrameworks/trunk/osx/
    OSXFrameworks/trunk/osx/__init__.py
    OSXFrameworks/trunk/osx/_corefoundation_cffi_build.py
    OSXFrameworks/trunk/osx/corefoundation.py
    OSXFrameworks/trunk/osx/frameworks/
    OSXFrameworks/trunk/osx/frameworks/__init__.py
    OSXFrameworks/trunk/osx/frameworks/_corefoundation_cffi.py
    OSXFrameworks/trunk/osx/frameworks/_opendirectory_cffi.py
    OSXFrameworks/trunk/osx/frameworks/_security_cffi.py
    OSXFrameworks/trunk/osx/frameworks/_utils_cffi.py
    OSXFrameworks/trunk/osx/opendirectory.py
    OSXFrameworks/trunk/osx/test/
    OSXFrameworks/trunk/osx/test/__init__.py
    OSXFrameworks/trunk/osx/test/data/
    OSXFrameworks/trunk/osx/test/data/binary_fmt.plist
    OSXFrameworks/trunk/osx/test/data/xml_fmt.plist
    OSXFrameworks/trunk/osx/test/test_cfarray.py
    OSXFrameworks/trunk/osx/test/test_cfdata.py
    OSXFrameworks/trunk/osx/test/test_cfdictionary.py
    OSXFrameworks/trunk/osx/test/test_cflocale.py
    OSXFrameworks/trunk/osx/test/test_cfpropertylist.py
    OSXFrameworks/trunk/osx/test/test_cfstring.py
    OSXFrameworks/trunk/osx/test/test_cftimezone.py
    OSXFrameworks/trunk/osx/test/test_opendirectory.py
    OSXFrameworks/trunk/osx/utils.py
    OSXFrameworks/trunk/setup.py

Added: OSXFrameworks/trunk/LICENSE
===================================================================
--- OSXFrameworks/trunk/LICENSE	                        (rev 0)
+++ OSXFrameworks/trunk/LICENSE	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

Added: OSXFrameworks/trunk/README
===================================================================
--- OSXFrameworks/trunk/README	                        (rev 0)
+++ OSXFrameworks/trunk/README	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,16 @@
+Getting Started
+===============
+
+This is a python library that wraps a number of useful OS X frameworks.
+
+
+Copyright and License
+=====================
+
+Copyright (c) 2015 Apple Inc.  All rights reserved.
+
+This software is licensed under the Apache License, Version 2.0.  The
+Apache License is a well-established open source license, enabling
+collaborative open source software development.
+
+See the "LICENSE" file for the full text of the license terms.

Added: OSXFrameworks/trunk/osx/__init__.py
===================================================================
--- OSXFrameworks/trunk/osx/__init__.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/__init__.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,15 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##

Added: OSXFrameworks/trunk/osx/_corefoundation_cffi_build.py
===================================================================
--- OSXFrameworks/trunk/osx/_corefoundation_cffi_build.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/_corefoundation_cffi_build.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,54 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+
+from cffi import FFI
+from importlib import import_module
+
+# Load cffi declaration modules
+modules = [import_module(".frameworks.{}".format(module), "osx") for module in (
+    "_corefoundation_cffi",
+    "_opendirectory_cffi",
+    "_security_cffi",
+    "_utils_cffi",
+)]
+
+# Build list of includes and extra link arguments from each module
+includes = "".join([m.INCLUDES for m in modules])
+extra_links = []
+for m in modules:
+    extra_links.extend(m.EXTRA_LINKS)
+
+# Build cffi - all modules go into one python extension module
+ffi = FFI()
+ffi.set_source(
+    "_corefoundation",
+    includes,
+    extra_link_args=extra_links,
+)
+
+# Add each module's details
+for m in modules:
+    ffi.cdef(m.TYPES + m.CONSTANTS + m.FUNCTIONS)
+
+
+
+def main():
+    ffi.compile()
+
+
+if __name__ == "__main__":
+    main()

Added: OSXFrameworks/trunk/osx/corefoundation.py
===================================================================
--- OSXFrameworks/trunk/osx/corefoundation.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/corefoundation.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,411 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+"""
+A set of Python classes that wrap common CoreFoundation classes.
+"""
+
+from ._corefoundation import ffi, lib as cf
+
+
+class CFError(Exception):
+    """
+    Generic CoreFoundation error occurred
+    """
+
+
+
+class CFObjectRef(object):
+    """
+    This is a wrapper for any CF objects returned from CFFI calls. For CF
+    objects whose ownership is implicitly retained (CoreFoundation Create Rule),
+    this class by default will CFRelease them. For an unowned object
+    (CoreFoundation Get Rule), the L{owned} parameter must be set to False,
+    which will cause the CF object to be explicitly CFRetain'd (and then
+    automatically released).
+    """
+
+    def __init__(self, cfobj, owned=True):
+        """
+        Create a wrapper around the supplied cffi object that mirrors a CoreFoundation object.
+
+        NB we have to cache the L{lib} and L{ffi} objects here to prevent them from being
+        garbage collected before this object's __del__ is called.
+
+        @param cfobj: the cffi object to wrap
+        @type cfobj: L{ffi.CData}
+        @param owned: whether the object is already retained
+        @type owned: L{bool}
+        """
+        self.cf = cf
+        self.ffi = ffi
+        self.cfobj = cfobj if cfobj is not None else ffi.NULL
+        if not owned and cfobj is not None:
+            cf.CFRetain(self.cfobj)
+
+
+    @classmethod
+    def fromRef(cls, cfobj):
+        return cls(cfobj, False)
+
+
+    def __del__(self):
+        """
+        When this object is garbage collected, also release the CoreFoundation object, which we
+        know is retained by us.
+        """
+        if self.cfobj != self.ffi.NULL:
+            self.cf.CFRelease(self.cfobj)
+        self.cfobj = None
+        self.cf = None
+
+
+    def ref(self):
+        return self.cfobj
+
+
+    def retainCount(self):
+        return cf.CFGetRetainCount(self.ref())
+
+
+    def instanceTypeId(self):
+        return cf.CFGetTypeID(self.ref())
+
+
+    def description(self):
+        description = CFStringRef(cf.CFCopyDescription(self.ref()))
+        return description.toString()
+
+
+    def native(self):
+        """
+        Convert this object, if possible, into a native Python type. If it cannot be
+        converted, just return it as is.
+        """
+        if self.instanceTypeId() == CFStringRef.typeId():
+            item = CFStringRef(self.ref(), owned=False)
+            result = item.native()
+        elif self.instanceTypeId() == CFArrayRef.typeId():
+            item = CFArrayRef(self.ref(), owned=False)
+            result = item.native()
+        elif self.instanceTypeId() == CFDictionaryRef.typeId():
+            item = CFDictionaryRef(self.ref(), owned=False)
+            result = item.native()
+        else:
+            result = self
+
+        return result
+
+
+
+class CFErrorRef(CFObjectRef):
+    """
+    A wrapper for CFErrorRef CoreFoundation objects.
+    """
+
+    @staticmethod
+    def typeId():
+        return cf.CFErrorGetTypeID()
+
+
+    def error(self):
+        """
+        Return the error description.
+
+        @return: error description
+        @rtype: L{str}
+        """
+        desc = CFStringRef(cf)
+        return desc.toString()
+
+
+
+class CFBooleanRef(CFObjectRef):
+    """
+    A wrapper for CFBooleanRef CoreFoundation objects.
+    """
+
+    @staticmethod
+    def typeId():
+        return cf.CFBooleanGetTypeID()
+
+
+    @classmethod
+    def fromBool(cls, value):
+        return cls.fromRef(cf.kCFBooleanTrue if value else cf.kCFBooleanFalse)
+
+
+
+class CFStringRef(CFObjectRef):
+    """
+    A wrapper for CFStringRef CoreFoundation objects.
+    """
+
+    @staticmethod
+    def typeId():
+        return cf.CFStringGetTypeID()
+
+
+    @classmethod
+    def fromString(cls, text):
+        """
+        Create a cffi/CFStringRef from a Python L{str} - assume UTF-8 encoding.
+
+        @param text: utf-8 encoded string
+        @type text: L{str}
+
+        @return: the cffi data
+        @rtype: L{ffi.CData}
+        """
+        if isinstance(text, unicode):
+            text = text.encode("utf-8")
+        cfstringref = cf.CFStringCreateWithCString(ffi.NULL, text, cf.kCFStringEncodingUTF8)
+        if cfstringref == ffi.NULL:
+            raise CFError("Unable to create a CFStringRef")
+        return CFStringRef(cfstringref)
+
+
+    def toString(self):
+        return self.native()
+
+
+    def __str__(self):
+        return self.native()
+
+
+    def native(self):
+        """
+        Convert the cffi/CFStringRef value to a utf-8 encoded Python string.
+
+        @return: the string value
+        @rtype: L{str}
+        """
+        # Try quick conversion first, then try longer one
+        str = cf.CFStringGetCStringPtr(self.ref(), cf.kCFStringEncodingUTF8)
+        if str == ffi.NULL:
+            range = cf.CFStringGetLength(self.ref())
+            actualSize = ffi.new("CFIndex *")
+            cf.CFStringGetBytes(self.ref(), [0, range], cf.kCFStringEncodingUTF8, ord("?"), False, ffi.NULL, 0, actualSize)
+            actualSize = actualSize[0]
+            str = ffi.new("char []", actualSize + 1)
+            cf.CFStringGetCString(self.ref(), str, actualSize + 1, cf.kCFStringEncodingUTF8)
+        return ffi.string(str) if str else ""
+
+
+    def copy(self):
+        return CFStringRef(cf.CFStringCreateCopy(ffi.NULL, self.ref()))
+
+
+
+class CFDataRef(CFObjectRef):
+    """
+    A wrapper for CFDataRef CoreFoundation objects.
+    """
+
+    @staticmethod
+    def typeId():
+        return cf.CFDataGetTypeID()
+
+
+    @classmethod
+    def fromString(cls, text):
+        """
+        Convert a L{str} to a cffi/CFDataRef.
+
+        @param text: string to convert
+        @type text: L{str}
+
+        @return: the  value
+        @rtype: L{CFDataRef}
+        """
+        cfdataref = cf.CFDataCreate(ffi.NULL, text, len(text))
+        if cfdataref == ffi.NULL:
+            raise CFError("Unable to create a CFDataRef")
+        return CFDataRef(cfdataref)
+
+
+    def toString(self):
+        return self.native()
+
+
+    def count(self):
+        """
+        The number of items in the wrapped CFArrayRef.
+
+        @return: the count
+        @rtype: L{int}
+        """
+        return cf.CFDataGetLength(self.ref())
+
+
+    def native(self):
+        """
+        Convert the cffi/CFDataRef value to a Python string.
+
+        @return: the string value
+        @rtype: L{str}
+        """
+        count = self.count()
+        value = ffi.new("UInt8 []", count)
+        cf.CFDataGetBytes(self.ref(), [0, count], value)
+        return bytes(ffi.buffer(value, count))
+
+
+
+class CFArrayRef(CFObjectRef):
+    """
+    A wrapper for CFArrayRef CoreFoundation objects.
+    """
+
+    @staticmethod
+    def typeId():
+        return cf.CFArrayGetTypeID()
+
+
+    @classmethod
+    def fromList(cls, l):
+        """
+        Create a cffi/CFArrayRef from a Python L{list} of L{CFObjectRef}.
+
+        @param l: list to convert
+        @type l: L{list}
+
+        @return: the cffi data
+        @rtype: L{CFArrayRef}
+        """
+        lr = [item.ref() for item in l]
+        cfarrayref = cf.CFArrayCreate(ffi.NULL, lr, len(l), ffi.addressof(cf.kCFTypeArrayCallBacks))
+        if cfarrayref == ffi.NULL:
+            raise CFError("Unable to create a CFArrayRef")
+        return CFArrayRef(cfarrayref)
+
+
+    def toList(self):
+        return self.native()
+
+
+    def count(self):
+        """
+        The number of items in the wrapped CFArrayRef.
+
+        @return: the count
+        @rtype: L{int}
+        """
+        return cf.CFArrayGetCount(self.ref())
+
+
+    def valueAtIndex(self, index):
+        """
+        Return an item from the CFArrayRef, converted to native type.
+
+        @param index: index of item to return
+        @type index: L{int}
+
+        @return: the cffi data
+        @rtype: L{CFObjectRef}, L{str}, L{list} or L{dict}
+        """
+        result = cf.CFArrayGetValueAtIndex(self.ref(), index)
+        if result != ffi.NULL:
+            result = CFObjectRef(result, owned=False)
+            return result.native()
+        else:
+            return None
+
+
+    def native(self):
+        """
+        Convert a CFArrayRef into an L{list} of native items.
+
+        @return: list of native items
+        @rtype: L{list}
+        """
+        count = self.count()
+        values = ffi.new("const void * []", count)
+        cf.CFArrayGetValues(self.ref(), [0, count], values)
+        items = [CFObjectRef(item, owned=False) for item in values]
+        return [item.native() for item in items]
+
+
+
+class CFDictionaryRef(CFObjectRef):
+    """
+    A wrapper for CFDictionaryRef CoreFoundation objects.
+    """
+
+    @staticmethod
+    def typeId():
+        return cf.CFDictionaryGetTypeID()
+
+
+    @classmethod
+    def fromDict(cls, d):
+        """
+        Create a cffi/CFDictionaryRef from a Python L{dict} of L{CFObjectRef}.
+
+        @param d: dict to convert
+        @type d: L{dict}
+
+        @return: the cffi data
+        @rtype: L{CFDictionaryRef}
+        """
+        keys = []
+        values = []
+        for k, v in d.items():
+            keys.append(k.ref())
+            values.append(v.ref())
+        cfdictref = cf.CFDictionaryCreate(
+            ffi.NULL, keys, values, len(keys),
+            ffi.addressof(cf.kCFTypeDictionaryKeyCallBacks),
+            ffi.addressof(cf.kCFTypeDictionaryValueCallBacks),
+        )
+        if cfdictref == ffi.NULL:
+            raise CFError("Unable to create a CFDictionaryRef")
+        return CFDictionaryRef(cfdictref)
+
+
+    def toDict(self):
+        return self.native()
+
+
+    def count(self):
+        """
+        The number of items in the wrapped CFDictionaryRef.
+
+        @return: the count
+        @rtype: L{int}
+        """
+        return cf.CFDictionaryGetCount(self.ref())
+
+
+    def native(self):
+        """
+        Convert the cffi/CFDictionaryRef value to a Python L{dict}. The keys and values
+        are all converted to their native values.
+
+        @return: the result
+        @rtype: L{dict}
+        """
+        count = self.count()
+        keys = ffi.new("const void * []", count)
+        values = ffi.new("const void * []", count)
+        cf.CFDictionaryGetKeysAndValues(self.ref(), keys, values)
+
+        result = {}
+        for key, value in zip(keys, values):
+            k = CFStringRef(key, owned=False)
+            v = CFObjectRef(value, owned=False)
+            result[k.native()] = v.native()
+        return result

Added: OSXFrameworks/trunk/osx/frameworks/__init__.py
===================================================================
--- OSXFrameworks/trunk/osx/frameworks/__init__.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/frameworks/__init__.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,22 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+all = [
+    "_corefoundation_cffi",
+    "_opendirectory_cffi",
+    "_security_cffi",
+    "_utils_cffi",
+]

Added: OSXFrameworks/trunk/osx/frameworks/_corefoundation_cffi.py
===================================================================
--- OSXFrameworks/trunk/osx/frameworks/_corefoundation_cffi.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/frameworks/_corefoundation_cffi.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,107 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+
+INCLUDES = """
+#include <CoreFoundation/CoreFoundation.h>
+"""
+
+EXTRA_LINKS = []
+
+TYPES = """
+typedef bool Boolean;
+typedef signed long OSStatus;
+typedef unsigned char UInt8;
+typedef uint32_t UInt32;
+
+typedef signed long CFIndex;
+typedef UInt32 CFOptionFlags;
+struct CFRange { CFIndex location; CFIndex length; };
+typedef struct CFRange CFRange;
+typedef UInt32 CFStringEncoding;
+typedef enum {
+    kCFStringEncodingUTF8 = 0x08000100, /* kTextEncodingUnicodeDefault + kUnicodeUTF8Format */
+};
+
+typedef unsigned long CFTypeID;
+typedef const void * CFTypeRef;
+typedef const struct __CFAllocator *CFAllocatorRef;
+typedef const struct __CFBoolean *CFBooleanRef;
+typedef const struct __CFString *CFStringRef;
+typedef const struct __CFData *CFDataRef;
+typedef const struct __CFArray *CFArrayRef;
+typedef const struct __CFDictionary *CFDictionaryRef;
+typedef struct __CFError * CFErrorRef;
+
+typedef struct {
+    ...;
+} CFArrayCallBacks;
+
+typedef struct {
+    ...;
+} CFDictionaryKeyCallBacks;
+typedef struct {
+    ...;
+} CFDictionaryValueCallBacks;
+"""
+
+CONSTANTS = """
+const CFBooleanRef kCFBooleanTrue;
+const CFBooleanRef kCFBooleanFalse;
+
+const CFArrayCallBacks kCFTypeArrayCallBacks;
+
+const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
+const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
+"""
+
+FUNCTIONS = """
+CFTypeRef CFRetain ( CFTypeRef cf );
+void CFRelease ( CFTypeRef cf );
+CFIndex CFGetRetainCount ( CFTypeRef cf );
+CFTypeID CFGetTypeID ( CFTypeRef cf );
+
+CFStringRef CFCopyDescription ( CFTypeRef cf );
+
+CFTypeID CFErrorGetTypeID ( void );
+
+CFTypeID CFBooleanGetTypeID ( void );
+Boolean CFBooleanGetValue( CFBooleanRef );
+
+CFTypeID CFStringGetTypeID ( void );
+CFStringRef CFStringCreateCopy ( CFAllocatorRef alloc, CFStringRef theString );
+CFStringRef CFStringCreateWithCString ( CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding );
+CFIndex CFStringGetBytes ( CFStringRef theString, CFRange range, CFStringEncoding encoding, UInt8 lossByte, Boolean isExternalRepresentation, UInt8 *buffer, CFIndex maxBufLen, CFIndex *usedBufLen );
+Boolean CFStringGetCString ( CFStringRef theString, char *buffer, CFIndex bufferSize, CFStringEncoding encoding );
+const char * CFStringGetCStringPtr ( CFStringRef theString, CFStringEncoding encoding );
+CFIndex CFStringGetLength ( CFStringRef theString );
+
+CFTypeID CFDataGetTypeID ( void );
+CFDataRef CFDataCreate ( CFAllocatorRef allocator, const UInt8 *bytes, CFIndex length );
+void CFDataGetBytes ( CFDataRef theData, CFRange range, UInt8 *buffer );
+CFIndex CFDataGetLength ( CFDataRef theData );
+
+CFTypeID CFArrayGetTypeID ( void );
+CFArrayRef CFArrayCreate ( CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks );
+CFIndex CFArrayGetCount ( CFArrayRef theArray );
+const void * CFArrayGetValueAtIndex ( CFArrayRef theArray, CFIndex idx );
+void CFArrayGetValues ( CFArrayRef theArray, CFRange range, const void **values );
+
+CFTypeID CFDictionaryGetTypeID ( void );
+CFDictionaryRef CFDictionaryCreate ( CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks );
+CFIndex CFDictionaryGetCount ( CFDictionaryRef theDict );
+void CFDictionaryGetKeysAndValues ( CFDictionaryRef theDict, const void **keys, const void **values );
+"""

Added: OSXFrameworks/trunk/osx/frameworks/_opendirectory_cffi.py
===================================================================
--- OSXFrameworks/trunk/osx/frameworks/_opendirectory_cffi.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/frameworks/_opendirectory_cffi.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,394 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+
+INCLUDES = """
+#include <OpenDirectory/OpenDirectory.h>
+"""
+
+EXTRA_LINKS = ["-framework", "OpenDirectory"]
+
+TYPES = """
+typedef struct __ODSession *ODSessionRef;
+typedef struct __ODNode *ODNodeRef;
+typedef struct __ODRecord *ODRecordRef;
+typedef struct __ODQuery *ODQueryRef;
+typedef uint32_t ODMatchType;
+typedef const struct __ODContext *ODContextRef;
+
+typedef CFStringRef ODRecordType;
+typedef CFStringRef ODAttributeType;
+typedef CFStringRef ODAuthenticationType;
+
+enum {
+   kODMatchAny = 0x0001,
+   kODMatchEqualTo = 0x2001,
+   kODMatchBeginsWith = 0x2002,
+   kODMatchEndsWith = 0x2003,
+   kODMatchContains = 0x2004,
+   kODMatchGreaterThan = 0x2006,
+   kODMatchLessThan = 0x2007
+   //kODMatchInsensitiveEqualTo = 0x2101,
+   //kODMatchInsensitiveBeginsWith = 0x2102,
+   //kODMatchInsensitiveEndsWith = 0x2103,
+   //kODMatchInsensitiveContains = 0x2104
+};
+
+"""
+
+CONSTANTS = """
+ODSessionRef kODSessionDefault;
+
+const ODRecordType kODRecordTypeAttributeTypes;
+const ODRecordType kODRecordTypeAFPServer;
+const ODRecordType kODRecordTypeAliases;
+const ODRecordType kODRecordTypeAugments;
+const ODRecordType kODRecordTypeAutomount;
+const ODRecordType kODRecordTypeAutomountMap;
+const ODRecordType kODRecordTypeAutoServerSetup;
+const ODRecordType kODRecordTypeBootp;
+const ODRecordType kODRecordTypeCertificateAuthorities;
+const ODRecordType kODRecordTypeComputerLists;
+const ODRecordType kODRecordTypeComputerGroups;
+const ODRecordType kODRecordTypeComputers;
+const ODRecordType kODRecordTypeConfiguration;
+const ODRecordType kODRecordTypeEthernets;
+const ODRecordType kODRecordTypeFileMakerServers;
+const ODRecordType kODRecordTypeFTPServer;
+const ODRecordType kODRecordTypeGroups;
+const ODRecordType kODRecordTypeHostServices;
+const ODRecordType kODRecordTypeHosts;
+const ODRecordType kODRecordTypeLDAPServer;
+const ODRecordType kODRecordTypeLocations;
+const ODRecordType kODRecordTypeMounts;
+const ODRecordType kODRecordTypeNFS;
+const ODRecordType kODRecordTypeNetDomains;
+const ODRecordType kODRecordTypeNetGroups;
+const ODRecordType kODRecordTypeNetworks;
+const ODRecordType kODRecordTypePeople;
+const ODRecordType kODRecordTypePresetComputers;
+const ODRecordType kODRecordTypePresetComputerGroups;
+const ODRecordType kODRecordTypePresetComputerLists;
+const ODRecordType kODRecordTypePresetGroups;
+const ODRecordType kODRecordTypePresetUsers;
+const ODRecordType kODRecordTypePrintService;
+const ODRecordType kODRecordTypePrintServiceUser;
+const ODRecordType kODRecordTypePrinters;
+const ODRecordType kODRecordTypeProtocols;
+const ODRecordType kODRecordTypeQTSServer;
+const ODRecordType kODRecordTypeQueryInformation;
+const ODRecordType kODRecordTypeRecordTypes;
+const ODRecordType kODRecordTypeResources;
+const ODRecordType kODRecordTypeRPC;
+const ODRecordType kODRecordTypeSMBServer;
+const ODRecordType kODRecordTypeServer;
+const ODRecordType kODRecordTypeServices;
+const ODRecordType kODRecordTypeSharePoints;
+const ODRecordType kODRecordTypeUsers;
+const ODRecordType kODRecordTypeWebServer;
+
+const ODAttributeType kODAttributeTypeAllAttributes;
+const ODAttributeType kODAttributeTypeStandardOnly;
+const ODAttributeType kODAttributeTypeNativeOnly;
+const ODAttributeType kODAttributeTypeMetaAmbiguousName;
+const ODAttributeType kODAttributeTypeMetaAugmentedAttributes;
+const ODAttributeType kODAttributeTypeMetaRecordName;
+const ODAttributeType kODAttributeTypeAdminLimits;
+const ODAttributeType kODAttributeTypeAltSecurityIdentities;
+const ODAttributeType kODAttributeTypeAuthenticationHint;
+const ODAttributeType kODAttributeTypeAllTypes;
+const ODAttributeType kODAttributeTypeAuthorityRevocationList;
+const ODAttributeType kODAttributeTypeBirthday;
+const ODAttributeType kODAttributeTypeCACertificate;
+const ODAttributeType kODAttributeTypeCapacity;
+const ODAttributeType kODAttributeTypeCertificateRevocationList;
+const ODAttributeType kODAttributeTypeComment;
+const ODAttributeType kODAttributeTypeContactGUID;
+const ODAttributeType kODAttributeTypeContactPerson;
+const ODAttributeType kODAttributeTypeCreationTimestamp;
+const ODAttributeType kODAttributeTypeCrossCertificatePair;
+const ODAttributeType kODAttributeTypeDataStamp;
+const ODAttributeType kODAttributeTypeFullName;
+const ODAttributeType kODAttributeTypeDNSDomain;
+const ODAttributeType kODAttributeTypeDNSNameServer;
+const ODAttributeType kODAttributeTypeENetAddress;
+const ODAttributeType kODAttributeTypeExpire;
+const ODAttributeType kODAttributeTypeFirstName;
+const ODAttributeType kODAttributeTypeGUID;
+const ODAttributeType kODAttributeTypeHardwareUUID;
+const ODAttributeType kODAttributeTypeHomeDirectoryQuota;
+const ODAttributeType kODAttributeTypeHomeDirectorySoftQuota;
+const ODAttributeType kODAttributeTypeHomeLocOwner;
+const ODAttributeType kODAttributeTypeInternetAlias;
+const ODAttributeType kODAttributeTypeKDCConfigData;
+const ODAttributeType kODAttributeTypeKerberosServices;
+const ODAttributeType kODAttributeTypeLastName;
+const ODAttributeType kODAttributeTypeLDAPSearchBaseSuffix;
+const ODAttributeType kODAttributeTypeLocation;
+const ODAttributeType kODAttributeTypeMapGUID;
+const ODAttributeType kODAttributeTypeMCXFlags;
+const ODAttributeType kODAttributeTypeMCXSettings;
+const ODAttributeType kODAttributeTypeMailAttribute;
+const ODAttributeType kODAttributeTypeMetaAutomountMap;
+const ODAttributeType kODAttributeTypeMiddleName;
+const ODAttributeType kODAttributeTypeModificationTimestamp;
+const ODAttributeType kODAttributeTypeNFSHomeDirectory;
+const ODAttributeType kODAttributeTypeNote;
+const ODAttributeType kODAttributeTypeOperatingSystem;
+const ODAttributeType kODAttributeTypeOperatingSystemVersion;
+const ODAttributeType kODAttributeTypeOwner;
+const ODAttributeType kODAttributeTypeOwnerGUID;
+const ODAttributeType kODAttributeTypePassword;
+const ODAttributeType kODAttributeTypePasswordPlus;
+const ODAttributeType kODAttributeTypePasswordPolicyOptions;
+const ODAttributeType kODAttributeTypePasswordServerList;
+const ODAttributeType kODAttributeTypePasswordServerLocation;
+const ODAttributeType kODAttributeTypePicture;
+const ODAttributeType kODAttributeTypePort;
+const ODAttributeType kODAttributeTypePresetUserIsAdmin;
+const ODAttributeType kODAttributeTypePrimaryComputerGUID;
+const ODAttributeType kODAttributeTypePrimaryComputerList;
+const ODAttributeType kODAttributeTypePrimaryGroupID;
+const ODAttributeType kODAttributeTypePrinter1284DeviceID;
+const ODAttributeType kODAttributeTypePrinterLPRHost;
+const ODAttributeType kODAttributeTypePrinterLPRQueue;
+const ODAttributeType kODAttributeTypePrinterMakeAndModel;
+const ODAttributeType kODAttributeTypePrinterType;
+const ODAttributeType kODAttributeTypePrinterURI;
+const ODAttributeType kODAttributeTypePrinterXRISupported;
+const ODAttributeType kODAttributeTypePrintServiceInfoText;
+const ODAttributeType kODAttributeTypePrintServiceInfoXML;
+const ODAttributeType kODAttributeTypePrintServiceUserData;
+const ODAttributeType kODAttributeTypeRealUserID;
+const ODAttributeType kODAttributeTypeRelativeDNPrefix;
+const ODAttributeType kODAttributeTypeSMBAcctFlags;
+const ODAttributeType kODAttributeTypeSMBGroupRID;
+const ODAttributeType kODAttributeTypeSMBHome;
+const ODAttributeType kODAttributeTypeSMBHomeDrive;
+const ODAttributeType kODAttributeTypeSMBKickoffTime;
+const ODAttributeType kODAttributeTypeSMBLogoffTime;
+const ODAttributeType kODAttributeTypeSMBLogonTime;
+const ODAttributeType kODAttributeTypeSMBPrimaryGroupSID;
+const ODAttributeType kODAttributeTypeSMBPWDLastSet;
+const ODAttributeType kODAttributeTypeSMBProfilePath;
+const ODAttributeType kODAttributeTypeSMBRID;
+const ODAttributeType kODAttributeTypeSMBScriptPath;
+const ODAttributeType kODAttributeTypeSMBSID;
+const ODAttributeType kODAttributeTypeSMBUserWorkstations;
+const ODAttributeType kODAttributeTypeServiceType;
+const ODAttributeType kODAttributeTypeSetupAdvertising;
+const ODAttributeType kODAttributeTypeSetupAutoRegister;
+const ODAttributeType kODAttributeTypeSetupLocation;
+const ODAttributeType kODAttributeTypeSetupOccupation;
+const ODAttributeType kODAttributeTypeTimeToLive;
+const ODAttributeType kODAttributeTypeTrustInformation;
+const ODAttributeType kODAttributeTypeUniqueID;
+const ODAttributeType kODAttributeTypeUserCertificate;
+const ODAttributeType kODAttributeTypeUserPKCS12Data;
+const ODAttributeType kODAttributeTypeUserShell;
+const ODAttributeType kODAttributeTypeUserSMIMECertificate;
+const ODAttributeType kODAttributeTypeVFSDumpFreq;
+const ODAttributeType kODAttributeTypeVFSLinkDir;
+const ODAttributeType kODAttributeTypeVFSPassNo;
+const ODAttributeType kODAttributeTypeVFSType;
+const ODAttributeType kODAttributeTypeWeblogURI;
+const ODAttributeType kODAttributeTypeXMLPlist;
+const ODAttributeType kODAttributeTypeProtocolNumber;
+const ODAttributeType kODAttributeTypeRPCNumber;
+const ODAttributeType kODAttributeTypeNetworkNumber;
+const ODAttributeType kODAttributeTypeAccessControlEntry;
+const ODAttributeType kODAttributeTypeAddressLine1;
+const ODAttributeType kODAttributeTypeAddressLine2;
+const ODAttributeType kODAttributeTypeAddressLine3;
+const ODAttributeType kODAttributeTypeAreaCode;
+const ODAttributeType kODAttributeTypeAuthenticationAuthority;
+const ODAttributeType kODAttributeTypeAutomountInformation;
+const ODAttributeType kODAttributeTypeBootParams;
+const ODAttributeType kODAttributeTypeBuilding;
+const ODAttributeType kODAttributeTypeServicesLocator;
+const ODAttributeType kODAttributeTypeCity;
+const ODAttributeType kODAttributeTypeCompany;
+const ODAttributeType kODAttributeTypeComputers;
+const ODAttributeType kODAttributeTypeCountry;
+const ODAttributeType kODAttributeTypeDepartment;
+const ODAttributeType kODAttributeTypeDNSName;
+const ODAttributeType kODAttributeTypeEMailAddress;
+const ODAttributeType kODAttributeTypeEMailContacts;
+const ODAttributeType kODAttributeTypeFaxNumber;
+const ODAttributeType kODAttributeTypeGroup;
+const ODAttributeType kODAttributeTypeGroupMembers;
+const ODAttributeType kODAttributeTypeGroupMembership;
+const ODAttributeType kODAttributeTypeGroupServices;
+const ODAttributeType kODAttributeTypeHomePhoneNumber;
+const ODAttributeType kODAttributeTypeHTML;
+const ODAttributeType kODAttributeTypeHomeDirectory;
+const ODAttributeType kODAttributeTypeIMHandle;
+const ODAttributeType kODAttributeTypeIPAddress;
+const ODAttributeType kODAttributeTypeIPAddressAndENetAddress;
+const ODAttributeType kODAttributeTypeIPv6Address;
+const ODAttributeType kODAttributeTypeJPEGPhoto;
+const ODAttributeType kODAttributeTypeJobTitle;
+const ODAttributeType kODAttributeTypeKDCAuthKey;
+const ODAttributeType kODAttributeTypeKeywords;
+const ODAttributeType kODAttributeTypeLDAPReadReplicas;
+const ODAttributeType kODAttributeTypeLDAPWriteReplicas;
+const ODAttributeType kODAttributeTypeMapCoordinates;
+const ODAttributeType kODAttributeTypeMapURI;
+const ODAttributeType kODAttributeTypeMIME;
+const ODAttributeType kODAttributeTypeMobileNumber;
+const ODAttributeType kODAttributeTypeNestedGroups;
+const ODAttributeType kODAttributeTypeNetGroups;
+const ODAttributeType kODAttributeTypeNickName;
+const ODAttributeType kODAttributeTypeOrganizationInfo;
+const ODAttributeType kODAttributeTypeOrganizationName;
+const ODAttributeType kODAttributeTypePagerNumber;
+const ODAttributeType kODAttributeTypePhoneContacts;
+const ODAttributeType kODAttributeTypePhoneNumber;
+const ODAttributeType kODAttributeTypePGPPublicKey;
+const ODAttributeType kODAttributeTypePostalAddress;
+const ODAttributeType kODAttributeTypePostalAddressContacts;
+const ODAttributeType kODAttributeTypePostalCode;
+const ODAttributeType kODAttributeTypeNamePrefix;
+const ODAttributeType kODAttributeTypeProfiles;
+const ODAttributeType kODAttributeTypeProfilesTimestamp;
+const ODAttributeType kODAttributeTypeProtocols;
+const ODAttributeType kODAttributeTypeRecordName;
+const ODAttributeType kODAttributeTypeRelationships;
+const ODAttributeType kODAttributeTypeResourceInfo;
+const ODAttributeType kODAttributeTypeResourceType;
+const ODAttributeType kODAttributeTypeState;
+const ODAttributeType kODAttributeTypeStreet;
+const ODAttributeType kODAttributeTypeNameSuffix;
+const ODAttributeType kODAttributeTypeURL;
+const ODAttributeType kODAttributeTypeVFSOpts;
+const ODAttributeType kODAttributeTypeAlias;
+const ODAttributeType kODAttributeTypeAuthCredential;
+const ODAttributeType kODAttributeTypeCopyTimestamp;
+const ODAttributeType kODAttributeTypeDateRecordCreated;
+const ODAttributeType kODAttributeTypeKerberosRealm;
+const ODAttributeType kODAttributeTypeNTDomainComputerAccount;
+const ODAttributeType kODAttributeTypeOriginalHomeDirectory;
+const ODAttributeType kODAttributeTypeOriginalNFSHomeDirectory;
+const ODAttributeType kODAttributeTypeOriginalNodeName;
+const ODAttributeType kODAttributeTypePrimaryNTDomain;
+const ODAttributeType kODAttributeTypePwdAgingPolicy;
+const ODAttributeType kODAttributeTypeReadOnlyNode;
+const ODAttributeType kODAttributeTypeTimePackage;
+const ODAttributeType kODAttributeTypeTotalSize;
+const ODAttributeType kODAttributeTypeAuthMethod;
+const ODAttributeType kODAttributeTypeMetaNodeLocation;
+const ODAttributeType kODAttributeTypeNodePath;
+const ODAttributeType kODAttributeTypePlugInInfo;
+const ODAttributeType kODAttributeTypeRecordType;
+const ODAttributeType kODAttributeTypeSchema;
+const ODAttributeType kODAttributeTypeSubNodes;
+const ODAttributeType kODAttributeTypeNetGroupTriplet;
+const ODAttributeType kODAttributeTypeSearchPath;
+const ODAttributeType kODAttributeTypeSearchPolicy;
+const ODAttributeType kODAttributeTypeAutomaticSearchPath;
+const ODAttributeType kODAttributeTypeLocalOnlySearchPath;
+const ODAttributeType kODAttributeTypeCustomSearchPath;
+const ODAttributeType kODAttributeTypeNodeOptions;
+//const ODAttributeType kODAttributeTypeNodeSASLRealm;
+const ODAttributeType kODAttributeTypeAdvertisedServices;
+const ODAttributeType kODAttributeTypeLocaleRelay;
+const ODAttributeType kODAttributeTypeLocaleSubnets;
+const ODAttributeType kODAttributeTypeNetworkInterfaces;
+const ODAttributeType kODAttributeTypeParentLocales;
+const ODAttributeType kODAttributeTypePrimaryLocale;
+const ODAttributeType kODAttributeTypeBuildVersion;
+const ODAttributeType kODAttributeTypeConfigAvailable;
+const ODAttributeType kODAttributeTypeConfigFile;
+const ODAttributeType kODAttributeTypeCoreFWVersion;
+const ODAttributeType kODAttributeTypeFunctionalState;
+const ODAttributeType kODAttributeTypeFWVersion;
+const ODAttributeType kODAttributeTypePluginIndex;
+const ODAttributeType kODAttributeTypeNumTableList;
+const ODAttributeType kODAttributeTypeVersion;
+const ODAttributeType kODAttributeTypePIDValue;
+const ODAttributeType kODAttributeTypeProcessName;
+const ODAttributeType kODAttributeTypeTotalRefCount;
+const ODAttributeType kODAttributeTypeDirRefCount;
+const ODAttributeType kODAttributeTypeNodeRefCount;
+const ODAttributeType kODAttributeTypeRecRefCount;
+const ODAttributeType kODAttributeTypeAttrListRefCount;
+const ODAttributeType kODAttributeTypeAttrListValueRefCount;
+const ODAttributeType kODAttributeTypeDirRefs;
+const ODAttributeType kODAttributeTypeNodeRefs;
+const ODAttributeType kODAttributeTypeRecRefs;
+const ODAttributeType kODAttributeTypeAttrListRefs;
+const ODAttributeType kODAttributeTypeAttrListValueRefs;
+
+const ODAuthenticationType kODAuthenticationType2WayRandom;
+const ODAuthenticationType kODAuthenticationType2WayRandomChangePasswd;
+const ODAuthenticationType kODAuthenticationTypeAPOP;
+const ODAuthenticationType kODAuthenticationTypeCRAM_MD5;
+const ODAuthenticationType kODAuthenticationTypeChangePasswd;
+const ODAuthenticationType kODAuthenticationTypeClearText;
+const ODAuthenticationType kODAuthenticationTypeCrypt;
+const ODAuthenticationType kODAuthenticationTypeDIGEST_MD5;
+const ODAuthenticationType kODAuthenticationTypeDeleteUser;
+const ODAuthenticationType kODAuthenticationTypeGetEffectivePolicy;
+const ODAuthenticationType kODAuthenticationTypeGetGlobalPolicy;
+const ODAuthenticationType kODAuthenticationTypeGetKerberosPrincipal;
+const ODAuthenticationType kODAuthenticationTypeGetPolicy;
+const ODAuthenticationType kODAuthenticationTypeGetUserData;
+const ODAuthenticationType kODAuthenticationTypeGetUserName;
+const ODAuthenticationType kODAuthenticationTypeKerberosTickets;
+const ODAuthenticationType kODAuthenticationTypeMPPEMasterKeys;
+const ODAuthenticationType kODAuthenticationTypeMSCHAP2;
+const ODAuthenticationType kODAuthenticationTypeNTLMv2;
+const ODAuthenticationType kODAuthenticationTypeNTLMv2WithSessionKey;
+const ODAuthenticationType kODAuthenticationTypeNewUser;
+const ODAuthenticationType kODAuthenticationTypeNewUserWithPolicy;
+const ODAuthenticationType kODAuthenticationTypeNodeNativeClearTextOK;
+const ODAuthenticationType kODAuthenticationTypeNodeNativeNoClearText;
+const ODAuthenticationType kODAuthenticationTypeReadSecureHash;
+const ODAuthenticationType kODAuthenticationTypeSMBNTv2UserSessionKey;
+const ODAuthenticationType kODAuthenticationTypeSMBWorkstationCredentialSessionKey;
+const ODAuthenticationType kODAuthenticationTypeSMB_LM_Key;
+const ODAuthenticationType kODAuthenticationTypeSMB_NT_Key;
+const ODAuthenticationType kODAuthenticationTypeSMB_NT_UserSessionKey;
+const ODAuthenticationType kODAuthenticationTypeSMB_NT_WithUserSessionKey;
+const ODAuthenticationType kODAuthenticationTypeSetGlobalPolicy;
+const ODAuthenticationType kODAuthenticationTypeSetLMHash;
+const ODAuthenticationType kODAuthenticationTypeSetNTHash;
+const ODAuthenticationType kODAuthenticationTypeSetPassword;
+const ODAuthenticationType kODAuthenticationTypeSetPasswordAsCurrent;
+const ODAuthenticationType kODAuthenticationTypeSetPolicy;
+const ODAuthenticationType kODAuthenticationTypeSetPolicyAsCurrent;
+const ODAuthenticationType kODAuthenticationTypeSetUserData;
+const ODAuthenticationType kODAuthenticationTypeSetUserName;
+const ODAuthenticationType kODAuthenticationTypeSetWorkstationPassword;
+const ODAuthenticationType kODAuthenticationTypeWithAuthorizationRef;
+const ODAuthenticationType kODAuthenticationTypeWriteSecureHash;"""
+
+FUNCTIONS = """
+ODSessionRef ODSessionCreate ( CFAllocatorRef allocator, CFDictionaryRef options, CFErrorRef *error );
+CFArrayRef ODSessionCopyNodeNames ( CFAllocatorRef allocator, ODSessionRef session, CFErrorRef *error );
+
+ODNodeRef ODNodeCreateWithName ( CFAllocatorRef allocator, ODSessionRef session, CFStringRef nodeName, CFErrorRef *error );
+bool ODNodeSetCredentials ( ODNodeRef node, ODRecordType recordType, CFStringRef recordName, CFStringRef password, CFErrorRef *error );
+CFDictionaryRef ODNodeCopyDetails ( ODNodeRef node, CFArrayRef keys, CFErrorRef *error );
+ODRecordRef ODNodeCopyRecord ( ODNodeRef node, ODRecordType recordType, CFStringRef recordName, CFTypeRef attributes, CFErrorRef *error );
+
+CFDictionaryRef ODRecordCopyDetails ( ODRecordRef record, CFArrayRef attributes, CFErrorRef *error );
+bool ODRecordVerifyPassword ( ODRecordRef record, CFStringRef password, CFErrorRef *error );
+bool ODRecordVerifyPasswordExtended ( ODRecordRef record, ODAuthenticationType authType, CFArrayRef authItems, CFArrayRef *outAuthItems, ODContextRef *outContext, CFErrorRef *error );
+
+CFArrayRef ODQueryCopyResults ( ODQueryRef query, bool allowPartialResults, CFErrorRef *error );
+ODQueryRef ODQueryCreateWithNode ( CFAllocatorRef allocator, ODNodeRef node, CFTypeRef recordTypeOrList, ODAttributeType attribute, ODMatchType matchType, CFTypeRef queryValueOrList, CFTypeRef returnAttributeOrList, CFIndex maxResults, CFErrorRef *error );
+"""

Added: OSXFrameworks/trunk/osx/frameworks/_security_cffi.py
===================================================================
--- OSXFrameworks/trunk/osx/frameworks/_security_cffi.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/frameworks/_security_cffi.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,371 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+
+INCLUDES = """
+#include <Security/Security.h>
+"""
+
+EXTRA_LINKS = []
+
+TYPES = """
+
+// SecBase.h
+typedef struct OpaqueSecCertificateRef *SecCertificateRef;
+typedef struct OpaqueSecIdentityRef *SecIdentityRef;
+
+// SecureTransport.h
+typedef enum
+{
+    kSSLServerSide,
+    kSSLClientSide
+} SSLProtocolSide;
+
+typedef enum
+{
+    kSSLStreamType,
+    kSSLDatagramType
+} SSLConnectionType;
+
+typedef enum {
+    kSSLProtocolUnknown = 0,                /* no protocol negotiated/specified; use default */
+    kSSLProtocol3       = 2,                /* SSL 3.0 */
+    kTLSProtocol1       = 4,                /* TLS 1.0 */
+    kTLSProtocol11      = 7,                /* TLS 1.1 */
+    kTLSProtocol12      = 8,                /* TLS 1.2 */
+    kDTLSProtocol1      = 9,                /* DTLS 1.0 */
+
+    /* DEPRECATED on iOS */
+    kSSLProtocol2       = 1,                /* SSL 2.0 */
+    kSSLProtocol3Only   = 3,                /* SSL 3.0 Only */
+    kTLSProtocol1Only   = 5,                /* TLS 1.0 Only */
+    kSSLProtocolAll     = 6,                /* All TLS supported protocols */
+
+} SSLProtocol;
+
+struct SSLContext;
+typedef struct SSLContext *SSLContextRef;
+typedef const void *SSLConnectionRef;
+
+typedef OSStatus (*SSLReadFunc) ( SSLConnectionRef connection, void *data, size_t *dataLength );
+typedef OSStatus (*SSLWriteFunc) ( SSLConnectionRef connection, const void *data, size_t *dataLength );
+"""
+
+CONSTANTS = """
+
+// SecCertificateOIDs.h
+const CFStringRef kSecOIDAuthorityInfoAccess;
+const CFStringRef kSecOIDAuthorityKeyIdentifier;
+const CFStringRef kSecOIDBasicConstraints;
+const CFStringRef kSecOIDBiometricInfo;
+const CFStringRef kSecOIDCSSMKeyStruct;
+const CFStringRef kSecOIDCertIssuer;
+const CFStringRef kSecOIDCertificatePolicies;
+const CFStringRef kSecOIDClientAuth;
+const CFStringRef kSecOIDCollectiveStateProvinceName;
+const CFStringRef kSecOIDCollectiveStreetAddress;
+const CFStringRef kSecOIDCommonName;
+const CFStringRef kSecOIDCountryName;
+const CFStringRef kSecOIDCrlDistributionPoints;
+const CFStringRef kSecOIDCrlNumber;
+const CFStringRef kSecOIDCrlReason;
+const CFStringRef kSecOIDDeltaCrlIndicator;
+const CFStringRef kSecOIDDescription;
+const CFStringRef kSecOIDEmailAddress;
+const CFStringRef kSecOIDEmailProtection;
+const CFStringRef kSecOIDExtendedKeyUsage;
+const CFStringRef kSecOIDExtendedKeyUsageAny;
+const CFStringRef kSecOIDExtendedUseCodeSigning;
+const CFStringRef kSecOIDGivenName;
+const CFStringRef kSecOIDHoldInstructionCode;
+const CFStringRef kSecOIDInvalidityDate;
+const CFStringRef kSecOIDIssuerAltName;
+const CFStringRef kSecOIDIssuingDistributionPoint;
+const CFStringRef kSecOIDIssuingDistributionPoints;
+const CFStringRef kSecOIDKeyUsage;
+const CFStringRef kSecOIDLocalityName;
+const CFStringRef kSecOIDMS_NTPrincipalName;
+const CFStringRef kSecOIDMicrosoftSGC;
+const CFStringRef kSecOIDNameConstraints;
+const CFStringRef kSecOIDNetscapeCertSequence;
+const CFStringRef kSecOIDNetscapeCertType;
+const CFStringRef kSecOIDNetscapeSGC;
+const CFStringRef kSecOIDOCSPSigning;
+const CFStringRef kSecOIDOrganizationName;
+const CFStringRef kSecOIDOrganizationalUnitName;
+const CFStringRef kSecOIDPolicyConstraints;
+const CFStringRef kSecOIDPolicyMappings;
+const CFStringRef kSecOIDPrivateKeyUsagePeriod;
+const CFStringRef kSecOIDQC_Statements;
+const CFStringRef kSecOIDSerialNumber;
+const CFStringRef kSecOIDServerAuth;
+const CFStringRef kSecOIDStateProvinceName;
+const CFStringRef kSecOIDStreetAddress;
+const CFStringRef kSecOIDSubjectAltName;
+const CFStringRef kSecOIDSubjectDirectoryAttributes;
+const CFStringRef kSecOIDSubjectEmailAddress;
+const CFStringRef kSecOIDSubjectInfoAccess;
+const CFStringRef kSecOIDSubjectKeyIdentifier;
+const CFStringRef kSecOIDSubjectPicture;
+const CFStringRef kSecOIDSubjectSignatureBitmap;
+const CFStringRef kSecOIDSurname;
+const CFStringRef kSecOIDTimeStamping;
+const CFStringRef kSecOIDTitle;
+const CFStringRef kSecOIDUseExemptions;
+const CFStringRef kSecOIDX509V1CertificateIssuerUniqueId;
+const CFStringRef kSecOIDX509V1CertificateSubjectUniqueId;
+const CFStringRef kSecOIDX509V1IssuerName;
+const CFStringRef kSecOIDX509V1IssuerNameCStruct;
+const CFStringRef kSecOIDX509V1IssuerNameLDAP;
+const CFStringRef kSecOIDX509V1IssuerNameStd;
+const CFStringRef kSecOIDX509V1SerialNumber;
+const CFStringRef kSecOIDX509V1Signature;
+const CFStringRef kSecOIDX509V1SignatureAlgorithm;
+const CFStringRef kSecOIDX509V1SignatureAlgorithmParameters;
+const CFStringRef kSecOIDX509V1SignatureAlgorithmTBS;
+const CFStringRef kSecOIDX509V1SignatureCStruct;
+const CFStringRef kSecOIDX509V1SignatureStruct;
+const CFStringRef kSecOIDX509V1SubjectName;
+const CFStringRef kSecOIDX509V1SubjectNameCStruct;
+const CFStringRef kSecOIDX509V1SubjectNameLDAP;
+const CFStringRef kSecOIDX509V1SubjectNameStd;
+const CFStringRef kSecOIDX509V1SubjectPublicKey;
+const CFStringRef kSecOIDX509V1SubjectPublicKeyAlgorithm;
+const CFStringRef kSecOIDX509V1SubjectPublicKeyAlgorithmParameters;
+const CFStringRef kSecOIDX509V1SubjectPublicKeyCStruct;
+const CFStringRef kSecOIDX509V1ValidityNotAfter;
+const CFStringRef kSecOIDX509V1ValidityNotBefore;
+const CFStringRef kSecOIDX509V1Version;
+const CFStringRef kSecOIDX509V3Certificate;
+const CFStringRef kSecOIDX509V3CertificateCStruct;
+const CFStringRef kSecOIDX509V3CertificateExtensionCStruct;
+const CFStringRef kSecOIDX509V3CertificateExtensionCritical;
+const CFStringRef kSecOIDX509V3CertificateExtensionId;
+const CFStringRef kSecOIDX509V3CertificateExtensionStruct;
+const CFStringRef kSecOIDX509V3CertificateExtensionType;
+const CFStringRef kSecOIDX509V3CertificateExtensionValue;
+const CFStringRef kSecOIDX509V3CertificateExtensionsCStruct;
+const CFStringRef kSecOIDX509V3CertificateExtensionsStruct;
+const CFStringRef kSecOIDX509V3CertificateNumberOfExtensions;
+const CFStringRef kSecOIDX509V3SignedCertificate;
+const CFStringRef kSecOIDX509V3SignedCertificateCStruct;
+const CFStringRef kSecOIDSRVName;
+
+// SecCertificate.h
+const CFStringRef kSecPropertyKeyType;
+const CFStringRef kSecPropertyKeyLabel;
+const CFStringRef kSecPropertyKeyLocalizedLabel;
+const CFStringRef kSecPropertyKeyValue;
+
+CFStringRef kSecPropertyTypeWarning;
+CFStringRef kSecPropertyTypeSuccess;
+CFStringRef kSecPropertyTypeSection;
+CFStringRef kSecPropertyTypeData;
+CFStringRef kSecPropertyTypeString;
+CFStringRef kSecPropertyTypeURL;
+CFStringRef kSecPropertyTypeDate;
+CFTypeRef kSecPropertyTypeTitle;
+CFTypeRef kSecPropertyTypeError;
+
+const CFStringRef kSecClass;
+
+const CFStringRef kSecClassInternetPassword;
+const CFStringRef kSecClassGenericPassword;
+const CFStringRef kSecClassCertificate;
+const CFStringRef kSecClassKey;
+const CFStringRef kSecClassIdentity;
+
+const CFStringRef kSecMatchPolicy;
+const CFStringRef kSecMatchItemList;
+const CFStringRef kSecMatchSearchList;
+const CFStringRef kSecMatchIssuers;
+const CFStringRef kSecMatchEmailAddressIfPresent;
+const CFStringRef kSecMatchSubjectContains;
+const CFStringRef kSecMatchSubjectStartsWith;
+const CFStringRef kSecMatchSubjectEndsWith;
+const CFStringRef kSecMatchSubjectWholeString;
+const CFStringRef kSecMatchCaseInsensitive;
+const CFStringRef kSecMatchDiacriticInsensitive;
+const CFStringRef kSecMatchWidthInsensitive;
+const CFStringRef kSecMatchTrustedOnly;
+const CFStringRef kSecMatchValidOnDate;
+const CFStringRef kSecMatchLimit;
+const CFStringRef kSecMatchLimitOne;
+const CFStringRef kSecMatchLimitAll;
+
+const CFStringRef kSecReturnData;
+const CFStringRef kSecReturnAttributes;
+const CFStringRef kSecReturnRef;
+const CFStringRef kSecReturnPersistentRef;
+
+const CFStringRef kSecAttrAccessible;
+const CFStringRef kSecAttrAccess;
+const CFStringRef kSecAttrAccessControl;
+const CFStringRef kSecAttrAccessGroup;
+const CFStringRef kSecAttrSynchronizable;
+const CFStringRef kSecAttrSynchronizableAny;
+const CFStringRef kSecAttrCreationDate;
+const CFStringRef kSecAttrModificationDate;
+const CFStringRef kSecAttrDescription;
+const CFStringRef kSecAttrComment;
+const CFStringRef kSecAttrCreator;
+const CFStringRef kSecAttrType;
+const CFStringRef kSecAttrLabel;
+const CFStringRef kSecAttrIsInvisible;
+const CFStringRef kSecAttrIsNegative;
+const CFStringRef kSecAttrAccount;
+const CFStringRef kSecAttrService;
+const CFStringRef kSecAttrGeneric;
+const CFStringRef kSecAttrSecurityDomain;
+const CFStringRef kSecAttrServer;
+const CFStringRef kSecAttrProtocol;
+const CFStringRef kSecAttrAuthenticationType;
+const CFStringRef kSecAttrPort;
+const CFStringRef kSecAttrPath;
+const CFStringRef kSecAttrSubject;
+const CFStringRef kSecAttrIssuer;
+const CFStringRef kSecAttrSerialNumber;
+const CFStringRef kSecAttrSubjectKeyID;
+const CFStringRef kSecAttrPublicKeyHash;
+const CFStringRef kSecAttrCertificateType;
+const CFStringRef kSecAttrCertificateEncoding;
+const CFStringRef kSecAttrKeyClass;
+const CFStringRef kSecAttrApplicationLabel;
+const CFStringRef kSecAttrIsPermanent;
+const CFStringRef kSecAttrIsSensitive;
+const CFStringRef kSecAttrIsExtractable;
+const CFStringRef kSecAttrApplicationTag;
+const CFStringRef kSecAttrKeyType;
+const CFStringRef kSecAttrPRF;
+const CFStringRef kSecAttrSalt;
+const CFStringRef kSecAttrRounds;
+const CFStringRef kSecAttrKeySizeInBits;
+const CFStringRef kSecAttrEffectiveKeySize;
+const CFStringRef kSecAttrCanEncrypt;
+const CFStringRef kSecAttrCanDecrypt;
+const CFStringRef kSecAttrCanDerive;
+const CFStringRef kSecAttrCanSign;
+const CFStringRef kSecAttrCanVerify;
+const CFStringRef kSecAttrCanWrap;
+const CFStringRef kSecAttrCanUnwrap;
+
+const CFStringRef kSecValueData;
+const CFStringRef kSecValueRef;
+const CFStringRef kSecValuePersistentRef;
+
+enum {
+    errSSLProtocol                = -9800,    /* SSL protocol error */
+    errSSLNegotiation            = -9801,    /* Cipher Suite negotiation failure */
+    errSSLFatalAlert            = -9802,    /* Fatal alert */
+    errSSLWouldBlock            = -9803,    /* I/O would block (not fatal) */
+    errSSLSessionNotFound         = -9804,    /* attempt to restore an unknown session */
+    errSSLClosedGraceful         = -9805,    /* connection closed gracefully */
+    errSSLClosedAbort             = -9806,    /* connection closed via error */
+    errSSLXCertChainInvalid     = -9807,    /* invalid certificate chain */
+    errSSLBadCert                = -9808,    /* bad certificate format */
+    errSSLCrypto                = -9809,    /* underlying cryptographic error */
+    errSSLInternal                = -9810,    /* Internal error */
+    errSSLModuleAttach            = -9811,    /* module attach failure */
+    errSSLUnknownRootCert        = -9812,    /* valid cert chain, untrusted root */
+    errSSLNoRootCert            = -9813,    /* cert chain not verified by root */
+    errSSLCertExpired            = -9814,    /* chain had an expired cert */
+    errSSLCertNotYetValid        = -9815,    /* chain had a cert not yet valid */
+    errSSLClosedNoNotify        = -9816,    /* server closed session with no notification */
+    errSSLBufferOverflow        = -9817,    /* insufficient buffer provided */
+    errSSLBadCipherSuite        = -9818,    /* bad SSLCipherSuite */
+
+    /* fatal errors detected by peer */
+    errSSLPeerUnexpectedMsg        = -9819,    /* unexpected message received */
+    errSSLPeerBadRecordMac        = -9820,    /* bad MAC */
+    errSSLPeerDecryptionFail    = -9821,    /* decryption failed */
+    errSSLPeerRecordOverflow    = -9822,    /* record overflow */
+    errSSLPeerDecompressFail    = -9823,    /* decompression failure */
+    errSSLPeerHandshakeFail        = -9824,    /* handshake failure */
+    errSSLPeerBadCert            = -9825,    /* misc. bad certificate */
+    errSSLPeerUnsupportedCert    = -9826,    /* bad unsupported cert format */
+    errSSLPeerCertRevoked        = -9827,    /* certificate revoked */
+    errSSLPeerCertExpired        = -9828,    /* certificate expired */
+    errSSLPeerCertUnknown        = -9829,    /* unknown certificate */
+    errSSLIllegalParam            = -9830,    /* illegal parameter */
+    errSSLPeerUnknownCA         = -9831,    /* unknown Cert Authority */
+    errSSLPeerAccessDenied        = -9832,    /* access denied */
+    errSSLPeerDecodeError        = -9833,    /* decoding error */
+    errSSLPeerDecryptError        = -9834,    /* decryption error */
+    errSSLPeerExportRestriction    = -9835,    /* export restriction */
+    errSSLPeerProtocolVersion    = -9836,    /* bad protocol version */
+    errSSLPeerInsufficientSecurity = -9837,    /* insufficient security */
+    errSSLPeerInternalError        = -9838,    /* internal error */
+    errSSLPeerUserCancelled        = -9839,    /* user canceled */
+    errSSLPeerNoRenegotiation    = -9840,    /* no renegotiation allowed */
+
+    /* non-fatal result codes */
+    errSSLPeerAuthCompleted     = -9841,    /* peer cert is valid, or was ignored if verification disabled */
+    errSSLClientCertRequested    = -9842,    /* server has requested a client cert */
+
+    /* more errors detected by us */
+    errSSLHostNameMismatch        = -9843,    /* peer host name mismatch */
+    errSSLConnectionRefused        = -9844,    /* peer dropped connection before responding */
+    errSSLDecryptionFail        = -9845,    /* decryption failure */
+    errSSLBadRecordMac            = -9846,    /* bad MAC */
+    errSSLRecordOverflow        = -9847,    /* record overflow */
+    errSSLBadConfiguration        = -9848,    /* configuration error */
+    errSSLUnexpectedRecord      = -9849,    /* unexpected (skipped) record in DTLS */
+    errSSLWeakPeerEphemeralDHKey = -9850,    /* weak ephemeral dh key  */
+
+    /* non-fatal result codes */
+    errSSLClientHelloReceived   = -9851,    /* SNI */
+};
+"""
+
+FUNCTIONS = """
+
+// SecCertificate.h
+SecCertificateRef SecCertificateCopyPreferred(CFStringRef name, CFArrayRef keyUsage);
+CFDictionaryRef SecCertificateCopyValues(SecCertificateRef certificate, CFArrayRef keys, CFErrorRef *error);
+
+// SecIdentity.h
+OSStatus SecIdentityCopyCertificate ( SecIdentityRef identityRef, SecCertificateRef *certificateRef );
+
+// SecItem.h
+OSStatus SecItemCopyMatching ( CFDictionaryRef query, CFTypeRef *result );
+
+// SecKeychain.h
+OSStatus SecKeychainSetUserInteractionAllowed ( Boolean state );
+
+// SecureTransport.h
+SSLContextRef
+SSLCreateContext(CFAllocatorRef alloc, SSLProtocolSide protocolSide, SSLConnectionType connectionType);
+
+OSStatus
+SSLSetProtocolVersionEnabled (SSLContextRef     context,
+                             SSLProtocol        protocol,
+                             Boolean            enable);
+
+OSStatus SSLSetConnection (SSLContextRef context, SSLConnectionRef connection);
+OSStatus SSLGetConnection (SSLContextRef context, SSLConnectionRef *connection);
+
+OSStatus SSLSetCertificate ( SSLContextRef context, CFArrayRef certRefs );
+OSStatus SSLCopyPeerCertificates ( SSLContextRef context, CFArrayRef *certs );
+
+OSStatus SSLSetIOFuncs ( SSLContextRef context, SSLReadFunc readFunc, SSLWriteFunc writeFunc );
+
+OSStatus SSLHandshake ( SSLContextRef context );
+
+OSStatus SSLWrite ( SSLContextRef context, const void *data, size_t dataLength, size_t *processed );
+OSStatus SSLRead ( SSLContextRef context, void *data, size_t dataLength, size_t *processed );
+
+OSStatus SSLClose ( SSLContextRef context );
+"""

Added: OSXFrameworks/trunk/osx/frameworks/_utils_cffi.py
===================================================================
--- OSXFrameworks/trunk/osx/frameworks/_utils_cffi.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/frameworks/_utils_cffi.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,62 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+
+INCLUDES = """
+#include <CoreFoundation/CoreFoundation.h>
+"""
+
+EXTRA_LINKS = []
+
+TYPES = """
+typedef const struct __CFTimeZone *CFTimeZoneRef;
+
+typedef const struct __CFLocale *CFLocaleRef;
+
+typedef CFTypeRef CFPropertyListRef;
+
+typedef CFOptionFlags CFPropertyListMutabilityOptions;
+enum {
+    kCFPropertyListImmutable = 0,
+    kCFPropertyListMutableContainers,
+    kCFPropertyListMutableContainersAndLeaves
+};
+
+typedef CFIndex CFPropertyListFormat;
+enum {
+    kCFPropertyListOpenStepFormat = 1,
+    kCFPropertyListXMLFormat_v1_0 = 100,
+    kCFPropertyListBinaryFormat_v1_0 = 200
+};
+"""
+
+CONSTANTS = """
+"""
+
+FUNCTIONS = """
+// CFTimeZone
+CFTypeID CFTimeZoneGetTypeID ( void );
+CFTimeZoneRef CFTimeZoneCopyDefault ( void );
+CFStringRef CFTimeZoneGetName ( CFTimeZoneRef tz );
+
+// CFLocale
+CFTypeID CFLocaleGetTypeID ( void );
+CFLocaleRef CFLocaleCopyCurrent ( void );
+CFArrayRef CFLocaleCopyPreferredLanguages ( void );
+
+// CFPropertyList
+CFPropertyListRef CFPropertyListCreateWithData ( CFAllocatorRef allocator, CFDataRef data, CFOptionFlags options, CFPropertyListFormat *format, CFErrorRef *error );
+"""

Added: OSXFrameworks/trunk/osx/opendirectory.py
===================================================================
--- OSXFrameworks/trunk/osx/opendirectory.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/opendirectory.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,282 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+"""
+A set of Python classes that wrap common CFOpenDirectory classes.
+"""
+
+from ._corefoundation import ffi, lib as od
+from .corefoundation import CFObjectRef, CFErrorRef, \
+    CFArrayRef, CFStringRef, CFDictionaryRef
+
+
+class ODError(Exception):
+    """
+    OpenDirectory error occurred.
+    """
+
+
+
+class ODSession(CFObjectRef):
+    """
+    Wraps a cffi/ODSession object.
+    """
+
+    def __init__(self, session=None):
+        """
+        Create an ODSession.
+        """
+
+        if session is None:
+            error = ffi.new("CFErrorRef *")
+            session = od.ODSessionCreate(ffi.NULL, ffi.NULL, error)
+            if session == ffi.NULL:
+                error = CFErrorRef(error[0])
+                raise ODError("Unable to create ODSession: {}".format(error.error()))
+        super(ODSession, self).__init__(session)
+
+
+    @classmethod
+    def defaultSession(cls):
+        """
+        Return the default session.
+
+        @return: the default session
+        @rtype: L{ODSession}
+        """
+        return cls(session=od.kODSessionDefault)
+
+
+    def nodeNames(self):
+        """
+        Return a list of all the nodes available to the current ODSession.
+
+        @return: list of node names
+        @rtype: L{list} of L{str}
+        """
+
+        error = ffi.new("CFErrorRef *")
+        nodes = od.ODSessionCopyNodeNames(ffi.NULL, self.ref(), error)
+        if nodes == ffi.NULL:
+            error = CFErrorRef(error[0])
+            raise ODError("Unable to get node names from session: {}".format(error.error()))
+
+        nodes = CFArrayRef(nodes)
+        return nodes.toList()
+
+
+
+class ODNode(CFObjectRef):
+    """
+    Wraps a cffi/ODNode object.
+    """
+
+    def __init__(self, session, nodename):
+        """
+        Create an ODNode with the specified name using an ODSession.
+
+        @param session: session to use
+        @type session: L{ODSession}
+        @param nodename: name
+        @type nodename: L{str}
+        """
+        name = CFStringRef.fromString(nodename)
+        error = ffi.new("CFErrorRef *")
+        node = od.ODNodeCreateWithName(ffi.NULL, session.ref(), name.ref(), error)
+        if node == ffi.NULL:
+            error = CFErrorRef(error[0])
+            raise ODError("Unable to create ODNode: {} {}".format(nodename, error.error()))
+        super(ODNode, self).__init__(node)
+
+
+    def setCredentials(self, recordType, user, pswd):
+        """
+        Authentication to this ODNode.
+
+        @param recordType: OD record type to use
+        @type recordType: L{str}
+        @param user: user record name to auth as
+        @type user: L{str}
+        @param pswd: password to use
+        @type pswd: L{str}
+
+        @return: whether or not the authentication worked
+        @rtype: L{bool}
+        """
+
+        recordType = CFStringRef.fromString(recordType)
+        user = CFStringRef.fromString(user)
+        pswd = CFStringRef.fromString(pswd)
+
+        return od.ODNodeSetCredentials(self.ref(), recordType.ref(), user, pswd, ffi.NULL)
+
+
+    def details(self, keys):
+        """
+        Return the node attributes as an L{dict}.
+
+        @param keys: specific attributes to retrieve
+        @type keys: L{list} of L{str}
+
+        @return: result
+        @rtype: L{dict}
+        """
+
+        keys = CFArrayRef.fromList([CFStringRef.fromString(key) for key in keys])
+        error = ffi.new("CFErrorRef *")
+        details = od.ODNodeCopyDetails(self.ref(), keys.ref(), error)
+        if details == ffi.NULL:
+            error = CFErrorRef(error[0])
+            raise ODError("Unable to get node details: {}".format(error.error()))
+        details = CFDictionaryRef(details)
+        return details.toDict()
+
+
+    def record(self, recordType, recordName):
+        """
+        Get a record of the specified type with the specified record name.
+
+        @param recordType: OD record type
+        @type recordType: L{str}
+        @param recordName: record name
+        @type recordName: L{str}
+
+        @return: record
+        @rtype: L{ODRecord} or L{None}
+        """
+
+        recordType = CFStringRef.fromString(recordType)
+        recordName = CFStringRef.fromString(recordName)
+        record = od.ODNodeCopyRecord(self.ref(), recordType.ref(), recordName.ref(), ffi.NULL, ffi.NULL)
+        return ODRecord(record) if record != ffi.NULL else None
+
+
+
+class ODRecord(CFObjectRef):
+    """
+    Wraps a cffi/ODRecord object.
+    """
+
+    def details(self, attributes=None):
+        """
+        Return the record attributes as an L{dict}.
+
+        @param attributes: specific attributes to retrieve
+        @type attributes: L{list} of L{ffi.ODAttributeType}
+
+        @return: result
+        @rtype: L{dict}
+        """
+
+        attributes = CFArrayRef.fromList([CFStringRef.fromString(attribute) for attribute in attributes]) if attributes else CFObjectRef(None)
+        error = ffi.new("CFErrorRef *")
+        details = od.ODRecordCopyDetails(self.ref(), attributes.ref(), error)
+        if details == ffi.NULL:
+            error = CFErrorRef(error[0])
+            raise ODError("Unable to get record details: {}".format(error.error()))
+        details = CFDictionaryRef(details)
+        return details.toDict()
+
+
+    def verifyPassword(self, password):
+        """
+        Verify the password associated with this record.
+
+        @param password: password to check
+        @type password: L{str}
+
+        @return: whether or not the verification worked
+        @rtype: L{bool}
+        """
+
+        password = CFStringRef.fromString(password)
+        return od.ODRecordVerifyPassword(self.ref(), password.ref(), ffi.NULL)
+
+
+    def verifyPasswordExtended(self, authType, authItems):
+        """
+        Verify the authentication details associated with this record, using an extended
+        authentication type.
+
+        @param authType: password to check
+        @type authType: L{str}
+        @param authItems: items needed by the auth type
+        @type authItems: L{list} of L{str}
+
+        @return: whether or not the verification worked
+        @rtype: L{bool}
+        """
+        authType = CFStringRef.fromString(authType)
+        authItems = CFArrayRef.fromList([CFStringRef.fromString(item) for item in authItems])
+        return od.ODRecordVerifyPasswordExtended(self.ref(), authType.ref(), authItems.ref(), ffi.NULL, ffi.NULL, ffi.NULL)
+
+
+
+class ODQuery(CFObjectRef):
+    """
+    Wraps a cffi/ODQuery object.
+    """
+
+    @classmethod
+    def newQuery(cls, node, recordTypes, queryAttribute, matchType, queryValue, fetchAttributes, maxResults):
+        """
+        Create a new query.
+
+        @param node: the node to query
+        @type node: L{ODNode}
+        @param recordTypes: list of record types
+        @type recordTypes: L{list} of L{str}
+        @param queryAttribute: attribute to query or L{None} for complex query
+        @type queryAttribute: L{str} or L{None}
+        @param matchType: type of match
+        @type matchType: L{lib.ODMatchType}
+        @param queryValue: value to query for, or complex query string
+        @type queryValue: L{str}
+        @param fetchAttributes: list of attributes to return in matched records
+        @type fetchAttributes: L{list} of L{lib.ODAttributeType}
+        @param maxResults: maximum number of results to return
+        @type maxResults: L{int}
+
+        @return; the query
+        @rtype: L{ODQuery}
+        """
+        recordTypes = CFArrayRef.fromList([CFStringRef.fromString(recordType) for recordType in recordTypes])
+        queryAttribute = CFStringRef.fromString(queryAttribute) if queryAttribute is not None else CFObjectRef(None)
+        queryValue = CFStringRef.fromString(queryValue) if queryValue is not None else CFObjectRef(None)
+        fetchAttributes = CFArrayRef.fromList([CFStringRef.fromString(fetchAttribute) for fetchAttribute in fetchAttributes])
+        error = ffi.new("CFErrorRef *")
+        query = od.ODQueryCreateWithNode(
+            ffi.NULL, node.ref(), recordTypes.ref(),
+            queryAttribute.ref(), matchType, queryValue.ref(),
+            fetchAttributes.ref(), maxResults, error
+        )
+        if query == ffi.NULL:
+            error = CFErrorRef(error[0])
+            raise ODError("Unable to create query: {}".format(error.error()))
+        return ODQuery(query)
+
+
+    def results(self, allowPartial=False):
+        """
+        Return a list of L{ODRecords} matching the query.
+        """
+        error = ffi.new("CFErrorRef *")
+        results = od.ODQueryCopyResults(self.ref(), allowPartial, error)
+        if results == ffi.NULL:
+            error = CFErrorRef(error[0])
+            raise ODError("Unable to create query: {}".format(error.error()))
+        results = CFArrayRef(results)
+        return [ODRecord(result.ref(), owned=False) for result in results.toList()]

Added: OSXFrameworks/trunk/osx/test/__init__.py
===================================================================
--- OSXFrameworks/trunk/osx/test/__init__.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/test/__init__.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,15 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##

Added: OSXFrameworks/trunk/osx/test/data/binary_fmt.plist
===================================================================
(Binary files differ)


Property changes on: OSXFrameworks/trunk/osx/test/data/binary_fmt.plist
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: OSXFrameworks/trunk/osx/test/data/xml_fmt.plist
===================================================================
--- OSXFrameworks/trunk/osx/test/data/xml_fmt.plist	                        (rev 0)
+++ OSXFrameworks/trunk/osx/test/data/xml_fmt.plist	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+    <dict>
+        <key>English</key>
+        <string>Hello World!</string>
+        <key>Latin</key>
+        <string>Salve Mundi!</string>
+    </dict>
+</plist>

Added: OSXFrameworks/trunk/osx/test/test_cfarray.py
===================================================================
--- OSXFrameworks/trunk/osx/test/test_cfarray.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/test/test_cfarray.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,89 @@
+##
+# Copyright (c) 2010-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from ..corefoundation import CFArrayRef, CFStringRef
+import gc
+import unittest
+
+
+"""
+CFArrayRef tests.
+"""
+
+class CFArrayRefTestCase(unittest.TestCase):
+    """
+    Tests for L{CFArrayRef}.
+    """
+
+    def test_typeid(self):
+        """
+        Make sure L{CFArrayRef.instanceTypeId} returns the right value.
+        """
+
+        array = CFArrayRef.fromList((CFStringRef.fromString("abc"), CFStringRef.fromString("def"),))
+        self.assertEqual(array.instanceTypeId(), CFArrayRef.typeId())
+
+
+    def test_description(self):
+        """
+        Make sure L{CFArrayRef.description} is the correct string.
+        """
+
+        array = CFArrayRef.fromList((CFStringRef.fromString("abc"), CFStringRef.fromString("def"),))
+        self.assertTrue("CFArray" in array.description(), msg=array.description())
+
+
+    def test_retain(self):
+        """
+        Make sure L{CFArrayRef.retainCount} returns the correct value based on ownership.
+        """
+
+        array1 = CFArrayRef.fromList((CFStringRef.fromString("abc"), CFStringRef.fromString("def"),))
+        self.assertEqual(array1.retainCount(), 1)
+        array2 = CFArrayRef(array1.ref(), owned=False)
+        self.assertEqual(array1.retainCount(), 2)
+        self.assertEqual(array2.retainCount(), 2)
+        del array1
+        gc.collect()
+        self.assertEqual(array2.retainCount(), 1)
+
+
+    def test_to_from_list(self):
+        """
+        Make sure L{CFArrayRef.fromString} and L{CFArrayRef.toString} work properly.
+        """
+
+        array = CFArrayRef.fromList((CFStringRef.fromString("abc"), CFStringRef.fromString("def"),))
+        self.assertEqual(array.toList(), ["abc", "def", ])
+
+
+    def test_count(self):
+        """
+        Make sure L{CFArrayRef.count} returns the right number.
+        """
+
+        array = CFArrayRef.fromList((CFStringRef.fromString("abc"), CFStringRef.fromString("def"),))
+        self.assertEqual(array.count(), 2)
+
+
+    def test_valueAt(self):
+        """
+        Make sure L{CFArrayRef.valueAtIndex} returns the right number.
+        """
+
+        array = CFArrayRef.fromList((CFStringRef.fromString("abc"), CFStringRef.fromString("def"),))
+        self.assertEqual(array.valueAtIndex(0), "abc")
+        self.assertEqual(array.valueAtIndex(1), "def")

Added: OSXFrameworks/trunk/osx/test/test_cfdata.py
===================================================================
--- OSXFrameworks/trunk/osx/test/test_cfdata.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/test/test_cfdata.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,85 @@
+##
+# Copyright (c) 2010-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from ..corefoundation import CFDataRef
+import unittest
+import tempfile
+
+
+"""
+CFDataRef tests.
+"""
+
+class CFDataRefTestCase(unittest.TestCase):
+    """
+    Tests for L{CFDataRef}.
+    """
+
+    def test_typeid(self):
+        """
+        Make sure L{CFDataRef.instanceTypeId} returns the right value.
+        """
+
+        data = CFDataRef.fromString("abc")
+        self.assertEqual(data.instanceTypeId(), CFDataRef.typeId())
+
+
+    def test_description(self):
+        """
+        Make sure L{CFDataRef.description} is the correct string.
+        """
+
+        data = CFDataRef.fromString("abc")
+        self.assertTrue("CFData" in data.description())
+
+
+    def test_to_from_string(self):
+        """
+        Make sure L{CFDataRef.fromString} and L{CFDataRef.toString} work properly.
+        """
+
+        data = CFDataRef.fromString("abc")
+        self.assertEqual(data.toString(), "abc")
+
+
+    def test_count(self):
+        """
+        Make sure L{CFDataRef.count} returns correct length.
+        """
+
+        data = CFDataRef.fromString("abc")
+        self.assertEqual(data.count(), 3)
+
+
+    def test_binary(self):
+        """
+        Make sure L{CFDataRef.fromString} and L{CFDataRef.toString} work properly.
+        """
+
+        tmp = tempfile.mktemp()
+        with open(tmp, "w") as f:
+            for i in range(100):
+                f.write(chr(i))
+
+        with open(tmp, "r") as f:
+            binary = f.read()
+
+        data = CFDataRef.fromString(binary)
+        self.assertEqual(data.count(), 100)
+        result = data.toString()
+        self.assertEqual(len(result), 100)
+        for i in range(100):
+            self.assertEqual(result[i], chr(i))

Added: OSXFrameworks/trunk/osx/test/test_cfdictionary.py
===================================================================
--- OSXFrameworks/trunk/osx/test/test_cfdictionary.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/test/test_cfdictionary.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,75 @@
+##
+# Copyright (c) 2010-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from ..corefoundation import CFDictionaryRef, CFStringRef
+import unittest
+
+
+"""
+CFDictionaryRef tests.
+"""
+
+class CFDictionaryRefTestCase(unittest.TestCase):
+    """
+    Tests for L{CFDictionaryRef}.
+    """
+
+    def test_typeid(self):
+        """
+        Make sure L{CFDictionaryRef.instanceTypeId} returns the right value.
+        """
+
+        cfdict = CFDictionaryRef.fromDict({
+            CFStringRef.fromString("abc"): CFStringRef.fromString("1"),
+            CFStringRef.fromString("def"): CFStringRef.fromString("2"),
+        })
+        self.assertEqual(cfdict.instanceTypeId(), CFDictionaryRef.typeId())
+
+
+    def test_description(self):
+        """
+        Make sure L{CFDictionaryRef.description} is the correct string.
+        """
+
+        cfdict = CFDictionaryRef.fromDict({
+            CFStringRef.fromString("abc"): CFStringRef.fromString("1"),
+            CFStringRef.fromString("def"): CFStringRef.fromString("2"),
+        })
+        self.assertTrue("dict" in cfdict.description(), msg=cfdict.description())
+
+
+    def test_to_from_dict(self):
+        """
+        Make sure L{CFDictionaryRef.fromDict} and L{CFDictionaryRef.toDict} work properly.
+        """
+
+        cfdict = CFDictionaryRef.fromDict({
+            CFStringRef.fromString("abc"): CFStringRef.fromString("1"),
+            CFStringRef.fromString("def"): CFStringRef.fromString("2"),
+        })
+        self.assertEqual(cfdict.toDict(), {"abc": "1", "def": "2", })
+
+
+    def test_count(self):
+        """
+        Make sure L{CFDictionaryRef.count} returns the right number.
+        """
+
+        cfdict = CFDictionaryRef.fromDict({
+            CFStringRef.fromString("abc"): CFStringRef.fromString("1"),
+            CFStringRef.fromString("def"): CFStringRef.fromString("2"),
+        })
+        self.assertEqual(cfdict.count(), 2)

Added: OSXFrameworks/trunk/osx/test/test_cflocale.py
===================================================================
--- OSXFrameworks/trunk/osx/test/test_cflocale.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/test/test_cflocale.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,46 @@
+##
+# Copyright (c) 2010-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from ..utils import CFLocaleRef
+import unittest
+
+
+"""
+CFLocaleRef tests.
+"""
+
+class CFLocaleRefTestCase(unittest.TestCase):
+    """
+    Tests for L{CFLocaleRef}.
+    """
+
+    def test_typeid(self):
+        """
+        Make sure L{CFLocaleRef.instanceTypeId} returns the right value.
+        """
+
+        locale = CFLocaleRef.currentLocale()
+        self.assertEqual(locale.instanceTypeId(), CFLocaleRef.typeId())
+
+
+    def test_preferredLanguages(self):
+        """
+        Make sure L{CFLocaleRef.description} is the correct string.
+        """
+
+        langs = CFLocaleRef.preferredLanguages()
+        self.assertTrue(len(langs) > 0)
+        self.assertTrue(all([isinstance(lang, str) for lang in langs]))

Added: OSXFrameworks/trunk/osx/test/test_cfpropertylist.py
===================================================================
--- OSXFrameworks/trunk/osx/test/test_cfpropertylist.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/test/test_cfpropertylist.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,129 @@
+##
+# Copyright (c) 2010-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from ..corefoundation import CFArrayRef, CFDataRef, CFDictionaryRef, CFStringRef
+from ..utils import CFPropertyListRef
+import os
+import unittest
+
+"""
+CFPropertyListRef tests.
+"""
+
+class CFPropertyListRefTestCase(unittest.TestCase):
+    """
+    Tests for L{CFPropertyListRef}.
+    """
+
+    def test_readStringData(self):
+        """
+        Make sure L{CFPropertyListRef} can parse a string-only plist.
+        """
+
+        data = """<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+    <string>Hello World!</string>
+</plist>
+"""
+        dataref = CFDataRef.fromString(data)
+        plist = CFPropertyListRef.createFromData(dataref)
+        self.assertEqual(plist.instanceTypeId(), CFStringRef.typeId())
+        self.assertEqual(plist.toString(), "Hello World!")
+
+
+    def test_readArrayData(self):
+        """
+        Make sure L{CFPropertyListRef} can parse an array plist.
+        """
+
+        data = """<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+    <array>
+        <string>Hello World!</string>
+        <string>Salve Mundi!</string>
+    </array>
+</plist>
+"""
+        dataref = CFDataRef.fromString(data)
+        plist = CFPropertyListRef.createFromData(dataref)
+        self.assertEqual(plist.instanceTypeId(), CFArrayRef.typeId())
+        self.assertEqual(plist.count(), 2)
+        items = plist.toList()
+        self.assertEqual(len(items), 2)
+        self.assertEqual(items[0], "Hello World!")
+        self.assertEqual(items[1], "Salve Mundi!")
+
+
+    def test_readDictionaryData(self):
+        """
+        Make sure L{CFPropertyListRef} can parse a dict plist.
+        """
+
+        data = """<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+    <dict>
+        <key>English</key>
+        <string>Hello World!</string>
+        <key>Latin</key>
+        <string>Salve Mundi!</string>
+    </dict>
+</plist>
+"""
+        dataref = CFDataRef.fromString(data)
+        plist = CFPropertyListRef.createFromData(dataref)
+        self.assertEqual(plist.instanceTypeId(), CFDictionaryRef.typeId())
+        self.assertEqual(plist.count(), 2)
+        items = plist.toDict()
+        self.assertEqual(len(items), 2)
+        self.assertEqual(items["English"], "Hello World!")
+        self.assertEqual(items["Latin"], "Salve Mundi!")
+
+
+    dataDir = os.path.join(os.path.dirname(__file__), "data")
+
+    def test_readDictionaryXMLFile(self):
+        """
+        Make sure L{CFPropertyListRef} can parse a XML plist read from a file.
+        """
+
+        data = open(os.path.join(self.dataDir, "xml_fmt.plist")).read()
+        dataref = CFDataRef.fromString(data)
+        plist = CFPropertyListRef.createFromData(dataref)
+        self.assertEqual(plist.instanceTypeId(), CFDictionaryRef.typeId())
+        self.assertEqual(plist.count(), 2)
+        items = plist.toDict()
+        self.assertEqual(len(items), 2)
+        self.assertEqual(items["English"], "Hello World!")
+        self.assertEqual(items["Latin"], "Salve Mundi!")
+
+
+    def test_readDictionaryBinaryFile(self):
+        """
+        Make sure L{CFPropertyListRef} can parse a binary plist read from a file.
+        """
+
+        data = open(os.path.join(self.dataDir, "binary_fmt.plist")).read()
+        dataref = CFDataRef.fromString(data)
+        plist = CFPropertyListRef.createFromData(dataref)
+        self.assertEqual(plist.instanceTypeId(), CFDictionaryRef.typeId())
+        self.assertEqual(plist.count(), 2)
+        items = plist.toDict()
+        self.assertEqual(len(items), 2)
+        self.assertEqual(items["English"], "Hello World!")
+        self.assertEqual(items["Latin"], "Salve Mundi!")

Added: OSXFrameworks/trunk/osx/test/test_cfstring.py
===================================================================
--- OSXFrameworks/trunk/osx/test/test_cfstring.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/test/test_cfstring.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,91 @@
+##
+# Copyright (c) 2010-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from ..corefoundation import CFStringRef
+import gc
+import unittest
+
+
+"""
+CFStringRef tests.
+"""
+
+class CFStringRefTestCase(unittest.TestCase):
+    """
+    Tests for L{CFStringRef}.
+    """
+
+    def test_typeid(self):
+        """
+        Make sure L{CFStringRef.instanceTypeId} returns the right value.
+        """
+
+        str = CFStringRef.fromString("abc")
+        self.assertEqual(str.instanceTypeId(), CFStringRef.typeId())
+
+
+    def test_description(self):
+        """
+        Make sure L{CFStringRef.description} is the correct string.
+        """
+
+        str = CFStringRef.fromString("abc")
+        self.assertTrue("CFString" in str.description())
+
+
+    def test_retain(self):
+        """
+        Make sure L{CFStringRef.retainCount} returns the correct value based on ownership.
+        """
+
+        str1 = CFStringRef.fromString("abc")
+        self.assertEqual(str1.retainCount(), 1)
+
+        # In this case copy actually uses the same original object but bumps the retain count
+        str2 = str1.copy()
+        self.assertEqual(str1.retainCount(), 2)
+        self.assertEqual(str2.retainCount(), 2)
+        del str1
+        gc.collect()
+        self.assertEqual(str2.retainCount(), 1)
+
+        str3 = CFStringRef.fromString("def")
+        self.assertEqual(str3.retainCount(), 1)
+        str4 = CFStringRef(str3.ref(), owned=False)
+        self.assertEqual(str3.retainCount(), 2)
+        self.assertEqual(str4.retainCount(), 2)
+        del str3
+        gc.collect()
+        self.assertEqual(str4.retainCount(), 1)
+
+
+    def test_to_from_string(self):
+        """
+        Make sure L{CFStringRef.fromString} and L{CFStringRef.toString} work properly.
+        """
+
+        str = CFStringRef.fromString("abc")
+        self.assertEqual(str.toString(), "abc")
+
+
+    def test_copy(self):
+        """
+        Make sure L{CFStringRef.copy} properly copies a string.
+        """
+
+        str = CFStringRef.fromString("abc")
+        str2 = str.copy()
+        self.assertEqual(str2.toString(), "abc")

Added: OSXFrameworks/trunk/osx/test/test_cftimezone.py
===================================================================
--- OSXFrameworks/trunk/osx/test/test_cftimezone.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/test/test_cftimezone.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,47 @@
+##
+# Copyright (c) 2010-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from ..utils import CFTimeZoneRef
+import unittest
+
+
+"""
+CFTimeZoneRef tests.
+"""
+
+class CFTimeZoneRefTestCase(unittest.TestCase):
+    """
+    Tests for L{CFTimeZoneRef}.
+    """
+
+    def test_typeid(self):
+        """
+        Make sure L{CFTimeZoneRef.instanceTypeId} returns the right value.
+        """
+
+        tz = CFTimeZoneRef.defaultTimeZone()
+        self.assertEqual(tz.instanceTypeId(), CFTimeZoneRef.typeId())
+
+
+    def test_name(self):
+        """
+        Make sure L{CFTimeZoneRef.description} is the correct string.
+        """
+
+        tz = CFTimeZoneRef.defaultTimeZone()
+        name = tz.name()
+        self.assertTrue(isinstance(name, str))
+        self.assertEqual(name, CFTimeZoneRef.defaultTimeZoneName())

Added: OSXFrameworks/trunk/osx/test/test_opendirectory.py
===================================================================
--- OSXFrameworks/trunk/osx/test/test_opendirectory.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/test/test_opendirectory.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,91 @@
+##
+# Copyright (c) 2010-2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from .._corefoundation import lib as od
+from ..opendirectory import ODSession, ODNode, ODRecord, ODQuery
+import unittest
+
+
+"""
+OpenDirectory tests.
+"""
+
+class OpenDirectoryTestCase(unittest.TestCase):
+    """
+    Tests for OpenDirectory cffi wrappers.
+    """
+
+    def test_session(self):
+        """
+        Make sure L{ODSession} works.
+        """
+
+        session = ODSession.defaultSession()
+        self.assertTrue(session is not None)
+
+
+    def test_nodeNames(self):
+        """
+        Make sure L{ODSession.nodeNames} returns a set of nodes.
+        """
+
+        session = ODSession.defaultSession()
+        names = session.nodeNames()
+        self.assertTrue(isinstance(names, list))
+        self.assertTrue("/Search" in names)
+
+
+    def test_node(self):
+        """
+        Make sure L{ODNode} returns a valid node.
+        """
+
+        session = ODSession.defaultSession()
+        node = ODNode(session, "/Search")
+        self.assertTrue(node is not None)
+        self.assertTrue(isinstance(node.details(["dsAttrTypeStandard:RecordType", ]), dict))
+
+
+    def test_record(self):
+        """
+        Make sure L{ODRecord} returns a valid node.
+        """
+
+        session = ODSession.defaultSession()
+        node = ODNode(session, "/Local/Default")
+        record = node.record("dsRecTypeStandard:Users", "_www")
+        self.assertTrue(isinstance(record, ODRecord))
+        self.assertTrue(isinstance(record.details(["dsAttrTypeStandard:RecordType", ]), dict))
+
+
+    def test_query(self):
+        """
+        Make sure L{ODQuery} returns records.
+        """
+
+        session = ODSession.defaultSession()
+        node = ODNode(session, "/Local/Default")
+        query = ODQuery.newQuery(
+            node, ["dsRecTypeStandard:Users"], "dsAttrTypeStandard:RealName",
+            od.kODMatchContains, "_",
+            ["dsAttrTypeStandard:UniqueID"], 100
+        )
+        self.assertTrue(isinstance(query, ODQuery))
+
+        results = query.results()
+        self.assertTrue(isinstance(results, list))
+        self.assertTrue(len(results) > 0)
+        self.assertTrue(isinstance(results[0], ODRecord), msg=results)

Added: OSXFrameworks/trunk/osx/utils.py
===================================================================
--- OSXFrameworks/trunk/osx/utils.py	                        (rev 0)
+++ OSXFrameworks/trunk/osx/utils.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,114 @@
+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+"""
+A set of Python classes that wrap miscellaneous CoreFoundation classes.
+"""
+
+from ._corefoundation import ffi, lib as cf
+from .corefoundation import CFObjectRef, CFStringRef, CFArrayRef, CFDictionaryRef, CFErrorRef, CFError
+
+
+class CFTimeZoneRef(CFObjectRef):
+    """
+    A wrapper for CFTimeZoneRef CoreFoundation objects.
+    """
+
+    @staticmethod
+    def typeId():
+        return cf.CFTimeZoneGetTypeID()
+
+
+    @classmethod
+    def defaultTimeZone(cls):
+        cftzref = cf.CFTimeZoneCopyDefault()
+        if cftzref == ffi.NULL:
+            raise CFError("Unable to create a CFTimeZoneRef")
+        return CFTimeZoneRef(cftzref)
+
+
+    @classmethod
+    def defaultTimeZoneName(cls):
+        tz = cls.defaultTimeZone()
+        return tz.name()
+
+
+    def name(self):
+        cfstr = CFStringRef(cf.CFTimeZoneGetName(self.ref()), owned=False)
+        return cfstr.toString()
+
+
+
+class CFLocaleRef(CFObjectRef):
+    """
+    A wrapper for CFLocaleRef CoreFoundation objects.
+    """
+
+    @staticmethod
+    def typeId():
+        return cf.CFLocaleGetTypeID()
+
+
+    @classmethod
+    def currentLocale(cls):
+        localeref = cf.CFLocaleCopyCurrent()
+        if localeref == ffi.NULL:
+            raise CFError("Unable to create a CFLocaleRef")
+        return CFLocaleRef(localeref)
+
+
+    @classmethod
+    def preferredLanguages(cls):
+        items = cf.CFLocaleCopyPreferredLanguages()
+        if items == ffi.NULL:
+            raise CFError("Unable to get CFLocale preferred languages")
+        items = CFArrayRef(items)
+        return items.toList()
+
+
+
+class CFPropertyListRef(CFObjectRef):
+    """
+    A wrapper for CFPropertyListRef CoreFoundation objects.
+    """
+
+    @staticmethod
+    def typeId():
+        # CFPropertyListRef is actually one of CFStringRef, CFArrayRef or CFDictionaryRef
+        return None
+
+
+    @classmethod
+    def createFromData(cls, data):
+        error = ffi.new("CFErrorRef *")
+        plist = cf.CFPropertyListCreateWithData(ffi.NULL, data.ref(), cf.kCFPropertyListImmutable, ffi.NULL, error)
+        if plist == ffi.NULL:
+            error = CFErrorRef(error[0])
+            raise CFError("Unable to create a CFPropertyListRef: {}".format(error.error()))
+
+        # Map to actual data type
+        plist = CFObjectRef(plist)
+        typeid = plist.instanceTypeId()
+        if typeid == CFStringRef.typeId():
+            plist = CFStringRef(plist.ref(), owned=False)
+        elif typeid == CFArrayRef.typeId():
+            plist = CFArrayRef(plist.ref(), owned=False)
+        elif typeid == CFDictionaryRef.typeId():
+            plist = CFDictionaryRef(plist.ref(), owned=False)
+        else:
+            raise CFError("Unknown CFPropertyListRef type id: {}".format(typeid))
+
+        return plist

Added: OSXFrameworks/trunk/setup.py
===================================================================
--- OSXFrameworks/trunk/setup.py	                        (rev 0)
+++ OSXFrameworks/trunk/setup.py	2015-10-21 20:02:01 UTC (rev 15204)
@@ -0,0 +1,34 @@
+##
+#    Copyright (c) 2015 Cyrus Daboo. All rights reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+##
+
+from distutils.core import setup
+from osx import _corefoundation_cffi_build
+
+setup(
+    name="OSXFrameworks",
+    version="0.1",
+    description="cffi wrappers for OS X APIs",
+    license="Apache 2.0",
+    platforms=["any"],
+    package_dir={'osx': 'osx'},
+    packages=[
+        'osx',
+        'osx.frameworks',
+    ],
+    ext_package="osx",
+    ext_modules=[_corefoundation_cffi_build.ffi.distutils_extension()],
+    setup_requires=["cffi>=1.2.0"],
+)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151021/aadfe1db/attachment-0001.html>


More information about the calendarserver-changes mailing list