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

Function PythonSave

trinity/Tr2HostBitmap_Blue.cpp:207–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207static PyObject* PythonSave( PyObject* self, PyObject* args, bool async )
208{
209 Tr2HostBitmap* pThis = BluePythonCast<Tr2HostBitmap*>( self );
210
211 PyObject* file = nullptr;
212
213 if( !PyArg_ParseTuple( args, "O", &file ) )
214 {
215 PyErr_SetString( PyExc_TypeError, "Expected a filepath string" );
216 return nullptr;
217 }
218
219 std::wstring wcstr;
220 std::string cstr;
221 bool OK = false;
222 if( PyUnicode_Check( file ) && BlueExtractArgument( file, wcstr, 1 ) )
223 {
224 if( async )
225 {
226 OK = pThis->SaveAsync( wcstr.c_str() );
227 }
228 else
229 {
230 OK = pThis->Save( wcstr.c_str() );
231 }
232 }
233#if PY_MAJOR_VERSION == 2
234 else if( PyString_Check( file ) && BlueExtractArgument( file, cstr, 1 ) )
235 {
236 if( async )
237 {
238 OK = pThis->SaveAsync( (const wchar_t*)CA2W( cstr.c_str() ) );
239 }
240 else
241 {
242 OK = pThis->Save( (const wchar_t*)CA2W( cstr.c_str() ) );
243 }
244 }
245#endif
246 else
247 {
248 PyErr_SetString( PyExc_TypeError, "Expected a filepath string" );
249 return nullptr;
250 }
251
252 return PyBool_FromLong( OK );
253}

Callers 2

PySaveAsyncFunction · 0.70
PySaveFunction · 0.70

Calls 2

SaveAsyncMethod · 0.45
SaveMethod · 0.45

Tested by

no test coverage detected