/* Copyright 2016-2017 The MathWorks, Inc. */ #ifndef MATLAB_EXTDATA_HELPER_FUNCTIONS_HPP #define MATLAB_EXTDATA_HELPER_FUNCTIONS_HPP #include "publish_util.hpp" #include "FunctionType.hpp" #include #include #include MATLAB_EXTDATA_PUBLISHED_API_EXTERN_C void* get_function_ptr(int fcn); namespace matlab { namespace data { namespace impl { class ArrayImpl; } } } namespace matlab { namespace data { namespace detail { class Access { public: template static ImplT* getImpl(const ObjT& a) { return static_cast(a.pImpl.get()); } template static ImplT* getImplPtr(const ObjT& a) { return static_cast(a.pImpl); } template static matlab::data::impl::ArrayImpl* getImplForWorkspace(const ObjT& a) { typedef matlab::data::impl::ArrayImpl*(*ArrayGetImplForWorkspaceFcnPtr)(matlab::data::impl::ArrayImpl*); static const ArrayGetImplForWorkspaceFcnPtr fcn = (ArrayGetImplForWorkspaceFcnPtr)get_function_ptr(static_cast(detail::FunctionType::ARRAY_GET_IMPL_FOR_WORKSPACE)); return fcn(a.pImpl.get()); } template static Obj createObj(Impl* impl) { return Obj(impl); } template static Obj createObj(std::shared_ptr impl) { return Obj(impl); } template static Obj createObj(Impl* impl, T arg1) { return Obj(impl, arg1); } template static void releaseImplFromWorkspace(ImplT impl) { typedef void(*ArrayReleaseImplFromWorkspaceFcnPtr)(matlab::data::impl::ArrayImpl*); static const ArrayReleaseImplFromWorkspaceFcnPtr fcn = (ArrayReleaseImplFromWorkspaceFcnPtr) get_function_ptr(static_cast(detail::FunctionType::ARRAY_RELEASE_IMPL_FROM_WORKSPACE)); return fcn(impl); } }; } } } #endif