start cereal wrappers (move to separate submodule in the future...)
This commit is contained in:
parent
50b09fa9c2
commit
fc48ae135f
3 changed files with 26 additions and 0 deletions
|
@ -9,10 +9,12 @@
|
||||||
from libcpp.memory cimport shared_ptr, make_shared, dynamic_pointer_cast
|
from libcpp.memory cimport shared_ptr, make_shared, dynamic_pointer_cast
|
||||||
from libcpp.string cimport string
|
from libcpp.string cimport string
|
||||||
from libcpp cimport bool
|
from libcpp cimport bool
|
||||||
|
from cython.operator cimport dereference as deref
|
||||||
from range cimport cpp_RangeBase
|
from range cimport cpp_RangeBase
|
||||||
from range_factory cimport cpp_RangeFactoryBase, cpp_CRangeFactory
|
from range_factory cimport cpp_RangeFactoryBase, cpp_CRangeFactory
|
||||||
from array cimport cpp_CArrayBase, cpp_MArray
|
from array cimport cpp_CArrayBase, cpp_MArray
|
||||||
from index cimport cpp_DIndex
|
from index cimport cpp_DIndex
|
||||||
|
from cereal cimport cpp_writeJSONFile
|
||||||
|
|
||||||
|
|
||||||
## ============
|
## ============
|
||||||
|
@ -152,3 +154,11 @@ def getSubRange(_range):
|
||||||
cdef Array_Range a = Array_Range()
|
cdef Array_Range a = Array_Range()
|
||||||
a.cpp_array = dynamic_pointer_cast[cpp_CArrayBase[shared_ptr[cpp_RangeBase]],cpp_MArray[shared_ptr[cpp_RangeBase]]] (make_shared[cpp_MArray[shared_ptr[cpp_RangeBase]]] (r.cpp_range.get().sub()) )
|
a.cpp_array = dynamic_pointer_cast[cpp_CArrayBase[shared_ptr[cpp_RangeBase]],cpp_MArray[shared_ptr[cpp_RangeBase]]] (make_shared[cpp_MArray[shared_ptr[cpp_RangeBase]]] (r.cpp_range.get().sub()) )
|
||||||
return a
|
return a
|
||||||
|
|
||||||
|
|
||||||
|
def writeJSONFile(_fname,_array):
|
||||||
|
cdef Array_Double a = _array
|
||||||
|
cdef shared_ptr[cpp_MArray[double]] ap = dynamic_pointer_cast[cpp_MArray[double],cpp_CArrayBase[double]](a.cpp_array)
|
||||||
|
cpp_writeJSONFile[double](_fname, deref(ap.get()))
|
||||||
|
|
||||||
|
|
||||||
|
|
15
cnorxz/base/cereal.pxd
Normal file
15
cnorxz/base/cereal.pxd
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
from libcpp.string cimport string
|
||||||
|
from array cimport cpp_MArray
|
||||||
|
|
||||||
|
cdef extern from "cereal/cnorxz_cereal.h" namespace "CNORXZ::cer":
|
||||||
|
cdef cppclass cpp_Format "CNORXZ::cer::Format":
|
||||||
|
pass
|
||||||
|
|
||||||
|
cdef extern from "cereal/cnorxz_cereal.h" namespace "CNORXZ::cer::Format":
|
||||||
|
cdef cpp_Format BINARY
|
||||||
|
cdef cpp_Format JSON
|
||||||
|
cdef cpp_Format XML
|
||||||
|
|
||||||
|
cdef extern from "cereal/cnorxz_cereal.h" namespace "CNORXZ::cer":
|
||||||
|
cdef void cpp_writeJSONFile "CNORXZ::cer::writeJSONFile" [T] (const string&, const cpp_MArray[T]&)
|
1
setup.py
1
setup.py
|
@ -60,6 +60,7 @@ if __name__ == "__main__":
|
||||||
sources = [
|
sources = [
|
||||||
"cnorxz/base/base.pyx",
|
"cnorxz/base/base.pyx",
|
||||||
],
|
],
|
||||||
|
define_macros=[('HAVE_CEREAL',None)],
|
||||||
**default_extension_args
|
**default_extension_args
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue