|
|
@ -115,6 +115,8 @@ namespace DFHack
|
|
|
|
virtual void lua_item_read(lua_State *state, int fname_idx, void *ptr, int idx);
|
|
|
|
virtual void lua_item_read(lua_State *state, int fname_idx, void *ptr, int idx);
|
|
|
|
virtual void lua_item_write(lua_State *state, int fname_idx, void *ptr, int idx, int val_index);
|
|
|
|
virtual void lua_item_write(lua_State *state, int fname_idx, void *ptr, int idx, int val_index);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool is_readonly() { return false; }
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool resize(void *ptr, int size) { return false; }
|
|
|
|
virtual bool resize(void *ptr, int size) { return false; }
|
|
|
|
virtual bool erase(void *ptr, int index) { return false; }
|
|
|
|
virtual bool erase(void *ptr, int index) { return false; }
|
|
|
|
virtual bool insert(void *ptr, int index, void *pitem) { return false; }
|
|
|
|
virtual bool insert(void *ptr, int index, void *pitem) { return false; }
|
|
|
@ -343,6 +345,33 @@ namespace df
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
|
|
|
|
class ro_stl_container_identity : public container_identity {
|
|
|
|
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
ro_stl_container_identity(const char *name, type_identity *item, enum_identity *ienum = NULL)
|
|
|
|
|
|
|
|
: container_identity(sizeof(T), &allocator_fn<T>, item, ienum), name(name)
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string getFullName(type_identity *item) {
|
|
|
|
|
|
|
|
return name + container_identity::getFullName(item);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual bool is_readonly() { return true; }
|
|
|
|
|
|
|
|
virtual bool resize(void *ptr, int size) { return false; }
|
|
|
|
|
|
|
|
virtual bool erase(void *ptr, int size) { return false; }
|
|
|
|
|
|
|
|
virtual bool insert(void *ptr, int idx, void *item) { return false; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual int item_count(void *ptr, CountMode) { return ((T*)ptr)->size(); }
|
|
|
|
|
|
|
|
virtual void *item_pointer(type_identity *item, void *ptr, int idx) {
|
|
|
|
|
|
|
|
auto iter = (*(T*)ptr).begin();
|
|
|
|
|
|
|
|
for (; idx > 0; idx--) ++iter;
|
|
|
|
|
|
|
|
return (void*)&*iter;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class bit_array_identity : public bit_container_identity {
|
|
|
|
class bit_array_identity : public bit_container_identity {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -517,6 +546,10 @@ namespace df
|
|
|
|
static container_identity *get();
|
|
|
|
static container_identity *get();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<class T> struct identity_traits<std::set<T> > {
|
|
|
|
|
|
|
|
static container_identity *get();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<> struct identity_traits<BitArray<int> > {
|
|
|
|
template<> struct identity_traits<BitArray<int> > {
|
|
|
|
static bit_array_identity identity;
|
|
|
|
static bit_array_identity identity;
|
|
|
|
static bit_container_identity *get() { return &identity; }
|
|
|
|
static bit_container_identity *get() { return &identity; }
|
|
|
@ -579,6 +612,13 @@ namespace df
|
|
|
|
return &identity;
|
|
|
|
return &identity;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
|
|
|
|
inline container_identity *identity_traits<std::set<T> >::get() {
|
|
|
|
|
|
|
|
typedef std::set<T> container;
|
|
|
|
|
|
|
|
static ro_stl_container_identity<container> identity("set", identity_traits<T>::get());
|
|
|
|
|
|
|
|
return &identity;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
template<class T>
|
|
|
|
inline bit_container_identity *identity_traits<BitArray<T> >::get() {
|
|
|
|
inline bit_container_identity *identity_traits<BitArray<T> >::get() {
|
|
|
|
static bit_array_identity identity(identity_traits<T>::get());
|
|
|
|
static bit_array_identity identity(identity_traits<T>::get());
|
|
|
|