MCPcopy Create free account
hub / github.com/carbonengine/trinity / PyRegisterVariable

Function PyRegisterVariable

trinity/Tr2VariableStore_Blue.cpp:95–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95static PyObject* PyRegisterVariable( PyObject* self, PyObject* args )
96{
97 Tr2VariableStore* pThis = BluePythonCast<Tr2VariableStore*>( self );
98
99 const char* name;
100 PyObject* valueArg = NULL;
101 if( !PyArg_ParseTuple( args, "sO", &name, &valueArg ) )
102 {
103 return NULL;
104 }
105
106 TriVariable* variable = NULL;
107
108 float valFloat;
109 Vector2 valVector2;
110 Vector3 valVector3;
111 Vector4 valVector4;
112 Matrix valMatrix;
113 Color valColor;
114
115 if( ITr2TextureProvider* value = BluePythonCast<ITr2TextureProvider*>( valueArg ) )
116 {
117 variable = pThis->RegisterVariable( name, value );
118 }
119 else if( ITr2GpuBuffer* value = BluePythonCast<ITr2GpuBuffer*>( valueArg ) )
120 {
121 variable = pThis->RegisterVariable( name, value );
122 }
123 else if( PyVerCompat::IsPyInt( valueArg ) )
124 {
125 variable = pThis->RegisterVariable( name, FromPython<int>( valueArg ) );
126 }
127 else if( BlueExtractFloat( valueArg, valFloat ) )
128 {
129 variable = pThis->RegisterVariable( name, valFloat );
130 }
131 else if( BlueExtractVector( valueArg, &valVector2.x, 2 ) )
132 {
133 variable = pThis->RegisterVariable( name, valVector2 );
134 }
135 else if( BlueExtractVector( valueArg, &valVector3.x, 3 ) )
136 {
137 variable = pThis->RegisterVariable( name, valVector3 );
138 }
139 else if( BlueExtractVector( valueArg, &valVector4.x, 4 ) )
140 {
141 variable = pThis->RegisterVariable( name, valVector4 );
142 }
143 else if( BlueExtractMatrix( valueArg, &valMatrix.m[0][0], 16 ) )
144 {
145 variable = pThis->RegisterVariable( name, valMatrix );
146 }
147 else if( BlueExtractVector( valueArg, &valColor.r, 4 ) )
148 {
149 variable = pThis->RegisterVariable( name, valColor );
150 }
151 else if( valueArg == Py_None )
152 {

Callers

nothing calls this directly

Calls 3

IsPyIntFunction · 0.85
PyWrapVariableFunction · 0.85
RegisterVariableMethod · 0.80

Tested by

no test coverage detected