Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/amulet/nbt/nbt_encoding/binary/bnbt.py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace NBT {

void init_bnbt(py::module& m)
{
py::class_<Amulet::NBT::ReadOffset> ReadOffset(m, "ReadOffset");
py::classh<Amulet::NBT::ReadOffset> ReadOffset(m, "ReadOffset");
ReadOffset.def(
py::init<const size_t>(),
py::arg("offset") = 0);
Expand Down
4 changes: 2 additions & 2 deletions src/amulet/nbt/string_encoding/encoding.py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace py = pybind11;

void init_encoding(py::module& m)
{
py::class_<Amulet::NBT::StringEncoding> StringEncoding(m, "StringEncoding");
py::classh<Amulet::NBT::StringEncoding> StringEncoding(m, "StringEncoding");
StringEncoding.def(
"encode",
[](const Amulet::NBT::StringEncoding& self, py::bytes data) -> py::bytes {
Expand All @@ -32,7 +32,7 @@ void init_encoding(py::module& m)
m.attr("utf8_escape_encoding") = utf8_escape_encoding;
m.attr("mutf8_encoding") = mutf8_encoding;

py::class_<Amulet::NBT::EncodingPreset> EncodingPreset(m, "EncodingPreset");
py::classh<Amulet::NBT::EncodingPreset> EncodingPreset(m, "EncodingPreset");
EncodingPreset.def_readonly(
"compressed",
&Amulet::NBT::EncodingPreset::compressed);
Expand Down
14 changes: 7 additions & 7 deletions src/amulet/nbt/tag/abc.py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void init_abc(py::module& m)
py::object mutf8_encoding = m.attr("mutf8_encoding");
py::object java_encoding = m.attr("java_encoding");

py::class_<Amulet::NBT::AbstractBaseTag> AbstractBaseTag(m, "AbstractBaseTag",
py::classh<Amulet::NBT::AbstractBaseTag> AbstractBaseTag(m, "AbstractBaseTag",
"Abstract Base Class for all tag classes");
AbstractBaseTag.def_property_readonly_static(
"tag_id",
Expand Down Expand Up @@ -131,14 +131,14 @@ void init_abc(py::module& m)
abstract_method<const Amulet::NBT::AbstractBaseTag&>,
"A string representation of the object.");

py::class_<Amulet::NBT::AbstractBaseImmutableTag, Amulet::NBT::AbstractBaseTag> AbstractBaseImmutableTag(m, "AbstractBaseImmutableTag",
py::classh<Amulet::NBT::AbstractBaseImmutableTag, Amulet::NBT::AbstractBaseTag> AbstractBaseImmutableTag(m, "AbstractBaseImmutableTag",
"Abstract Base Class for all tag classes");
AbstractBaseImmutableTag.def(
"__hash__",
abstract_method<const Amulet::NBT::AbstractBaseImmutableTag&>,
"A hash of the data in the class.");

py::class_<Amulet::NBT::AbstractBaseNumericTag, Amulet::NBT::AbstractBaseImmutableTag> AbstractBaseNumericTag(m, "AbstractBaseNumericTag",
py::classh<Amulet::NBT::AbstractBaseNumericTag, Amulet::NBT::AbstractBaseImmutableTag> AbstractBaseNumericTag(m, "AbstractBaseNumericTag",
"Abstract Base Class for all numeric tag classes");
AbstractBaseNumericTag.def(
"__int__",
Expand All @@ -153,7 +153,7 @@ void init_abc(py::module& m)
abstract_method<const Amulet::NBT::AbstractBaseNumericTag&>,
"Get a python bool representation of the class.");

py::class_<Amulet::NBT::AbstractBaseIntTag, Amulet::NBT::AbstractBaseNumericTag> AbstractBaseIntTag(m, "AbstractBaseIntTag",
py::classh<Amulet::NBT::AbstractBaseIntTag, Amulet::NBT::AbstractBaseNumericTag> AbstractBaseIntTag(m, "AbstractBaseIntTag",
"Abstract Base Class for all int tag classes");
AbstractBaseIntTag.def_property_readonly(
"py_int",
Expand All @@ -162,7 +162,7 @@ void init_abc(py::module& m)
"\n"
"The returned data is immutable so changes will not mirror the instance.");

py::class_<Amulet::NBT::AbstractBaseFloatTag, Amulet::NBT::AbstractBaseNumericTag> AbstractBaseFloatTag(m, "AbstractBaseFloatTag",
py::classh<Amulet::NBT::AbstractBaseFloatTag, Amulet::NBT::AbstractBaseNumericTag> AbstractBaseFloatTag(m, "AbstractBaseFloatTag",
"Abstract Base Class for all float tag classes.");
AbstractBaseFloatTag.def_property_readonly(
"py_float",
Expand All @@ -171,10 +171,10 @@ void init_abc(py::module& m)
"\n"
"The returned data is immutable so changes will not mirror the instance.");

py::class_<Amulet::NBT::AbstractBaseMutableTag, Amulet::NBT::AbstractBaseTag> AbstractBaseMutableTag(m, "AbstractBaseMutableTag",
py::classh<Amulet::NBT::AbstractBaseMutableTag, Amulet::NBT::AbstractBaseTag> AbstractBaseMutableTag(m, "AbstractBaseMutableTag",
"Abstract Base Class for all mutable tags.");
AbstractBaseMutableTag.attr("__hash__") = py::none();

py::class_<Amulet::NBT::AbstractBaseArrayTag, Amulet::NBT::AbstractBaseMutableTag> AbstractBaseArrayTag(m, "AbstractBaseArrayTag",
py::classh<Amulet::NBT::AbstractBaseArrayTag, Amulet::NBT::AbstractBaseMutableTag> AbstractBaseArrayTag(m, "AbstractBaseArrayTag",
"Abstract Base Class for all array tag classes.");
}
2 changes: 1 addition & 1 deletion src/amulet/nbt/tag/array.py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace py = pybind11;

#define PyArray(CLSNAME, ELEMENTCLS, BITCOUNT, TAGID) \
py::class_<Amulet::NBT::CLSNAME, std::shared_ptr<Amulet::NBT::CLSNAME>> CLSNAME(m, #CLSNAME, AbstractBaseArrayTag, py::buffer_protocol(), \
py::classh<Amulet::NBT::CLSNAME> CLSNAME(m, #CLSNAME, AbstractBaseArrayTag, py::buffer_protocol(), \
"This class stores a fixed size signed " #BITCOUNT " bit vector."); \
CLSNAME.def_property_readonly_static("tag_id", [](py::object) { return TAGID; }); \
CLSNAME.def( \
Expand Down
5 changes: 2 additions & 3 deletions src/amulet/nbt/tag/compound.py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ T new_tag()

void init_compound(py::module& m)
{
py::class_<Amulet::NBT::CompoundTagIterator> CompoundTagIterator(m, "CompoundTagIterator");
py::classh<Amulet::NBT::CompoundTagIterator> CompoundTagIterator(m, "CompoundTagIterator");
CompoundTagIterator.def(
"__next__",
[](Amulet::NBT::CompoundTagIterator& self) -> py::object {
Expand All @@ -117,8 +117,7 @@ void init_compound(py::module& m)
py::object mutf8_encoding = m.attr("mutf8_encoding");
py::object java_encoding = m.attr("java_encoding");

// py::class_<Amulet::NBT::CompoundTag, Amulet::NBT::AbstractBaseMutableTag, std::shared_ptr<Amulet::NBT::CompoundTag>> CompoundTag(m, "CompoundTag",
py::class_<Amulet::NBT::CompoundTag, std::shared_ptr<Amulet::NBT::CompoundTag>> CompoundTag(m, "CompoundTag", AbstractBaseMutableTag,
py::classh<Amulet::NBT::CompoundTag> CompoundTag(m, "CompoundTag", AbstractBaseMutableTag,
"A Python wrapper around a C++ unordered map.\n"
"\n"
"Note that this class is not thread safe and inherits all the limitations of a C++ unordered_map.");
Expand Down
2 changes: 1 addition & 1 deletion src/amulet/nbt/tag/float.py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace py = pybind11;

#define PyFloat(NATIVE, CLSNAME, PRECISION, TAGID) \
py::class_<Amulet::NBT::CLSNAME, Amulet::NBT::AbstractBaseFloatTag> CLSNAME(m, #CLSNAME, \
py::classh<Amulet::NBT::CLSNAME, Amulet::NBT::AbstractBaseFloatTag> CLSNAME(m, #CLSNAME, \
"A " #PRECISION " precision float class."); \
CLSNAME.def_property_readonly_static("tag_id", [](py::object) { return TAGID; }); \
CLSNAME.def( \
Expand Down
2 changes: 1 addition & 1 deletion src/amulet/nbt/tag/int.py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace py = pybind11;

#define PyInt(NATIVE, CLSNAME, BYTEWIDTH, BITPOW, SIGNBIT, MAGBITS, TAGID) \
py::class_<Amulet::NBT::CLSNAME, Amulet::NBT::AbstractBaseIntTag> CLSNAME(m, #CLSNAME, \
py::classh<Amulet::NBT::CLSNAME, Amulet::NBT::AbstractBaseIntTag> CLSNAME(m, #CLSNAME, \
"A " #BYTEWIDTH " byte integer class.\n" \
"\n" \
"Can Store numbers between -(2^" #BITPOW ") and (2^" #BITPOW " - 1)"); \
Expand Down
6 changes: 2 additions & 4 deletions src/amulet/nbt/tag/list.py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void ListTag_del_slice(std::vector<tagT>& self, const py::slice& slice)

void init_list(py::module& m)
{
py::class_<Amulet::NBT::ListTagIterator, std::shared_ptr<Amulet::NBT::ListTagIterator>> ListTagIterator(m, "ListTagIterator");
py::classh<Amulet::NBT::ListTagIterator> ListTagIterator(m, "ListTagIterator");
ListTagIterator.def(
"__next__",
[](Amulet::NBT::ListTagIterator& self) {
Expand All @@ -170,9 +170,7 @@ void init_list(py::module& m)
py::object java_encoding = m.attr("java_encoding");
py::object AbstractBaseMutableTag = m.attr("AbstractBaseMutableTag");

// py::class_<Amulet::NBT::ListTag, Amulet::NBT::AbstractBaseMutableTag, std::shared_ptr<Amulet::NBT::ListTag>> ListTag(m, "ListTag",
py::class_<Amulet::NBT::ListTag, std::shared_ptr<Amulet::NBT::ListTag>> ListTag(m, "ListTag", AbstractBaseMutableTag,
// py::class_<Amulet::NBT::ListTag, std::shared_ptr<Amulet::NBT::ListTag>> ListTag(m, "ListTag",
py::classh<Amulet::NBT::ListTag> ListTag(m, "ListTag", AbstractBaseMutableTag,
"A Python wrapper around a C++ vector.\n"
"\n"
"All contained data must be of the same NBT data type.");
Expand Down
4 changes: 2 additions & 2 deletions src/amulet/nbt/tag/named_tag.py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void init_named_tag(py::module& m)
py::object mutf8_encoding = m.attr("mutf8_encoding");
py::object java_encoding = m.attr("java_encoding");

py::class_<AmuletPy::NamedTagIterator> NamedTagIterator(m, "NamedTagIterator");
py::classh<AmuletPy::NamedTagIterator> NamedTagIterator(m, "NamedTagIterator");
NamedTagIterator.def(
"__next__",
&AmuletPy::NamedTagIterator::next);
Expand All @@ -65,7 +65,7 @@ void init_named_tag(py::module& m)
return self;
});

py::class_<Amulet::NBT::NamedTag, std::shared_ptr<Amulet::NBT::NamedTag>> NamedTag(m, "NamedTag");
py::classh<Amulet::NBT::NamedTag> NamedTag(m, "NamedTag");
NamedTag.def(
py::init([](std::variant<std::monostate, Amulet::NBT::TagNode> value, std::string name) {
return std::visit([&name](auto&& tag) {
Expand Down
2 changes: 1 addition & 1 deletion src/amulet/nbt/tag/string.py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void init_string(py::module& m)
py::object mutf8_encoding = m.attr("mutf8_encoding");
py::object java_encoding = m.attr("java_encoding");

py::class_<Amulet::NBT::StringTag, Amulet::NBT::AbstractBaseImmutableTag> StringTag(m, "StringTag",
py::classh<Amulet::NBT::StringTag, Amulet::NBT::AbstractBaseImmutableTag> StringTag(m, "StringTag",
"A class that behaves like a string.");
StringTag.def_property_readonly_static("tag_id", [](py::object) { return 8; });
StringTag.def(
Expand Down