Repository navigation
Expand file tree
/
Copy pathvector4.hpp
More file actions
137 lines (112 loc) · 4.08 KB
/
Copy pathvector4.hpp
File metadata and controls
137 lines (112 loc) · 4.08 KB
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
/*
This source file is part of KBEngine
For the latest info, see http://www.kbengine.org/
Copyright (c) 2008-2012 KBEngine.
KBEngine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KBEngine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SCRIPT_VECTOR4_H
#define _SCRIPT_VECTOR4_H
#include "cstdkbe/cstdkbe.hpp"
#include "math/math.hpp"
#include "scriptobject.hpp"
#include "pickler.hpp"
namespace KBEngine{ namespace script{
class ScriptVector4 : public ScriptObject
{
/** 子类化 将一些py操作填充进派生类 */
INSTANCE_SCRIPT_HREADER(ScriptVector4, ScriptObject)
public:
static PySequenceMethods seqMethods;
static PyNumberMethods numberMethods;
ScriptVector4(Vector4 v);
ScriptVector4(Vector4* v);
ScriptVector4(float x, float y, float z, float w);
virtual ~ScriptVector4();
/**
获得对象的描述
*/
PyObject* tp_repr();
PyObject* tp_str();
/**
脚本模块对象从python中创建
*/
static PyObject* tp_new(PyTypeObject* type, PyObject* args, PyObject* kwds);
/**
seq相关操作
*/
static Py_ssize_t seq_length(PyObject* self);
static PyObject* seq_item(PyObject* self, Py_ssize_t index);
static PyObject* seq_slice(PyObject* self, Py_ssize_t startIndex, Py_ssize_t endIndex);
static int seq_ass_item(PyObject* self, Py_ssize_t index, PyObject* value);
/**
加减乘除相关操作
*/
static PyObject* py_add(PyObject *a, PyObject *b);
static PyObject* py_subtract(PyObject *a, PyObject *b);
static PyObject* py_multiply(PyObject *a, PyObject *b);
static PyObject* py_divide(PyObject *a, PyObject *b);
static PyObject* py_negative(PyObject *self);
static PyObject* py_positive(PyObject *self);
static int py_nonzero(PyObject *self);
static PyObject* py_inplace_add(PyObject *self, PyObject *b);
static PyObject* py_inplace_subtract(PyObject *self, PyObject *b);
static PyObject* py_inplace_multiply(PyObject *self, PyObject *b);
static PyObject* py_inplace_divide(PyObject *self, PyObject *b);
/**
暴漏一些方法
*/
static PyObject* __py_pyDistTo(PyObject* self, PyObject* args);
static PyObject* __py_pyDistSqrTo(PyObject* self, PyObject* args);
static PyObject* __py_pyScale(PyObject* self, PyObject* args);
static PyObject* __py_pyDot(PyObject* self, PyObject* args);
static PyObject* __py_pyNormalise(PyObject* self, PyObject* args);
static PyObject* __py_pyTuple(PyObject* self, PyObject* args);
static PyObject* __py_pyList(PyObject* self, PyObject* args);
static PyObject* __py_pySet(PyObject* self, PyObject* args);
DECLARE_PY_GET_MOTHOD(pyGetVectorLength);
DECLARE_PY_GET_MOTHOD(pyGetVectorLengthSquared);
DECLARE_PY_GETSET_MOTHOD(pyGetX, pySetX);
DECLARE_PY_GETSET_MOTHOD(pyGetY, pySetY);
DECLARE_PY_GETSET_MOTHOD(pyGetZ, pySetZ);
DECLARE_PY_GETSET_MOTHOD(pyGetW, pySetW);
/**
支持pickler 方法
*/
static PyObject* __reduce_ex__(PyObject* self, PyObject* protocol);
/**
unpickle方法
*/
static PyObject* __unpickle__(PyObject* self, PyObject* args);
/**
脚本被安装时被调用
*/
static void onInstallScript(PyObject* mod);
int length(void){ return VECTOR_SIZE; }
Vector4& getVector(void){ return *val_; }
void setVector(const Vector4& v){ *val_ = v; }
/**
检查某个python对象是否可以转换为本类型
*/
static bool check(PyObject* value, bool isPrintErr = true);
/**
将某个经过check检查过的python对象转换为vector4
*/
static void convertPyObjectToVector4(Vector4& v, PyObject* obj);
private:
Vector4* val_;
bool isCopy_;
bool isReadOnly_;
static const int VECTOR_SIZE;
} ;
}
}
#endif