ยปCore Development>Code coverage>Modules/_ctypes/_ctypes_test.c

Python code coverage for Modules/_ctypes/_ctypes_test.c

#countcontent
1n/a#include <Python.h>
2n/a
3n/a#ifdef MS_WIN32
4n/a#include <windows.h>
5n/a#endif
6n/a
7n/a#if defined(MS_WIN32) || defined(__CYGWIN__)
8n/a#define EXPORT(x) __declspec(dllexport) x
9n/a#else
10n/a#define EXPORT(x) x
11n/a#endif
12n/a
13n/a/* some functions handy for testing */
14n/a
15n/aEXPORT(int)
16n/a_testfunc_cbk_reg_int(int a, int b, int c, int d, int e,
17n/a int (*func)(int, int, int, int, int))
18n/a{
19n/a return func(a*a, b*b, c*c, d*d, e*e);
20n/a}
21n/a
22n/aEXPORT(double)
23n/a_testfunc_cbk_reg_double(double a, double b, double c, double d, double e,
24n/a double (*func)(double, double, double, double, double))
25n/a{
26n/a return func(a*a, b*b, c*c, d*d, e*e);
27n/a}
28n/a
29n/a/*
30n/a * This structure should be the same as in test_callbacks.py and the
31n/a * method test_callback_large_struct. See issues 17310 and 20160: the
32n/a * structure must be larger than 8 bytes long.
33n/a */
34n/a
35n/atypedef struct {
36n/a unsigned long first;
37n/a unsigned long second;
38n/a unsigned long third;
39n/a} Test;
40n/a
41n/aEXPORT(void)
42n/a_testfunc_cbk_large_struct(Test in, void (*func)(Test))
43n/a{
44n/a func(in);
45n/a}
46n/a
47n/aEXPORT(void)testfunc_array(int values[4])
48n/a{
49n/a printf("testfunc_array %d %d %d %d\n",
50n/a values[0],
51n/a values[1],
52n/a values[2],
53n/a values[3]);
54n/a}
55n/a
56n/aEXPORT(long double)testfunc_Ddd(double a, double b)
57n/a{
58n/a long double result = (long double)(a * b);
59n/a printf("testfunc_Ddd(%p, %p)\n", &a, &b);
60n/a printf("testfunc_Ddd(%g, %g)\n", a, b);
61n/a return result;
62n/a}
63n/a
64n/aEXPORT(long double)testfunc_DDD(long double a, long double b)
65n/a{
66n/a long double result = a * b;
67n/a printf("testfunc_DDD(%p, %p)\n", &a, &b);
68n/a printf("testfunc_DDD(%Lg, %Lg)\n", a, b);
69n/a return result;
70n/a}
71n/a
72n/aEXPORT(int)testfunc_iii(int a, int b)
73n/a{
74n/a int result = a * b;
75n/a printf("testfunc_iii(%p, %p)\n", &a, &b);
76n/a return result;
77n/a}
78n/a
79n/aEXPORT(int)myprintf(char *fmt, ...)
80n/a{
81n/a int result;
82n/a va_list argptr;
83n/a va_start(argptr, fmt);
84n/a result = vprintf(fmt, argptr);
85n/a va_end(argptr);
86n/a return result;
87n/a}
88n/a
89n/aEXPORT(char *)my_strtok(char *token, const char *delim)
90n/a{
91n/a return strtok(token, delim);
92n/a}
93n/a
94n/aEXPORT(char *)my_strchr(const char *s, int c)
95n/a{
96n/a return strchr(s, c);
97n/a}
98n/a
99n/a
100n/aEXPORT(double) my_sqrt(double a)
101n/a{
102n/a return sqrt(a);
103n/a}
104n/a
105n/aEXPORT(void) my_qsort(void *base, size_t num, size_t width, int(*compare)(const void*, const void*))
106n/a{
107n/a qsort(base, num, width, compare);
108n/a}
109n/a
110n/aEXPORT(int *) _testfunc_ai8(int a[8])
111n/a{
112n/a return a;
113n/a}
114n/a
115n/aEXPORT(void) _testfunc_v(int a, int b, int *presult)
116n/a{
117n/a *presult = a + b;
118n/a}
119n/a
120n/aEXPORT(int) _testfunc_i_bhilfd(signed char b, short h, int i, long l, float f, double d)
121n/a{
122n/a/* printf("_testfunc_i_bhilfd got %d %d %d %ld %f %f\n",
123n/a b, h, i, l, f, d);
124n/a*/
125n/a return (int)(b + h + i + l + f + d);
126n/a}
127n/a
128n/aEXPORT(float) _testfunc_f_bhilfd(signed char b, short h, int i, long l, float f, double d)
129n/a{
130n/a/* printf("_testfunc_f_bhilfd got %d %d %d %ld %f %f\n",
131n/a b, h, i, l, f, d);
132n/a*/
133n/a return (float)(b + h + i + l + f + d);
134n/a}
135n/a
136n/aEXPORT(double) _testfunc_d_bhilfd(signed char b, short h, int i, long l, float f, double d)
137n/a{
138n/a/* printf("_testfunc_d_bhilfd got %d %d %d %ld %f %f\n",
139n/a b, h, i, l, f, d);
140n/a*/
141n/a return (double)(b + h + i + l + f + d);
142n/a}
143n/a
144n/aEXPORT(long double) _testfunc_D_bhilfD(signed char b, short h, int i, long l, float f, long double d)
145n/a{
146n/a/* printf("_testfunc_d_bhilfd got %d %d %d %ld %f %f\n",
147n/a b, h, i, l, f, d);
148n/a*/
149n/a return (long double)(b + h + i + l + f + d);
150n/a}
151n/a
152n/aEXPORT(char *) _testfunc_p_p(void *s)
153n/a{
154n/a return (char *)s;
155n/a}
156n/a
157n/aEXPORT(void *) _testfunc_c_p_p(int *argcp, char **argv)
158n/a{
159n/a return argv[(*argcp)-1];
160n/a}
161n/a
162n/aEXPORT(void *) get_strchr(void)
163n/a{
164n/a return (void *)strchr;
165n/a}
166n/a
167n/aEXPORT(char *) my_strdup(char *src)
168n/a{
169n/a char *dst = (char *)malloc(strlen(src)+1);
170n/a if (!dst)
171n/a return NULL;
172n/a strcpy(dst, src);
173n/a return dst;
174n/a}
175n/a
176n/aEXPORT(void)my_free(void *ptr)
177n/a{
178n/a free(ptr);
179n/a}
180n/a
181n/a#ifdef HAVE_WCHAR_H
182n/aEXPORT(wchar_t *) my_wcsdup(wchar_t *src)
183n/a{
184n/a size_t len = wcslen(src);
185n/a wchar_t *ptr = (wchar_t *)malloc((len + 1) * sizeof(wchar_t));
186n/a if (ptr == NULL)
187n/a return NULL;
188n/a memcpy(ptr, src, (len+1) * sizeof(wchar_t));
189n/a return ptr;
190n/a}
191n/a
192n/aEXPORT(size_t) my_wcslen(wchar_t *src)
193n/a{
194n/a return wcslen(src);
195n/a}
196n/a#endif
197n/a
198n/a#ifndef MS_WIN32
199n/a# ifndef __stdcall
200n/a# define __stdcall /* */
201n/a# endif
202n/a#endif
203n/a
204n/atypedef struct {
205n/a int (*c)(int, int);
206n/a int (__stdcall *s)(int, int);
207n/a} FUNCS;
208n/a
209n/aEXPORT(int) _testfunc_callfuncp(FUNCS *fp)
210n/a{
211n/a fp->c(1, 2);
212n/a fp->s(3, 4);
213n/a return 0;
214n/a}
215n/a
216n/aEXPORT(int) _testfunc_deref_pointer(int *pi)
217n/a{
218n/a return *pi;
219n/a}
220n/a
221n/a#ifdef MS_WIN32
222n/aEXPORT(int) _testfunc_piunk(IUnknown FAR *piunk)
223n/a{
224n/a piunk->lpVtbl->AddRef(piunk);
225n/a return piunk->lpVtbl->Release(piunk);
226n/a}
227n/a#endif
228n/a
229n/aEXPORT(int) _testfunc_callback_with_pointer(int (*func)(int *))
230n/a{
231n/a int table[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
232n/a
233n/a return (*func)(table);
234n/a}
235n/a
236n/aEXPORT(long long) _testfunc_q_bhilfdq(signed char b, short h, int i, long l, float f,
237n/a double d, long long q)
238n/a{
239n/a return (long long)(b + h + i + l + f + d + q);
240n/a}
241n/a
242n/aEXPORT(long long) _testfunc_q_bhilfd(signed char b, short h, int i, long l, float f, double d)
243n/a{
244n/a return (long long)(b + h + i + l + f + d);
245n/a}
246n/a
247n/aEXPORT(int) _testfunc_callback_i_if(int value, int (*func)(int))
248n/a{
249n/a int sum = 0;
250n/a while (value != 0) {
251n/a sum += func(value);
252n/a value /= 2;
253n/a }
254n/a return sum;
255n/a}
256n/a
257n/aEXPORT(long long) _testfunc_callback_q_qf(long long value,
258n/a long long (*func)(long long))
259n/a{
260n/a long long sum = 0;
261n/a
262n/a while (value != 0) {
263n/a sum += func(value);
264n/a value /= 2;
265n/a }
266n/a return sum;
267n/a}
268n/a
269n/atypedef struct {
270n/a char *name;
271n/a char *value;
272n/a} SPAM;
273n/a
274n/atypedef struct {
275n/a char *name;
276n/a int num_spams;
277n/a SPAM *spams;
278n/a} EGG;
279n/a
280n/aSPAM my_spams[2] = {
281n/a { "name1", "value1" },
282n/a { "name2", "value2" },
283n/a};
284n/a
285n/aEGG my_eggs[1] = {
286n/a { "first egg", 1, my_spams }
287n/a};
288n/a
289n/aEXPORT(int) getSPAMANDEGGS(EGG **eggs)
290n/a{
291n/a *eggs = my_eggs;
292n/a return 1;
293n/a}
294n/a
295n/atypedef struct tagpoint {
296n/a int x;
297n/a int y;
298n/a} point;
299n/a
300n/aEXPORT(int) _testfunc_byval(point in, point *pout)
301n/a{
302n/a if (pout) {
303n/a pout->x = in.x;
304n/a pout->y = in.y;
305n/a }
306n/a return in.x + in.y;
307n/a}
308n/a
309n/aEXPORT (int) an_integer = 42;
310n/a
311n/aEXPORT(int) get_an_integer(void)
312n/a{
313n/a return an_integer;
314n/a}
315n/a
316n/aEXPORT(double)
317n/aintegrate(double a, double b, double (*f)(double), long nstep)
318n/a{
319n/a double x, sum=0.0, dx=(b-a)/(double)nstep;
320n/a for(x=a+0.5*dx; (b-x)*(x-a)>0.0; x+=dx)
321n/a sum += f(x);
322n/a return sum/(double)nstep;
323n/a}
324n/a
325n/atypedef struct {
326n/a void (*initialize)(void *(*)(int), void(*)(void *));
327n/a} xxx_library;
328n/a
329n/astatic void _xxx_init(void *(*Xalloc)(int), void (*Xfree)(void *))
330n/a{
331n/a void *ptr;
332n/a
333n/a printf("_xxx_init got %p %p\n", Xalloc, Xfree);
334n/a printf("calling\n");
335n/a ptr = Xalloc(32);
336n/a Xfree(ptr);
337n/a printf("calls done, ptr was %p\n", ptr);
338n/a}
339n/a
340n/axxx_library _xxx_lib = {
341n/a _xxx_init
342n/a};
343n/a
344n/aEXPORT(xxx_library) *library_get(void)
345n/a{
346n/a return &_xxx_lib;
347n/a}
348n/a
349n/a#ifdef MS_WIN32
350n/a/* See Don Box (german), pp 79ff. */
351n/aEXPORT(void) GetString(BSTR *pbstr)
352n/a{
353n/a *pbstr = SysAllocString(L"Goodbye!");
354n/a}
355n/a#endif
356n/a
357n/a/*
358n/a * Some do-nothing functions, for speed tests
359n/a */
360n/aPyObject *py_func_si(PyObject *self, PyObject *args)
361n/a{
362n/a char *name;
363n/a int i;
364n/a if (!PyArg_ParseTuple(args, "si", &name, &i))
365n/a return NULL;
366n/a Py_RETURN_NONE;
367n/a}
368n/a
369n/aEXPORT(void) _py_func_si(char *s, int i)
370n/a{
371n/a}
372n/a
373n/aPyObject *py_func(PyObject *self, PyObject *args)
374n/a{
375n/a Py_RETURN_NONE;
376n/a}
377n/a
378n/aEXPORT(void) _py_func(void)
379n/a{
380n/a}
381n/a
382n/aEXPORT(long long) last_tf_arg_s;
383n/aEXPORT(unsigned long long) last_tf_arg_u;
384n/a
385n/astruct BITS {
386n/a int A: 1, B:2, C:3, D:4, E: 5, F: 6, G: 7, H: 8, I: 9;
387n/a short M: 1, N: 2, O: 3, P: 4, Q: 5, R: 6, S: 7;
388n/a};
389n/a
390n/aEXPORT(void) set_bitfields(struct BITS *bits, char name, int value)
391n/a{
392n/a switch (name) {
393n/a case 'A': bits->A = value; break;
394n/a case 'B': bits->B = value; break;
395n/a case 'C': bits->C = value; break;
396n/a case 'D': bits->D = value; break;
397n/a case 'E': bits->E = value; break;
398n/a case 'F': bits->F = value; break;
399n/a case 'G': bits->G = value; break;
400n/a case 'H': bits->H = value; break;
401n/a case 'I': bits->I = value; break;
402n/a
403n/a case 'M': bits->M = value; break;
404n/a case 'N': bits->N = value; break;
405n/a case 'O': bits->O = value; break;
406n/a case 'P': bits->P = value; break;
407n/a case 'Q': bits->Q = value; break;
408n/a case 'R': bits->R = value; break;
409n/a case 'S': bits->S = value; break;
410n/a }
411n/a}
412n/a
413n/aEXPORT(int) unpack_bitfields(struct BITS *bits, char name)
414n/a{
415n/a switch (name) {
416n/a case 'A': return bits->A;
417n/a case 'B': return bits->B;
418n/a case 'C': return bits->C;
419n/a case 'D': return bits->D;
420n/a case 'E': return bits->E;
421n/a case 'F': return bits->F;
422n/a case 'G': return bits->G;
423n/a case 'H': return bits->H;
424n/a case 'I': return bits->I;
425n/a
426n/a case 'M': return bits->M;
427n/a case 'N': return bits->N;
428n/a case 'O': return bits->O;
429n/a case 'P': return bits->P;
430n/a case 'Q': return bits->Q;
431n/a case 'R': return bits->R;
432n/a case 'S': return bits->S;
433n/a }
434n/a return 0;
435n/a}
436n/a
437n/astatic PyMethodDef module_methods[] = {
438n/a/* {"get_last_tf_arg_s", get_last_tf_arg_s, METH_NOARGS},
439n/a {"get_last_tf_arg_u", get_last_tf_arg_u, METH_NOARGS},
440n/a*/
441n/a {"func_si", py_func_si, METH_VARARGS},
442n/a {"func", py_func, METH_NOARGS},
443n/a { NULL, NULL, 0, NULL},
444n/a};
445n/a
446n/a#define S last_tf_arg_s = (long long)c
447n/a#define U last_tf_arg_u = (unsigned long long)c
448n/a
449n/aEXPORT(signed char) tf_b(signed char c) { S; return c/3; }
450n/aEXPORT(unsigned char) tf_B(unsigned char c) { U; return c/3; }
451n/aEXPORT(short) tf_h(short c) { S; return c/3; }
452n/aEXPORT(unsigned short) tf_H(unsigned short c) { U; return c/3; }
453n/aEXPORT(int) tf_i(int c) { S; return c/3; }
454n/aEXPORT(unsigned int) tf_I(unsigned int c) { U; return c/3; }
455n/aEXPORT(long) tf_l(long c) { S; return c/3; }
456n/aEXPORT(unsigned long) tf_L(unsigned long c) { U; return c/3; }
457n/aEXPORT(long long) tf_q(long long c) { S; return c/3; }
458n/aEXPORT(unsigned long long) tf_Q(unsigned long long c) { U; return c/3; }
459n/aEXPORT(float) tf_f(float c) { S; return c/3; }
460n/aEXPORT(double) tf_d(double c) { S; return c/3; }
461n/aEXPORT(long double) tf_D(long double c) { S; return c/3; }
462n/a
463n/a#ifdef MS_WIN32
464n/aEXPORT(signed char) __stdcall s_tf_b(signed char c) { S; return c/3; }
465n/aEXPORT(unsigned char) __stdcall s_tf_B(unsigned char c) { U; return c/3; }
466n/aEXPORT(short) __stdcall s_tf_h(short c) { S; return c/3; }
467n/aEXPORT(unsigned short) __stdcall s_tf_H(unsigned short c) { U; return c/3; }
468n/aEXPORT(int) __stdcall s_tf_i(int c) { S; return c/3; }
469n/aEXPORT(unsigned int) __stdcall s_tf_I(unsigned int c) { U; return c/3; }
470n/aEXPORT(long) __stdcall s_tf_l(long c) { S; return c/3; }
471n/aEXPORT(unsigned long) __stdcall s_tf_L(unsigned long c) { U; return c/3; }
472n/aEXPORT(long long) __stdcall s_tf_q(long long c) { S; return c/3; }
473n/aEXPORT(unsigned long long) __stdcall s_tf_Q(unsigned long long c) { U; return c/3; }
474n/aEXPORT(float) __stdcall s_tf_f(float c) { S; return c/3; }
475n/aEXPORT(double) __stdcall s_tf_d(double c) { S; return c/3; }
476n/aEXPORT(long double) __stdcall s_tf_D(long double c) { S; return c/3; }
477n/a#endif
478n/a/*******/
479n/a
480n/aEXPORT(signed char) tf_bb(signed char x, signed char c) { S; return c/3; }
481n/aEXPORT(unsigned char) tf_bB(signed char x, unsigned char c) { U; return c/3; }
482n/aEXPORT(short) tf_bh(signed char x, short c) { S; return c/3; }
483n/aEXPORT(unsigned short) tf_bH(signed char x, unsigned short c) { U; return c/3; }
484n/aEXPORT(int) tf_bi(signed char x, int c) { S; return c/3; }
485n/aEXPORT(unsigned int) tf_bI(signed char x, unsigned int c) { U; return c/3; }
486n/aEXPORT(long) tf_bl(signed char x, long c) { S; return c/3; }
487n/aEXPORT(unsigned long) tf_bL(signed char x, unsigned long c) { U; return c/3; }
488n/aEXPORT(long long) tf_bq(signed char x, long long c) { S; return c/3; }
489n/aEXPORT(unsigned long long) tf_bQ(signed char x, unsigned long long c) { U; return c/3; }
490n/aEXPORT(float) tf_bf(signed char x, float c) { S; return c/3; }
491n/aEXPORT(double) tf_bd(signed char x, double c) { S; return c/3; }
492n/aEXPORT(long double) tf_bD(signed char x, long double c) { S; return c/3; }
493n/aEXPORT(void) tv_i(int c) { S; return; }
494n/a
495n/a#ifdef MS_WIN32
496n/aEXPORT(signed char) __stdcall s_tf_bb(signed char x, signed char c) { S; return c/3; }
497n/aEXPORT(unsigned char) __stdcall s_tf_bB(signed char x, unsigned char c) { U; return c/3; }
498n/aEXPORT(short) __stdcall s_tf_bh(signed char x, short c) { S; return c/3; }
499n/aEXPORT(unsigned short) __stdcall s_tf_bH(signed char x, unsigned short c) { U; return c/3; }
500n/aEXPORT(int) __stdcall s_tf_bi(signed char x, int c) { S; return c/3; }
501n/aEXPORT(unsigned int) __stdcall s_tf_bI(signed char x, unsigned int c) { U; return c/3; }
502n/aEXPORT(long) __stdcall s_tf_bl(signed char x, long c) { S; return c/3; }
503n/aEXPORT(unsigned long) __stdcall s_tf_bL(signed char x, unsigned long c) { U; return c/3; }
504n/aEXPORT(long long) __stdcall s_tf_bq(signed char x, long long c) { S; return c/3; }
505n/aEXPORT(unsigned long long) __stdcall s_tf_bQ(signed char x, unsigned long long c) { U; return c/3; }
506n/aEXPORT(float) __stdcall s_tf_bf(signed char x, float c) { S; return c/3; }
507n/aEXPORT(double) __stdcall s_tf_bd(signed char x, double c) { S; return c/3; }
508n/aEXPORT(long double) __stdcall s_tf_bD(signed char x, long double c) { S; return c/3; }
509n/aEXPORT(void) __stdcall s_tv_i(int c) { S; return; }
510n/a#endif
511n/a
512n/a/********/
513n/a
514n/a#ifndef MS_WIN32
515n/a
516n/atypedef struct {
517n/a long x;
518n/a long y;
519n/a} POINT;
520n/a
521n/atypedef struct {
522n/a long left;
523n/a long top;
524n/a long right;
525n/a long bottom;
526n/a} RECT;
527n/a
528n/a#endif
529n/a
530n/aEXPORT(int) PointInRect(RECT *prc, POINT pt)
531n/a{
532n/a if (pt.x < prc->left)
533n/a return 0;
534n/a if (pt.x > prc->right)
535n/a return 0;
536n/a if (pt.y < prc->top)
537n/a return 0;
538n/a if (pt.y > prc->bottom)
539n/a return 0;
540n/a return 1;
541n/a}
542n/a
543n/aEXPORT(long left = 10);
544n/aEXPORT(long top = 20);
545n/aEXPORT(long right = 30);
546n/aEXPORT(long bottom = 40);
547n/a
548n/aEXPORT(RECT) ReturnRect(int i, RECT ar, RECT* br, POINT cp, RECT dr,
549n/a RECT *er, POINT fp, RECT gr)
550n/a{
551n/a /*Check input */
552n/a if (ar.left + br->left + dr.left + er->left + gr.left != left * 5)
553n/a {
554n/a ar.left = 100;
555n/a return ar;
556n/a }
557n/a if (ar.right + br->right + dr.right + er->right + gr.right != right * 5)
558n/a {
559n/a ar.right = 100;
560n/a return ar;
561n/a }
562n/a if (cp.x != fp.x)
563n/a {
564n/a ar.left = -100;
565n/a }
566n/a if (cp.y != fp.y)
567n/a {
568n/a ar.left = -200;
569n/a }
570n/a switch(i)
571n/a {
572n/a case 0:
573n/a return ar;
574n/a break;
575n/a case 1:
576n/a return dr;
577n/a break;
578n/a case 2:
579n/a return gr;
580n/a break;
581n/a
582n/a }
583n/a return ar;
584n/a}
585n/a
586n/atypedef struct {
587n/a short x;
588n/a short y;
589n/a} S2H;
590n/a
591n/aEXPORT(S2H) ret_2h_func(S2H inp)
592n/a{
593n/a inp.x *= 2;
594n/a inp.y *= 3;
595n/a return inp;
596n/a}
597n/a
598n/atypedef struct {
599n/a int a, b, c, d, e, f, g, h;
600n/a} S8I;
601n/a
602n/aEXPORT(S8I) ret_8i_func(S8I inp)
603n/a{
604n/a inp.a *= 2;
605n/a inp.b *= 3;
606n/a inp.c *= 4;
607n/a inp.d *= 5;
608n/a inp.e *= 6;
609n/a inp.f *= 7;
610n/a inp.g *= 8;
611n/a inp.h *= 9;
612n/a return inp;
613n/a}
614n/a
615n/aEXPORT(int) GetRectangle(int flag, RECT *prect)
616n/a{
617n/a if (flag == 0)
618n/a return 0;
619n/a prect->left = (int)flag;
620n/a prect->top = (int)flag + 1;
621n/a prect->right = (int)flag + 2;
622n/a prect->bottom = (int)flag + 3;
623n/a return 1;
624n/a}
625n/a
626n/aEXPORT(void) TwoOutArgs(int a, int *pi, int b, int *pj)
627n/a{
628n/a *pi += a;
629n/a *pj += b;
630n/a}
631n/a
632n/a#ifdef MS_WIN32
633n/aEXPORT(S2H) __stdcall s_ret_2h_func(S2H inp) { return ret_2h_func(inp); }
634n/aEXPORT(S8I) __stdcall s_ret_8i_func(S8I inp) { return ret_8i_func(inp); }
635n/a#endif
636n/a
637n/a#ifdef MS_WIN32
638n/a/* Should port this */
639n/a#include <stdlib.h>
640n/a#include <search.h>
641n/a
642n/aEXPORT (HRESULT) KeepObject(IUnknown *punk)
643n/a{
644n/a static IUnknown *pobj;
645n/a if (punk)
646n/a punk->lpVtbl->AddRef(punk);
647n/a if (pobj)
648n/a pobj->lpVtbl->Release(pobj);
649n/a pobj = punk;
650n/a return S_OK;
651n/a}
652n/a
653n/a#endif
654n/a
655n/a
656n/astatic struct PyModuleDef _ctypes_testmodule = {
657n/a PyModuleDef_HEAD_INIT,
658n/a "_ctypes_test",
659n/a NULL,
660n/a -1,
661n/a module_methods,
662n/a NULL,
663n/a NULL,
664n/a NULL,
665n/a NULL
666n/a};
667n/a
668n/aPyMODINIT_FUNC
669n/aPyInit__ctypes_test(void)
670n/a{
671n/a return PyModule_Create(&_ctypes_testmodule);
672n/a}