Swapped to using std::string from unsigned char* for ConstantUtf8Info.bytes

This commit is contained in:
calcium 2024-08-24 23:38:54 -04:00
parent ddba2b6d66
commit 47df116083
3 changed files with 5 additions and 4 deletions

View File

@ -4,7 +4,7 @@
#include <SpecTypes.h>
#include <cstdint>
#include <cstdlib>
#include <string>
struct JavaClassFormat;
@ -47,7 +47,7 @@ struct ConstantUtf8Info : ConstantPoolInfo
{
ConstantPoolTags::Tags tag;
u2 length;
unsigned char *bytes;
std::string bytes;
// std::vector<unsigned char> bytes;
};

View File

@ -163,7 +163,8 @@ int main(int argc, char **argv)
if (x == TYPE(ConstantPoolTags::ConstantUtf8Info))
{
std::cout << "utf8:\t" << std::any_cast<ConstantPoolTags::ConstantUtf8Info>(jc.constant_pool[i]).bytes << std::endl;
ConstantPoolTags::ConstantUtf8Info ref = std::any_cast<ConstantPoolTags::ConstantUtf8Info>(jc.constant_pool[i]);
std::cout << "utf8:\t" << "(length): " << ref.length.ToHostFormat() << ",\t(str): " << ref.bytes << std::endl;
}
else if (x == TYPE(ConstantPoolTags::ConstantClassInfo))
{

View File

@ -32,7 +32,7 @@ void Methods::MethodParser(method_info &p, JavaClassFormat &jc)
ASSERT(VEC_ELEM_TYPE(v) == TYPE(ConstantPoolTags::ConstantUtf8Info));
ConstantPoolTags::ConstantUtf8Info str = std::any_cast<ConstantPoolTags::ConstantUtf8Info>(v);
ASSERT(strcmp(reinterpret_cast<const char *>(str.bytes), "Code") == 0);
ASSERT(strcmp(str.bytes.c_str(), "Code") == 0);
u4 attribute_length = Utils::ReadFromStartIntoVal<uint32_t>(Globals::buffer());