File: simple_typemaps.inc

package info (click to toggle)
pyopengl 2.0.1.08-5.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 19,484 kB
  • ctags: 9,036
  • sloc: pascal: 64,950; xml: 28,088; ansic: 20,696; python: 19,761; tcl: 668; makefile: 240; sh: 25
file content (139 lines) | stat: -rw-r--r-- 2,040 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**********  Simple input values **********/
%typemap(python, in) GLbyte, GLubyte, GLshort
{
	if (PyInt_Check($input) || PyLong_Check($input))
	{
		$1= ($1_type)(PyInt_AsLong( $input ));
	}
	else if (PyString_Check ($input))
	{
		/* what is a GLshort's size? */
		$1= ($1_type) PyString_AsString($input)[0];
	}
}

%typemap(python, in) GLboolean
{
	$1= (PyObject_IsTrue($input)) ? GL_TRUE : GL_FALSE;
}


%typemap(python, out) const GLubyte*
{
	if ($1) 
	{
	    $result= PyString_FromString($1); 
	}
	else 
	{
	    Py_INCREF($result = Py_None);
	}
}


%typemap(python, in) const void *buffer
{
	int len;
	PyObject* str;
	if ($input == Py_None) 
	{
		$1= NULL; 
	}
	else
	{
		str = PyObject_Str($input);
		PyString_AsStringAndSize(str, (char**)&$1, &len);
		Py_DECREF(str);
	}
}


%typemap(python, out) const wchar_t*
{
	if ($1) 
	{
	    $result = PyUnicode_FromWideChar($1, wcslen($1)); 
	}
	else 
	{
	    Py_INCREF($result= Py_None);
	}
}


%typemap(python,in) PyObject*, void*
{
	$1 = $input;
}

%typemap(python,out) PyObject*, void*
{
	$result= $1;
}

%typemap(python,in) PyObject* pyfunc
{
	if ($input != Py_None && !PyCallable_Check($input))
	{
		PyErr_SetString(PyExc_Exception, "Not callable.");
		return NULL;
	}
	$1 = $input;
}












%typemap(python,ignore) GLenum type_UNSIGNED_BYTE
{
	$1 = GL_UNSIGNED_BYTE;
}

%typemap(python,ignore) GLenum type_BYTE
{
	$1 = GL_BYTE;
}

%typemap(python,ignore) GLenum type_UNSIGNED_SHORT
{
	$1 = GL_UNSIGNED_SHORT;
}

%typemap(python,ignore) GLenum type_SHORT
{
	$1 = GL_SHORT;
}

%typemap(python,ignore) GLenum type_UNSIGNED_INT
{
	$1 = GL_UNSIGNED_INT;
}

%typemap(python,ignore) GLenum type_INT
{
	$1 = GL_INT;
}

%typemap(python,ignore) GLenum type_FLOAT
{
	$1 = GL_FLOAT;
}

%typemap(python,ignore) GLenum type_DOUBLE
{
	$1 = GL_DOUBLE;
}

%typemap(python,ignore) GLsizei stride_0, GLint stride_0, GLint ustride_0, GLint vstride_0
{
	$1 = 0;
}