xo-interpreter: ObjectConverter + VirtualSchmatikaMachineFlyweight
This commit is contained in:
parent
3956635920
commit
37b132821f
6 changed files with 187 additions and 20 deletions
34
xo-object/src/object/ObjectConverter.cpp
Normal file
34
xo-object/src/object/ObjectConverter.cpp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/** @file ObjectConverter.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Nov 2025
|
||||
**/
|
||||
|
||||
#include "ObjectConverter.hpp"
|
||||
#include "Integer.hpp"
|
||||
|
||||
namespace xo {
|
||||
using xo::reflect::TaggedPtr;
|
||||
using xo::gc::IAlloc;
|
||||
|
||||
namespace obj {
|
||||
namespace {
|
||||
template <typename T>
|
||||
gp<Object>
|
||||
int_to_object(IAlloc * mm, const TaggedPtr & src)
|
||||
{
|
||||
T * native = src.recover_native<T>();
|
||||
|
||||
assert(native);
|
||||
|
||||
return Integer::make(mm, *native);
|
||||
}
|
||||
}
|
||||
|
||||
ObjectConverter::ObjectConverter()
|
||||
{
|
||||
this->establish_conversion<std::int32_t>(&int_to_object<std::int32_t>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* end ObjectConverter.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue