-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #255 from Point72/feature/fastlist
Implement FastList type for Struct list fields
- Loading branch information
Showing
19 changed files
with
1,974 additions
and
442 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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,43 @@ | ||
#ifndef _IN_CSP_PYTHON_PYSTRUCTFASTLIST_H | ||
#define _IN_CSP_PYTHON_PYSTRUCTFASTLIST_H | ||
|
||
#include <csp/python/Conversions.h> | ||
#include <csp/python/InitHelper.h> | ||
#include <csp/python/PyIterator.h> | ||
#include <csp/python/PyStruct.h> | ||
#include <csp/python/VectorWrapper.h> | ||
#include <Python.h> | ||
#include <vector> | ||
|
||
namespace csp::python | ||
{ | ||
|
||
template<typename StorageT> | ||
struct PyStructFastList : public PyObject | ||
{ | ||
using ElemT = typename CspType::Type::toCArrayElemType<StorageT>::type; | ||
|
||
PyStructFastList( PyStruct * p, std::vector<StorageT> & v, const CspType & type ) : pystruct( p ), vector( VectorWrapper<StorageT>( v ) ), arrayType( type ) | ||
{ | ||
Py_INCREF( pystruct ); | ||
} | ||
|
||
PyStruct * pystruct; // Pointer to PyStruct for proper reference counting | ||
VectorWrapper<StorageT> vector; // Field value for modifying | ||
|
||
const CspType & arrayType; // We require the type information of any non-primitive type, i.e. Struct or Enum, since they contain a meta | ||
static PyTypeObject PyType; | ||
static bool s_typeRegister; | ||
|
||
inline CspTypePtr elemType() const { return static_cast<const CspArrayType &>( arrayType ).elemType(); } | ||
|
||
inline PyObject * toPythonValue( const StorageT & value ) const; | ||
inline StorageT fromPythonValue( PyObject * value ) const; | ||
}; | ||
|
||
template<typename StorageT> bool PyStructFastList<StorageT>::s_typeRegister = InitHelper::instance().registerCallback( | ||
InitHelper::typeInitCallback( &PyStructFastList<StorageT>::PyType, "" ) ); | ||
|
||
} | ||
|
||
#endif |
Oops, something went wrong.