primitive_item.cpp (816B)
1 #include "primitive_item.hpp" 2 #include "context.hpp" 3 4 // factory 5 #include "stcm/data.hpp" 6 7 #include "primitive_item.binding.hpp" 8 9 namespace Neptools 10 { 11 #define NEPTOOLS_GEN(cname, lname, ...) template class __VA_ARGS__ 12 NEPTOOLS_PRIMITIVE_ITEMS(NEPTOOLS_GEN); 13 #undef NEPTOOLS_GEN 14 15 template <typename Item, int32_t TypeId> 16 static bool CheckFun(Stcm::DataItem& it) 17 { 18 if (it.type != TypeId || it.offset_unit != 1 || it.field_8 != 1) 19 return false; 20 auto child = dynamic_cast<RawItem*>(&it.GetChildren().front()); 21 if (child && child->GetSize() == sizeof(typename Item::Type)) 22 { 23 Item::CreateAndInsert({child, 0}); 24 return true; 25 } 26 return false; 27 } 28 29 static Stcm::DataFactory reg_int32{CheckFun<Int32Item, 0>}; 30 static Stcm::DataFactory reg_float{CheckFun<FloatItem, 1>}; 31 32 }