Skip to content

Commit

Permalink
fix: fix molang & hashedstring bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Feb 8, 2024
1 parent 4e0391f commit 4e53ed4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/mc/deps/core/string/HashedString.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ class HashedString {
str(str),
lastMatch(nullptr) {} // NOLINT

[[nodiscard]] constexpr HashedString(std::string&& str) noexcept // NOLINT
: str(std::move(str)),
lastMatch(nullptr) {
hash = computeHash(str);
}
[[nodiscard]] constexpr HashedString(std::string&& s) noexcept // NOLINT
: hash(computeHash(s)),
str(std::move(s)),
lastMatch(nullptr) {}
[[nodiscard]] constexpr HashedString(char const* str) noexcept : HashedString(std::string{str}) {} // NOLINT

[[nodiscard]] constexpr HashedString(HashedString const& other) noexcept
Expand Down
2 changes: 1 addition & 1 deletion src/mc/util/molang/MolangMemberArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace mce { class Color; }

struct MolangMemberArray {
public:
std::unique_ptr<std::vector<MolangMemberVariable>> mMembers;
std::vector<MolangMemberVariable> mMembers;

public:
// prevent constructor by default
Expand Down
9 changes: 7 additions & 2 deletions src/mc/util/molang/MolangScriptArg.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,21 @@ struct MolangScriptArg {
MolangScriptArgPOD mPOD;
MolangScriptArgData mData;

template <class T>
MolangScriptArg(T const&) = delete;

MCTAPI MolangScriptArg(MolangMemberArray const&);

public:
// NOLINTBEGIN
// symbol: ??0MolangScriptArg@@QEAA@XZ
MCAPI MolangScriptArg();

// symbol: ??0MolangScriptArg@@QEAA@M@Z
MCAPI explicit MolangScriptArg(float);
MCAPI MolangScriptArg(float);

// symbol: ??0MolangScriptArg@@QEAA@H@Z
MCAPI explicit MolangScriptArg(int);
MCAPI MolangScriptArg(int);

// symbol: ??0MolangScriptArg@@QEAA@$$QEAU0@@Z
MCAPI MolangScriptArg(struct MolangScriptArg&&);
Expand Down
8 changes: 8 additions & 0 deletions src/mc/util/molang/MolangVariable.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#pragma once

#include "mc/_HeaderOutputPredefine.h"
#include "mc/deps/core/string/HashedString.h"
#include "mc/util/molang/MolangScriptArg.h"
#include "mc/util/molang/MolangVariableSettings.h"

// auto generated inclusion list
#include "mc/util/molang/MolangVariableIndex.h"

class MolangVariable {
public:
HashedString mName;
MolangScriptArg mValue;
MolangScriptArg mPublicValue;
MolangVariableSettings mSettings;

// prevent constructor by default
MolangVariable& operator=(MolangVariable const&);
MolangVariable(MolangVariable const&);
Expand Down
12 changes: 7 additions & 5 deletions src/mc/util/molang/MolangVariableSettings.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#pragma once

#include "mc/_HeaderOutputPredefine.h"
#include "mc/util/molang/MolangVariableIndex.h"

struct MolangVariableSettings {
public:
// prevent constructor by default
MolangVariableSettings& operator=(MolangVariableSettings const&);
MolangVariableSettings(MolangVariableSettings const&);
MolangVariableSettings();
enum AccessSpecifier : int {
Private = 0,
Public = 1,
};
MolangVariableIndex mIndex;
AccessSpecifier mAccessSpecifier;
};

0 comments on commit 4e53ed4

Please sign in to comment.