]> git.saurik.com Git - wxWidgets.git/blame - wxPython/wxSWIG/swig_lib/config/swigptr.swg
added renderer.h/.cpp
[wxWidgets.git] / wxPython / wxSWIG / swig_lib / config / swigptr.swg
CommitLineData
c90f71dd
RD
1/* swigptr.cfg
2 * $Header$
3 *
4 * This file contains two functions :
5 *
6 * void _swig_make_hex(char *_c, void *_ptr, char *type)
7 * char *_swig_get_hex(char *_c, void **ptr, char *type)
8 *
9 * These are used to convert pointers to and from pointer strings
10 * and to perform type checking.
11 *
12 * You can remap these functions by making a file called "swigptr.cfg" in
13 * your the same directory as the interface file you are wrapping.
14 *
15 * IMPORTANT !!! the function _swig_get_hex returns a non-null char pointer
16 * in the event of a type error (this is used to generate an error message).
17 * If a type is successfully parsed, a NULL pointer is returned.
18 *
19 * $Log$
20 * Revision 1.1 2002/04/29 19:56:50 RD
21 * Since I have made several changes to SWIG over the years to accomodate
22 * special cases and other things in wxPython, and since I plan on making
23 * several more, I've decided to put the SWIG sources in wxPython's CVS
24 * instead of relying on maintaining patches. This effectivly becomes a
25 * fork of an obsolete version of SWIG, :-( but since SWIG 1.3 still
26 * doesn't have some things I rely on in 1.1, not to mention that my
27 * custom patches would all have to be redone, I felt that this is the
28 * easier road to take.
29 *
30 * Revision 1.1.1.1 1999/02/28 02:00:53 beazley
31 * Swig1.1
32 *
33 * Revision 1.5 1996/08/01 16:28:56 dmb
34 * Took out unused "dt" variable.
35 *
36 * Revision 1.4 1996/07/23 14:38:42 dmb
37 * Minor change to handling of NULL pointers.
38 *
39 * Revision 1.3 1996/07/17 15:26:08 dmb
40 * Made a minor bug fix so pointers of form _0_Type could be used
41 * (as described in the manual). Disable by compiling with -DNO_ZERO.
42 *
43 * Revision 1.2 1996/06/10 23:42:10 beazley
44 * Added const qualifier.
45 *
46# Revision 1.1 1996/05/22 17:17:47 beazley
47# Initial revision
48#
49 */
50
51static void
52_swig_make_hex (char *_c, const void *_ptr, char *type)
53{
54 static char _hex[16] =
55 {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
56 'a', 'b', 'c', 'd', 'e', 'f'};
57 unsigned long _p, _s;
58 char _result[128], *_r;
59 _r = _result;
60 _p = (unsigned long) _ptr;
61 if (_p > 0)
62 {
63 while (_p > 0)
64 {
65 _s = _p & 0xf;
66 *(_r++) = _hex[_s];
67 _p = _p >> 4;
68 }
69 *_r = '_';
70 while (_r >= _result)
71 *(_c++) = *(_r--);
72 }
73 else
74 {
75 strcpy (_c, "NULL");
76 }
77 if (_ptr)
78 strcpy (_c, type);
79}
80
81/* A forward reference; */
82
83static char ***swig_ptr_derived = 0;
84
85static char *
86_swig_get_hex (char *_c, void **ptr, char *_t)
87{
88 unsigned long _p;
89 char temp_type[256];
90 char *_tt;
91 char **eq;
92 int i, j, n;
93 _p = 0;
94 if (*_c == '_')
95 {
96 _c++;
97 while (*_c)
98 {
99 if ((*_c >= '0') && (*_c <= '9'))
100 _p = (_p << 4) + (*_c - '0');
101 else if ((*_c >= 'a') && (*_c <= 'f'))
102 _p = (_p << 4) + ((*_c - 'a') + 10);
103 else
104 break;
105 _c++;
106 }
107#ifdef NO_ZERO
108 if (_p == 0)
109 {
110 return (char *) _c;
111 }
112#endif
113 _tt = _c;
114 if (_t)
115 {
116 if (strcmp (_c, _t))
117 {
118 /* Have a type mismatch, we're going to have to do some
119 searching here */
120 i = 0;
121 if (swig_ptr_derived)
122 {
123 while (swig_ptr_derived[i])
124 {
125 eq = swig_ptr_derived[i];
126 /* Check type */
127 if (strncmp (_t, eq[0], strlen (eq[0])) == 0)
128 {
129 /* Found derived type list for this. */
130 n = strlen (eq[0]);
131 j = 1;
132 while (eq[j])
133 {
134 sprintf (temp_type, "%s%s", eq[j], _t + n);
135 if (strcmp (_c, temp_type) == 0)
136 {
137 *ptr = (void *) _p;
138 return (char *) 0;
139 }
140 j++;
141 }
142 }
143 i++;
144 }
145 }
146 *ptr = (void *) _p;
147 return _tt;
148 }
149 else
150 {
151 *ptr = (void *) _p;
152 return (char *) 0;
153 }
154 }
155 else
156 {
157 *ptr = (void *) _p;
158 return (char *) 0;
159 }
160 }
161 else {
162#ifdef ALLOW_NULL
163 if (strcmp (_c, "NULL") == 0)
164 {
165 *ptr = (void *) 0;
166 return (char *) 0;
167 }
168#endif
169 *ptr = (void *) 0;
170 return _c;
171 }
172}