-
Notifications
You must be signed in to change notification settings - Fork 55
Allow for autogen bypass, partial fix for #264 #252 #207, ref #303 #347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
timkpaine
wants to merge
3
commits into
main
Choose a base branch
from
tkp/autogen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
cpp/csp/adapters/websocket/csp_autogen/websocket_types.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
|
||
// AUTOGENERATED BY CSP_AUTOGEN | ||
// DO NOT MODIFY DIRECTLY | ||
// command: python csp/build/csp_autogen.py -m csp.adapters.websocket_types -d cpp/csp/adapters/websocket/csp_autogen/ -o websocket_types --omit_asserts | ||
|
||
#include "websocket_types.h" | ||
#include <csp/python/Common.h> | ||
#include <csp/python/PyStruct.h> | ||
#include <csp/python/PyCspEnum.h> | ||
#include <iostream> | ||
#include <stdlib.h> | ||
#include <Python.h> | ||
|
||
namespace csp::autogen | ||
{ | ||
|
||
#define _offsetof( C, M ) ( ( char * ) &( ( C * ) nullptr ) -> M - ( char * ) 0 ) | ||
|
||
static void assert_or_die( bool assertion, const char * error ) | ||
{ | ||
if( !assertion ) | ||
{ | ||
std::cerr << "Fatal error on import of " << __FILE__ << ": " << error << std::endl; | ||
if( PyErr_Occurred() ) | ||
PyErr_Print(); | ||
abort(); | ||
} | ||
} | ||
|
||
|
||
bool WebsocketStatus::static_init() | ||
{ | ||
if( Py_IsInitialized() ) | ||
{ | ||
csp::python::AcquireGIL gil; | ||
|
||
// initialize EnumMeta from python type if we're in python | ||
PyObject * pymodule = PyImport_ImportModule( "csp.adapters.websocket_types" ); | ||
assert_or_die( pymodule != nullptr, "failed to import struct module csp.adapters.websocket_types" ); | ||
|
||
PyObject * enumType = PyObject_GetAttrString(pymodule, "WebsocketStatus" ); | ||
assert_or_die( enumType != nullptr, "failed to find num type WebsocketStatus in module csp.adapters.websocket_types" ); | ||
|
||
// should add some assertion here.. | ||
csp::python::PyCspEnumMeta * pymeta = ( csp::python::PyCspEnumMeta * ) enumType; | ||
s_meta = pymeta -> enumMeta; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool static_init_WebsocketStatus = WebsocketStatus::static_init(); | ||
std::shared_ptr<csp::CspEnumMeta> WebsocketStatus::s_meta; | ||
WebsocketStatus WebsocketStatus::ACTIVE = WebsocketStatus::create("ACTIVE"); | ||
WebsocketStatus WebsocketStatus::GENERIC_ERROR = WebsocketStatus::create("GENERIC_ERROR"); | ||
WebsocketStatus WebsocketStatus::CONNECTION_FAILED = WebsocketStatus::create("CONNECTION_FAILED"); | ||
WebsocketStatus WebsocketStatus::CLOSED = WebsocketStatus::create("CLOSED"); | ||
WebsocketStatus WebsocketStatus::MESSAGE_SEND_FAIL = WebsocketStatus::create("MESSAGE_SEND_FAIL"); | ||
|
||
|
||
bool WebsocketHeaderUpdate::static_init() | ||
{ | ||
|
||
if( Py_IsInitialized() ) | ||
{ | ||
//Note that windows requires we grab the GIL since the windows DLL loading code releases GIL | ||
csp::python::AcquireGIL gil; | ||
|
||
// initialize StructMeta from python type if we're in python | ||
PyObject * pymodule = PyImport_ImportModule( "csp.adapters.websocket_types" ); | ||
assert_or_die( pymodule != nullptr, "failed to import struct module csp.adapters.websocket_types" ); | ||
|
||
PyObject * structType = PyObject_GetAttrString(pymodule, "WebsocketHeaderUpdate" ); | ||
assert_or_die( structType != nullptr, "failed to find struct type WebsocketHeaderUpdate in module csp.adapters.websocket_types" ); | ||
|
||
// should add some assertion here.. | ||
csp::python::PyStructMeta * pymeta = ( csp::python::PyStructMeta * ) structType; | ||
s_meta = pymeta -> structMeta; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool static_init_WebsocketHeaderUpdate = WebsocketHeaderUpdate::static_init(); | ||
csp::StructMetaPtr WebsocketHeaderUpdate::s_meta; | ||
|
||
} |
225 changes: 225 additions & 0 deletions
225
cpp/csp/adapters/websocket/csp_autogen/websocket_types.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
|
||
// AUTOGENERATED BY CSP_AUTOGEN | ||
// DO NOT MODIFY DIRECTLY | ||
// command: python csp/build/csp_autogen.py -m csp.adapters.websocket_types -d cpp/csp/adapters/websocket/csp_autogen/ -o websocket_types --omit_asserts | ||
|
||
#ifndef _IN_CSP_AUTOGEN_CSP_ADAPTERS_WEBSOCKET_TYPES | ||
#define _IN_CSP_AUTOGEN_CSP_ADAPTERS_WEBSOCKET_TYPES | ||
|
||
#include <csp/core/Exception.h> | ||
#include <csp/core/Platform.h> | ||
#include <csp/engine/Struct.h> | ||
#include <cstddef> | ||
|
||
namespace csp::autogen | ||
{ | ||
|
||
class WebsocketStatus : public csp::CspEnum | ||
{ | ||
public: | ||
// Raw value quick access | ||
enum class enum_ | ||
{ | ||
ACTIVE = 0, | ||
GENERIC_ERROR = 1, | ||
CONNECTION_FAILED = 2, | ||
CLOSED = 3, | ||
MESSAGE_SEND_FAIL = 4 | ||
}; | ||
|
||
// CspEnum types | ||
static WebsocketStatus ACTIVE; | ||
static WebsocketStatus GENERIC_ERROR; | ||
static WebsocketStatus CONNECTION_FAILED; | ||
static WebsocketStatus CLOSED; | ||
static WebsocketStatus MESSAGE_SEND_FAIL; | ||
|
||
const char * asCString() const { return name().c_str(); } | ||
const std::string & asString() const { return name(); } | ||
|
||
static WebsocketStatus create( enum_ v ) { return s_meta -> create( ( int64_t ) v ); } | ||
static WebsocketStatus create( const char * name) { return s_meta -> fromString( name ); } | ||
static WebsocketStatus create( const std::string & s ) { return create( s.c_str() ); } | ||
|
||
enum_ enum_value() const { return ( enum_ ) value(); } | ||
|
||
static constexpr uint32_t num_types() { return 5; } | ||
|
||
static bool static_init(); | ||
|
||
WebsocketStatus( const csp::CspEnum & v ) : csp::CspEnum( v ) { CSP_TRUE_OR_THROW( v.meta() == s_meta.get(), AssertionError, "Mismatched enum meta" ); } | ||
|
||
private: | ||
|
||
static std::shared_ptr<csp::CspEnumMeta> s_meta; | ||
}; | ||
|
||
class WebsocketHeaderUpdate : public csp::Struct | ||
{ | ||
public: | ||
|
||
using Ptr = csp::TypedStructPtr<WebsocketHeaderUpdate>; | ||
|
||
WebsocketHeaderUpdate() = delete; | ||
~WebsocketHeaderUpdate() = delete; | ||
WebsocketHeaderUpdate( const WebsocketHeaderUpdate & ) = delete; | ||
WebsocketHeaderUpdate( WebsocketHeaderUpdate && ) = delete; | ||
|
||
Ptr copy() const { return csp::structptr_cast<WebsocketHeaderUpdate>( Struct::copy() ); } | ||
|
||
static WebsocketHeaderUpdate::Ptr create() | ||
{ | ||
return Ptr( static_cast<WebsocketHeaderUpdate *>( s_meta -> createRaw() ) ); | ||
} | ||
|
||
static const csp::StructMetaPtr & meta() { return s_meta; } | ||
|
||
|
||
const std::string & key() const | ||
{ | ||
|
||
|
||
|
||
|
||
if( !key_isSet() ) | ||
CSP_THROW( csp::ValueError, "field key on struct WebsocketHeaderUpdate is not set" ); | ||
|
||
return m_key; | ||
} | ||
|
||
void set_key( const std::string & value ) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
m_WebsocketHeaderUpdate_mask[0] |= 1; | ||
|
||
|
||
//TODO employ move semantics where it makes sense | ||
m_key = value; | ||
} | ||
|
||
|
||
void set_key( const char * value ) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
m_WebsocketHeaderUpdate_mask[0] |= 1; | ||
|
||
m_key = value; | ||
} | ||
|
||
void set_key( std::string_view value ) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
m_WebsocketHeaderUpdate_mask[0] |= 1; | ||
|
||
m_key = value; | ||
} | ||
|
||
|
||
bool key_isSet() const | ||
{ | ||
|
||
return m_WebsocketHeaderUpdate_mask[0] & 1; | ||
} | ||
|
||
void clear_key() | ||
{ | ||
|
||
m_WebsocketHeaderUpdate_mask[0] &= ~1; | ||
} | ||
|
||
const std::string & value() const | ||
{ | ||
|
||
|
||
|
||
|
||
if( !value_isSet() ) | ||
CSP_THROW( csp::ValueError, "field value on struct WebsocketHeaderUpdate is not set" ); | ||
|
||
return m_value; | ||
} | ||
|
||
void set_value( const std::string & value ) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
m_WebsocketHeaderUpdate_mask[0] |= 2; | ||
|
||
|
||
//TODO employ move semantics where it makes sense | ||
m_value = value; | ||
} | ||
|
||
|
||
void set_value( const char * value ) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
m_WebsocketHeaderUpdate_mask[0] |= 2; | ||
|
||
m_value = value; | ||
} | ||
|
||
void set_value( std::string_view value ) | ||
{ | ||
|
||
|
||
|
||
|
||
|
||
m_WebsocketHeaderUpdate_mask[0] |= 2; | ||
|
||
m_value = value; | ||
} | ||
|
||
|
||
bool value_isSet() const | ||
{ | ||
|
||
return m_WebsocketHeaderUpdate_mask[0] & 2; | ||
} | ||
|
||
void clear_value() | ||
{ | ||
|
||
m_WebsocketHeaderUpdate_mask[0] &= ~2; | ||
} | ||
|
||
|
||
static bool static_init(); | ||
|
||
private: | ||
|
||
std::string m_key; | ||
std::string m_value; | ||
char m_WebsocketHeaderUpdate_mask[1]; | ||
|
||
|
||
static csp::StructMetaPtr s_meta; | ||
|
||
static void assert_mask() | ||
{ | ||
|
||
} | ||
}; | ||
|
||
} | ||
#endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.