xo-interpreter: add Primitive object, to expose builtin functions
This commit is contained in:
parent
ce6fa08abb
commit
aff30a1ee3
1 changed files with 9 additions and 2 deletions
|
|
@ -99,21 +99,28 @@ namespace xo {
|
||||||
*
|
*
|
||||||
* Example
|
* Example
|
||||||
* T * p = new T(...);
|
* T * p = new T(...);
|
||||||
* DestructorAux<T>::dtor(p);
|
* InvokerAux<T>::dtor(p);
|
||||||
**/
|
**/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct InvokerAux : public Invoker {
|
struct InvokerAux : public Invoker {
|
||||||
virtual void dtor(void * addr) const override {
|
virtual void dtor(void * addr) const override {
|
||||||
T * obj = static_cast<T *>(addr);
|
T * obj = reinterpret_cast<T *>(addr);
|
||||||
|
|
||||||
obj->~T();
|
obj->~T();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** no dtor for void **/
|
||||||
template<>
|
template<>
|
||||||
struct InvokerAux<void> : public Invoker {
|
struct InvokerAux<void> : public Invoker {
|
||||||
virtual void dtor(void *) const override {}
|
virtual void dtor(void *) const override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** no dtor for function types **/
|
||||||
|
template <typename Ret, typename... Args>
|
||||||
|
struct InvokerAux<Ret(Args...)> : public Invoker {
|
||||||
|
virtual void dtor(void *) const override {}
|
||||||
|
};
|
||||||
} /*namespace detail*/
|
} /*namespace detail*/
|
||||||
} /*namespace reflect*/
|
} /*namespace reflect*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue