-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWraper.h
46 lines (44 loc) · 1018 Bytes
/
Wraper.h
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
#pragma once
#include "Interface.h"
#include "PyArray.h"
#include "PyDict.h"
inline void wrap_python_var(PyObject *item, CSimpleTypeVar* var)
{
if(var)
{
if(PyInt_Check(item))
{
var->type = CSimpleTypeVar::VAR_LONG;
var->lval = PyInt_AsLong(item);
}
else if(PyLong_Check(item))
{
var->type = CSimpleTypeVar::VAR_LONG;
var->lval = PyLong_AsLong(item);
}
else if(PyFloat_Check(item))
{
var->type = CSimpleTypeVar::VAR_FLOAT;
var->fval = PyFloat_AS_DOUBLE(item);
}
else if(PyString_Check(item))
{
var->type = CSimpleTypeVar::VAR_STRING;
PyString_AsStringAndSize(item, &(var->sval.str), (Py_ssize_t*)&(var->sval.str_l));
}
else if(PyDict_Check(item))
{
var->type = CSimpleTypeVar::VAR_DICT;
var->dval = new CPyDict(item);
}
else if(PySequence_Check(item))
{
var->type = CSimpleTypeVar::VAR_ARRAY;
var->aval = new CPyArray(item);
}
else
{
var->type = CSimpleTypeVar::VAR_NULL;
};
};
};