Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6d207c09
Commit
6d207c09
authored
May 10, 2002
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Get data from CFData objects as Python strings and vv.
- Started on supporting CFPropertyLists.
parent
e037665f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
Mac/Modules/cf/cfscan.py
Mac/Modules/cf/cfscan.py
+5
-1
Mac/Modules/cf/cfsupport.py
Mac/Modules/cf/cfsupport.py
+29
-0
No files found.
Mac/Modules/cf/cfscan.py
View file @
6d207c09
...
...
@@ -15,6 +15,7 @@ OBJECTS = ("CFTypeRef",
"CFDictionaryRef"
,
"CFMutableDictionaryRef"
,
"CFStringRef"
,
"CFMutableStringRef"
,
"CFURLRef"
,
## "CFPropertyListRef",
)
# ADD object typenames here
...
...
@@ -31,7 +32,7 @@ def main():
## "CFNumber.h",
## "CFPlugIn.h",
## "CFPreferences.h",
##
"CFPropertyList.h",
"CFPropertyList.h"
,
## "CFSet.h",
"CFString.h"
,
## "CFStringEncodingExt.h",
...
...
@@ -130,6 +131,9 @@ class MyScanner(Scanner_OSX):
([(
"CFURLRef"
,
"baseURL"
,
"InMode"
)],
[(
"OptionalCFURLRef"
,
"*"
,
"*"
)]),
# We handle CFPropertyListRef objects as plain CFTypeRef
([(
"CFPropertyListRef"
,
"*"
,
"*"
)],
[(
"CFTypeRef"
,
"*"
,
"*"
)]),
]
if
__name__
==
"__main__"
:
...
...
Mac/Modules/cf/cfsupport.py
View file @
6d207c09
...
...
@@ -49,6 +49,7 @@ includestuff = includestuff + """
#include <CFDictionary.h>
#include <CFString.h>
#include <CFURL.h>
#include <CFPropertyList.h>
#else
#include <CoreServices/CoreServices.h>
#endif
...
...
@@ -195,6 +196,7 @@ CFStringRef = OpaqueByValueType("CFStringRef", "CFStringRefObj")
CFMutableStringRef
=
OpaqueByValueType
(
"CFMutableStringRef"
,
"CFMutableStringRefObj"
)
CFURLRef
=
OpaqueByValueType
(
"CFURLRef"
,
"CFURLRefObj"
)
OptionalCFURLRef
=
OpaqueByValueType
(
"CFURLRef"
,
"OptionalCFURLRefObj"
)
##CFPropertyListRef = OpaqueByValueType("CFPropertyListRef", "CFTypeRefObj")
# ADD object type here
# Our (opaque) objects
...
...
@@ -301,6 +303,18 @@ class CFMutableDictionaryRefObjectDefinition(MyGlobalObjectDefinition):
class
CFDataRefObjectDefinition
(
MyGlobalObjectDefinition
):
basechain
=
"&CFTypeRefObj_chain"
def
outputCheckConvertArg
(
self
):
Out
(
"""
if (v == Py_None) { *p_itself = NULL; return 1; }
if (PyString_Check(v)) {
char *cStr;
int cLen;
if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0;
*p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen);
return 1;
}
"""
)
def
outputRepr
(
self
):
Output
()
Output
(
"static PyObject * %s_repr(%s *self)"
,
self
.
prefix
,
self
.
objecttype
)
...
...
@@ -491,6 +505,21 @@ toPython_body = """
return PyCF_CF2Python(_self->ob_itself);
"""
# Get data from CFDataRef
getasdata_body
=
"""
int size = CFDataGetLength(_self->ob_itself);
char *data = (char *)CFDataGetBytePtr(_self->ob_itself);
_res = (PyObject *)PyString_FromStringAndSize(data, size);
return _res;
"""
f
=
ManualGenerator
(
"CFDataGetData"
,
getasdata_body
);
f
.
docstring
=
lambda
:
"() -> (string _rv)"
CFDataRef_object
.
add
(
f
)
f
=
ManualGenerator
(
"toPython"
,
toPython_body
);
f
.
docstring
=
lambda
:
"() -> (python_object)"
CFTypeRef_object
.
add
(
f
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment