|
| 1 | + |
| 2 | +// AUTOGENERATED BY CSP_AUTOGEN |
| 3 | +// DO NOT MODIFY DIRECTLY |
| 4 | +// command: python csp/build/csp_autogen.py -m csp.adapters.websocket_types -d cpp/csp/adapters/websocket/csp_autogen/ -o websocket_types |
| 5 | + |
| 6 | +#include "websocket_types.h" |
| 7 | +#include <csp/python/Common.h> |
| 8 | +#include <csp/python/PyStruct.h> |
| 9 | +#include <csp/python/PyCspEnum.h> |
| 10 | +#include <iostream> |
| 11 | +#include <stdlib.h> |
| 12 | +#include <Python.h> |
| 13 | + |
| 14 | +namespace csp::autogen |
| 15 | +{ |
| 16 | + |
| 17 | +#define _offsetof( C, M ) ( ( char * ) &( ( C * ) nullptr ) -> M - ( char * ) 0 ) |
| 18 | + |
| 19 | +static void assert_or_die( bool assertion, const char * error ) |
| 20 | +{ |
| 21 | + if( !assertion ) |
| 22 | + { |
| 23 | + std::cerr << "Fatal error on import of " << __FILE__ << ": " << error << std::endl; |
| 24 | + if( PyErr_Occurred() ) |
| 25 | + PyErr_Print(); |
| 26 | + abort(); |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | + |
| 31 | +bool WebsocketStatus::static_init() |
| 32 | +{ |
| 33 | + if( Py_IsInitialized() ) |
| 34 | + { |
| 35 | + csp::python::AcquireGIL gil; |
| 36 | + |
| 37 | + // initialize EnumMeta from python type if we're in python |
| 38 | + PyObject * pymodule = PyImport_ImportModule( "csp.adapters.websocket_types" ); |
| 39 | + assert_or_die( pymodule != nullptr, "failed to import struct module csp.adapters.websocket_types" ); |
| 40 | + |
| 41 | + PyObject * enumType = PyObject_GetAttrString(pymodule, "WebsocketStatus" ); |
| 42 | + assert_or_die( enumType != nullptr, "failed to find num type WebsocketStatus in module csp.adapters.websocket_types" ); |
| 43 | + |
| 44 | + // should add some assertion here.. |
| 45 | + csp::python::PyCspEnumMeta * pymeta = ( csp::python::PyCspEnumMeta * ) enumType; |
| 46 | + s_meta = pymeta -> enumMeta; |
| 47 | + } |
| 48 | + |
| 49 | + return true; |
| 50 | +} |
| 51 | + |
| 52 | +bool static_init_WebsocketStatus = WebsocketStatus::static_init(); |
| 53 | +std::shared_ptr<csp::CspEnumMeta> WebsocketStatus::s_meta; |
| 54 | +WebsocketStatus WebsocketStatus::ACTIVE = WebsocketStatus::create("ACTIVE"); |
| 55 | +WebsocketStatus WebsocketStatus::GENERIC_ERROR = WebsocketStatus::create("GENERIC_ERROR"); |
| 56 | +WebsocketStatus WebsocketStatus::CONNECTION_FAILED = WebsocketStatus::create("CONNECTION_FAILED"); |
| 57 | +WebsocketStatus WebsocketStatus::CLOSED = WebsocketStatus::create("CLOSED"); |
| 58 | +WebsocketStatus WebsocketStatus::MESSAGE_SEND_FAIL = WebsocketStatus::create("MESSAGE_SEND_FAIL"); |
| 59 | + |
| 60 | + |
| 61 | +bool WebsocketHeaderUpdate::static_init() |
| 62 | +{ |
| 63 | + |
| 64 | + if( Py_IsInitialized() ) |
| 65 | + { |
| 66 | + //Note that windows requires we grab the GIL since the windows DLL loading code releases GIL |
| 67 | + csp::python::AcquireGIL gil; |
| 68 | + |
| 69 | + // initialize StructMeta from python type if we're in python |
| 70 | + PyObject * pymodule = PyImport_ImportModule( "csp.adapters.websocket_types" ); |
| 71 | + assert_or_die( pymodule != nullptr, "failed to import struct module csp.adapters.websocket_types" ); |
| 72 | + |
| 73 | + PyObject * structType = PyObject_GetAttrString(pymodule, "WebsocketHeaderUpdate" ); |
| 74 | + assert_or_die( structType != nullptr, "failed to find struct type WebsocketHeaderUpdate in module csp.adapters.websocket_types" ); |
| 75 | + |
| 76 | + // should add some assertion here.. |
| 77 | + csp::python::PyStructMeta * pymeta = ( csp::python::PyStructMeta * ) structType; |
| 78 | + s_meta = pymeta -> structMeta; |
| 79 | + } |
| 80 | + |
| 81 | + return true; |
| 82 | +} |
| 83 | + |
| 84 | +bool static_init_WebsocketHeaderUpdate = WebsocketHeaderUpdate::static_init(); |
| 85 | +csp::StructMetaPtr WebsocketHeaderUpdate::s_meta; |
| 86 | + |
| 87 | +} |
0 commit comments