aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/~checkout~/code/nelns/agent_service/Attic/py_object_trans.cpp?rev=1.1&content-type=text/plain&hideattic=0/index.html
blob: 92f3b3044c76be711258b4e68221955fcc5b0a39 (plain)
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
#include "py_object_trans.h"
//#include "ag_compile.h"


namespace SRV
{
	static PyObject *commandSell(pyCPyEditWin *self, PyObject *arg)
	{
		char *txt;
		PyObject *argi;
		argi = PyTuple_GetItem (arg, 0);
		PyArg_Parse(argi,"s",&txt);
		txt[strlen(txt)] = 0;
		char command[1024*16];
#ifdef NL_DEBUG
		memset(command,0,sizeof(command));
#endif
		int i = 0,j = 0;

		while(txt[i] != 0)
		{
			if(txt[i] != '\n')
			{
				command[j] = txt[i];
				j ++;
			}
			else
			{
				command[j] = 0;
				self->Instance->commandSell(command);
				j = 0;				
			}
			i ++;			
		}					
		if(j)
		{
			command[j] = 0;
			self->Instance->commandSell(command);				
		}
		return Py_BuildValue("i",false);
	}

	static PyObject *coord(pyCPyEditWin *self, PyObject *arg)
	{
		char *txt;
		PyObject *argi;
		argi = PyTuple_GetItem (arg, 0);
		PyArg_Parse(argi,"s",&txt);
		//txt[strlen(txt)] = 0;
		char num[1024];		
#ifdef NL_DEBUG
		memset(num,0,sizeof(num));		
#endif
		int i = 0,j = 0;
		int x = -1,y = -1;
		while(txt[i] != 0)
		{
			if(txt[i] == '.')
			{
				num[j] = 0;
				x = atoi(num);
				j = 0;
				i++;
				break;
			}
			else
			{
				num[j ++] = txt[i];
			}
			i ++;
		}			

		while(1)
		{
			if(txt[i] == 0)
			{
				num[j] = 0;
				y = atoi(num);
				break;
			}
			else
			{
				num[j ++] = txt[i];
			}
			i ++;
		}			
		return Py_BuildValue("ii",x,y);
	}

	static PyMethodDef V_methods[] = 
	{	
		{"commandSell", (PyCFunction) commandSell, 	1, NULL},
		{"coord", (PyCFunction) coord, 	1, NULL},
		{NULL,		NULL}		/* sentinel */
	};
	
	static PyObject *getAttribDigitalType(pyCPyEditWin *self,char *name)
	{	
		return Py_FindMethod(V_methods, (PyObject *)self, name);
	}

	static void dealloc(pyCPyEditWin *self)
	{	
		delete self;
	}

	staticforward PyTypeObject V_Type = 
	{
		PyObject_HEAD_INIT(&PyType_Type)
		0,					/*ob_size*/
		"Shell",			/*tp_name*/
		sizeof(pyCPyEditWin),	/*tp_basicsize*/
		0,			/*tp_itemsize*/
		/* methods */
		(destructor)dealloc, /*tp_dealloc*/
		0,			/*tp_print*/
		(getattrfunc)getAttribDigitalType, /*tp_getattr*/
		0,
	/*	(setattrfunc)VConnection_setattr,*/ /*tp_setattr*/
		0,			/*tp_compare*/
		0,			/*tp_repr*/
		0,			/*tp_as_number*/
		0,			/*tp_as_sequence*/
		0,			/*tp_as_mapping*/
		0,			/*tp_hash*/
	};	

	pyCPyEditWin *allocPyEditWin(CPyEditWin *classType)
	{
		return NLAIC::CreatePyObjectInstance<CPyEditWin>(classType,&V_Type);
	}
}