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
c90acb95
Commit
c90acb95
authored
Jul 04, 2001
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do conversion of CFStrings to/from unicode.
parent
d1054ef3
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
255 additions
and
43 deletions
+255
-43
Mac/Modules/cf/CFmodule.c
Mac/Modules/cf/CFmodule.c
+228
-43
Mac/Modules/cf/cfsupport.py
Mac/Modules/cf/cfsupport.py
+27
-0
No files found.
Mac/Modules/cf/CFmodule.c
View file @
c90acb95
This diff is collapsed.
Click to expand it.
Mac/Modules/cf/cfsupport.py
View file @
c90acb95
...
...
@@ -250,6 +250,15 @@ class CFStringRefObjectDefinition(MyGlobalObjectDefinition):
*p_itself = CFStringCreateWithCString((CFAllocatorRef)NULL, cStr, 0);
return 1;
}
if (PyUnicode_Check(v)) {
/* We use the CF types here, if Python was configured differently that will give an error */
CFIndex size = PyUnicode_GetSize(v);
UniChar *unichars = PyUnicode_AsUnicode(v);
if (!unichars) return 0;
*p_itself = CFStringCreateWithCharacters((CFAllocatorRef)NULL, unichars, size);
return 1;
}
"""
)
def
outputRepr
(
self
):
...
...
@@ -377,6 +386,24 @@ f = ManualGenerator("CFStringGetString", getasstring_body);
f
.
docstring
=
lambda
:
"() -> (string _rv)"
CFStringRef_object
.
add
(
f
)
getasunicode_body
=
"""
int size = CFStringGetLength(_self->ob_itself)+1;
Py_UNICODE *data = malloc(size*sizeof(Py_UNICODE));
CFRange range;
range.location = 0;
range.length = size;
if( data == NULL ) return PyErr_NoMemory();
CFStringGetCharacters(_self->ob_itself, range, data);
_res = (PyObject *)PyUnicode_FromUnicode(data, size);
free(data);
return _res;
"""
f
=
ManualGenerator
(
"CFStringGetUnicode"
,
getasunicode_body
);
f
.
docstring
=
lambda
:
"() -> (unicode _rv)"
CFStringRef_object
.
add
(
f
)
# ADD add forloop here
# generate output (open the output file as late as possible)
...
...
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