Skip to content

Instantly share code, notes, and snippets.

@syureri
Created February 14, 2020 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syureri/a579af50c0c0df74c1c411fbaafca1cc to your computer and use it in GitHub Desktop.
Save syureri/a579af50c0c0df74c1c411fbaafca1cc to your computer and use it in GitHub Desktop.
#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