Skip to content

Commit

Permalink
Move macro helpers to v8_helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
zpl-zak committed Sep 23, 2021
1 parent 10909d1 commit f486ec9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 32 deletions.
28 changes: 0 additions & 28 deletions code/framework/src/scripting/builtins/macros.h

This file was deleted.

2 changes: 1 addition & 1 deletion code/framework/src/scripting/builtins/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "../errors.h"
#include "../resource.h"
#include "../v8_helpers/v8_string.h"
#include "macros.h"
#include "../v8_helpers/helpers.h"

#include <v8.h>

Expand Down
1 change: 0 additions & 1 deletion code/framework/src/scripting/builtins/quaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "../v8_helpers/v8_class.h"
#include "../v8_helpers/v8_module.h"
#include "factory.h"
#include "macros.h"

#include <glm/ext.hpp>
#include <glm/ext/matrix_relational.hpp>
Expand Down
1 change: 0 additions & 1 deletion code/framework/src/scripting/builtins/vector_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "../v8_helpers/v8_class.h"
#include "../v8_helpers/v8_module.h"
#include "factory.h"
#include "macros.h"

#include <glm/glm.hpp>
#include <iomanip>
Expand Down
1 change: 0 additions & 1 deletion code/framework/src/scripting/builtins/vector_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "../v8_helpers/v8_class.h"
#include "../v8_helpers/v8_module.h"
#include "factory.h"
#include "macros.h"

#include <glm/glm.hpp>
#include <iomanip>
Expand Down
27 changes: 27 additions & 0 deletions code/framework/src/scripting/v8_helpers/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,30 @@ namespace Framework::Scripting::V8Helpers {
return false;
}
} // namespace Framework::Scripting::V8Helpers

#define V8_GET_ISOLATE() v8::Isolate *isolate = info.GetIsolate()
#define V8_GET_CONTEXT() v8::Local<v8::Context> ctx = isolate->GetEnteredOrMicrotaskContext()
#define V8_GET_ISOLATE_CONTEXT() \
V8_GET_ISOLATE(); \
V8_GET_CONTEXT()

#define V8_GET_RESOURCE() auto resource = static_cast<Resource *>(ctx->GetAlignedPointerFromEmbedderData(0))

#define V8_GET_SUITE() \
V8_GET_ISOLATE(); \
V8_GET_CONTEXT(); \
V8_GET_RESOURCE()

#define V8_RETURN(ret) info.GetReturnValue().Set(ret)

#define V8_RETURN_NULL(ret) info.GetReturnValue().SetNull()

#define V8_GET_SELF() v8::Local<v8::Object> _this = info.This()

#define V8_DEFINE_STACK() V8Helpers::ArgumentStack stack(info)

#define V8_VALIDATE_CTOR_CALL() \
if (!info.IsConstructCall()) { \
V8Helpers::Throw(isolate, "Function cannot be called without new keyword"); \
return; \
}

0 comments on commit f486ec9

Please sign in to comment.