10000 All changes wrapped by preprocessor directive PY33 to make backward c… · matplotlib/matplotlib@fe27462 · GitHub
[go: up one dir, main page]

Skip to content

Commit fe27462

Browse files
committed
All changes wrapped by preprocessor directive PY33 to make backward compatible.
1 parent 6433af0 commit fe27462

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

src/_macosx.m

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
#define PY3K 0
1212
#endif
1313

14+
#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >=3)
15+
#define PY33 1
16+
#else
17+
#define PY33 0
18+
#endif
19+
1420
/* Must define Py_TYPE for Python 2.5 or older */
1521
#ifndef Py_TYPE
1622
# define Py_TYPE(o) ((o)->ob_type)
@@ -2546,6 +2552,11 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
25462552
CTFontRef font;
25472553
CGColorRef color;
25482554
CGFloat descent;
2555+
#if PY33
2556+
const char* text;
2557+
#else
2558+
const UniChar* text;
2559+
#endif
25492560

25502561
CFStringRef keys[2];
25512562
CFTypeRef values[2];
@@ -2556,7 +2567,7 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
25562567
PyErr_SetString(PyExc_RuntimeError, "CGContextRef is NULL");
25572568
return NULL;
25582569
}
2559-
2570+
#if PY33
25602571
if(!PyArg_ParseTuple(args, "ffs#Ofssf",
25612572
&x,
25622573
&y,
@@ -2568,6 +2579,19 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
25682579
&italic,
25692580
&angle)) return NULL;
25702581
CFStringRef s = CFStringCreateWithCString(kCFAllocatorDefault, text, kCFStringEncodingUTF8);
2582+
#else
2583+
if(!PyArg_ParseTuple(args, "ffu#Ofssf",
2584+
&x,
2585+
&y,
2586+
&text,
2587+
&n,
2588+
&family,
2589+
&size,
2590+
&weight,
2591+
&italic,
2592+
&angle)) return NULL;
2593+
CFStringRef s = CFStringCreateWithCharacters(kCFAllocatorDefault, text, n);
2594+
#endif
25712595

25722596
font = setfont(cr, family, size, weight, italic);
25732597

@@ -2636,6 +2660,11 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
26362660
const char* text;
26372661
const char* weight;
26382662
const char* italic;
2663+
#if PY33
2664+
const char* text;
2665+
#else
2666+
const UniChar* text;
2667+
#endif
26392668

26402669
CGFloat ascent;
26412670
CGFloat descent;
@@ -2651,6 +2680,7 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
26512680
return NULL;
26522681
}
26532682

2683+
#if PY33
26542684
if(!PyArg_ParseTuple(args, "s#Ofss",
26552685
&text,
26562686
&n,
@@ -2659,6 +2689,16 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
26592689
&weight,
26602690
&italic)) return NULL;
26612691
CFStringRef s = CFStringCreateWithCString(kCFAllocatorDefault, text, kCFStringEncodingUTF8);
2692+
#else
2693+
if(!PyArg_ParseTuple(args, "u#Ofss",
2694+
& A3FF ;text,
2695+
&n,
2696+
&family,
2697+
&size,
2698+
&weight,
2699+
&italic)) return NULL;
2700+
CFStringRef s = CFStringCreateWithCharacters(kCFAllocatorDefault, text, n);
2701+
#endif
26622702

26632703
font = setfont(cr, family, size, weight, italic);
26642704

@@ -4902,7 +4942,7 @@ -(void)save_figure:(id)sender
49024942
unsigned int n = [filename length];
49034943
unichar* buffer = malloc(n*sizeof(unichar));
49044944
[filename getCharacters: buffer];
4905-
#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 3)
4945+
#if PY33
49064946
PyObject* string = PyUnicode_FromKindAndData(PyUnicode_2BYTE_KIND, buffer, n);
49074947
#else
49084948
PyObject* string = PyUnicode_FromUnicode(buffer, n);

0 commit comments

Comments
 (0)
0