-
-
Save syureri/a579af50c0c0df74c1c411fbaafca1cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "RubyStuff.hpp" | |
#include <Windows.h> | |
#include <iostream> | |
typedef void (*RGSSInitialize3)(HMODULE rgssDLL); | |
typedef int (*RGSSEval)(const char* script); | |
namespace | |
{ | |
HMODULE rgssDLL = nullptr; | |
RGSSInitialize3 rgssInitialize3 = nullptr; | |
RGSSEval rgssEval = nullptr; | |
} | |
RubyStuff::VALUE SimpleMethod(RubyStuff::VALUE self) | |
{ | |
std::cout << "Hello from native function." << std::endl; | |
return RubyStuff::Qnil; | |
} | |
int main() | |
{ | |
rgssDLL = LoadLibraryW(L"RGSS301.dll"); | |
if (!rgssDLL) | |
return -1; | |
rgssInitialize3 = (RGSSInitialize3)GetProcAddress(rgssDLL, "RGSSInitialize3"); | |
rgssEval = (RGSSEval)GetProcAddress(rgssDLL, "RGSSEval"); | |
rgssInitialize3(rgssDLL); | |
RubyStuff::Init(rgssDLL); | |
RubyStuff::VALUE rbmodule = RubyStuff::rb_define_module("TestModule"); | |
RubyStuff::rb_define_module_function(rbmodule, "simple_method", SimpleMethod, 0); | |
rgssEval("TestModule.simple_method"); | |
FreeLibrary(rgssDLL); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment