File: command_wrapper.c

package info (click to toggle)
spring 106.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 55,316 kB
  • sloc: cpp: 543,954; ansic: 44,800; python: 12,575; java: 12,201; awk: 5,889; sh: 1,796; asm: 1,546; xml: 655; perl: 405; php: 211; objc: 194; makefile: 76; sed: 2
file content (44 lines) | stat: -rw-r--r-- 1,034 bytes parent folder | download | duplicates (7)
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
/* wrapper for command struct's */

static struct SAIFloat3*
build_SAIFloat3(PyObject* tpl)
{
	struct SAIFloat3* data=malloc(sizeof(struct SAIFloat3));
	data->x=PyFloat_AsDouble(PyTuple_GetItem(tpl, 0));
	data->y=PyFloat_AsDouble(PyTuple_GetItem(tpl, 1));
	data->z=PyFloat_AsDouble(PyTuple_GetItem(tpl, 2));
	return data;
}

void*
command_convert(int commandTopic, PyObject* command)
{
	void *data=NULL;
	switch (commandTopic) {
	{% for command in commands %}
		case {{command}}:
		{% exec cmd=commands[command] %}
		{% include os.path.join(templatedir, "create_command.c") %}
		break;
	{% endfor %}
	}
	return data;
}

PyObject*
command_reverse(int topic, void* data)
{
	switch (topic) {
	{% for command in commands %}
	{% exec structname="struct "+commands[command][0] %}
	{% exec members = commands[command][1] %}
	{% for member in members %}
	{% if "ret_" in member %}
		case {{command}}:
			return {{converter(members[member], "(("+structname+"*)data)->"+member)}};
	{% endif %}
	{% endfor %}
	{% endfor %}
	}
	return Py_None;
}