]> git.localhorst.tv Git - l2e.git/blobdiff - src/loader/TypeDescription.cpp
added constructors for described types
[l2e.git] / src / loader / TypeDescription.cpp
index 07be7b29f165dd091e36d78e292851377546c858..ed88e8ec8eedee6e3d4f83d482ae7008f39e0440 100644 (file)
@@ -8,6 +8,7 @@
 #include "TypeDescription.h"
 
 #include <cassert>
+#include <cstring>
 #include <stdexcept>
 
 using std::map;
@@ -37,6 +38,14 @@ const FieldDescription &TypeDescription::GetField(const std::string &n) const {
        }
 }
 
+void TypeDescription::Construct(void *data) const {
+       if (constructor) {
+               (*constructor)(data);
+       } else {
+               std::memset(data, 0, Size());
+       }
+}
+
 
 void TypeDescription::AddSupertype(int id, std::ptrdiff_t offset) {
        supertypes[id] = offset;