Skip to content

Commit

Permalink
Fix API.hpp failing to compile in native code
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Mar 17, 2024
1 parent ebe9095 commit 768569b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions include/reframework/API.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#ifdef __cplusplus_cli
#pragma managed
#include <msclr/gcroot.h>
#include <msclr/marshal_cppstd.h>
//#include <cliext/vector>
Expand Down Expand Up @@ -127,16 +128,16 @@ class API {
public:
// ALWAYS call initialize first in reframework_plugin_initialize
#ifndef __cplusplus_cli
static API& initialize(const REFrameworkPluginInitializeParam* param);
static inline std::unique_ptr<reframework::API>& initialize(const REFrameworkPluginInitializeParam* param);
#else
static API^ initialize(uintptr_t param);
static inline API^ initialize(uintptr_t param);
#endif

// only call this AFTER calling initialize
#ifndef __cplusplus_cli
static auto& get() {
static inline auto& get() {
#else
static auto get() {
static inline auto get() {
#endif
if (s_instance == nullptr) {
throw std::runtime_error("API not initialized");
Expand Down Expand Up @@ -342,6 +343,12 @@ class API {
return (void*)this;
}
};

#define POINTER_CONTAINER_CONSTRUCTOR(WrapperType, Tx) WrapperType(Tx ptr) : PointerContainer(ptr) {}
#define PUBLIC_POINTER_CONTAINER(X, Tx) struct X : public PointerContainer<Tx> { \
public:\
X(Tx ptr) : PointerContainer(ptr) {}

#endif

//#define PUBLIC_POINTER_CONTAINER(Tx) : public PointerContainer<Tx>
Expand Down Expand Up @@ -1154,9 +1161,9 @@ else

// ALWAYS call initialize first in reframework_plugin_initialize
#ifndef __cplusplus_cli
reframework::API& reframework::API::initialize(const REFrameworkPluginInitializeParam* param) {
inline std::unique_ptr<reframework::API>& reframework::API::initialize(const REFrameworkPluginInitializeParam* param) {
#else
reframework::API^ reframework::API::initialize(uintptr_t param) {
inline reframework::API^ reframework::API::initialize(uintptr_t param) {
#endif
#ifndef __cplusplus_cli
if (param == nullptr) {
Expand Down

0 comments on commit 768569b

Please sign in to comment.