Skip to content

Commit

Permalink
Refactor usage of PhysFS
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandezseb committed Mar 4, 2024
1 parent 0cdbef3 commit 0c7b9a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/VM/VM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "Configuration.h"
#include "Memory.h"
#include "Library/Builtin.h"
#include "physfs.h"

#include <stack>
#include <string>
Expand All @@ -28,9 +29,11 @@ VM::VM(const Configuration configuration) noexcept
{
}

void VM::start()
void VM::start(const char* commandLineName)
{
Platform::initialize();
PHYSFS_init(commandLineName);
PHYSFS_permitSymbolicLinks(1);

registerBuiltinRegisterNatives();
getClass("java/lang/OutOfMemoryError", &m_mainThread);
Expand Down Expand Up @@ -357,6 +360,7 @@ void VM::runMain()

void VM::shutdown()
{
PHYSFS_deinit();
Platform::cleanup();
}

Expand Down
2 changes: 1 addition & 1 deletion src/VM/VM.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class VM {
void updateVariableFromVariable(Variable* variable, const char* descriptor, Variable operand, Variable operand2, VMThread* thread);
static std::vector<Variable> createVariableForDescriptor(const char* descriptor);
[[nodiscard]] static u1 getDescriptorVarCategory(const char* descriptor) noexcept;
void start();
void start(const char* commandLineName);
ClassInfo* getClass(const char* className, VMThread* thread);
void executeNativeMethod(const ClassInfo* targetClass, const MethodInfo* methodInfo, JavaHeap* heap, VMThread* thread);
void runMain();
Expand Down
8 changes: 1 addition & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include "VM/Configuration.h"
#include "VM/VM.h"
#include "physfs.h"

#include <span>
#include <string_view>
Expand Down Expand Up @@ -53,19 +52,14 @@ static Configuration parseArguments(const std::span<const char*> args)

int main(const int argc, const char* argv[])
{
PHYSFS_init(argv[0]);
PHYSFS_permitSymbolicLinks(1);

const size_t size = argc;
const std::span args{argv, size};
const Configuration config = parseArguments(args);

VM vm(config);
vm.start();
vm.start(argv[0]);
vm.runMain();
vm.shutdown();

PHYSFS_deinit();

return 0;
}

0 comments on commit 0c7b9a5

Please sign in to comment.