Sha256: 199338e95af98b3145a472840f87588affd8e006fe35663675f11028ead87e0c

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

#include <Gosu/Directories.hpp>
#include <Gosu/Utility.hpp>
#include <unistd.h>
#include "ruby.h"
#include "oniguruma.h"

extern "C" void Init_gosu();

extern "C" int rb_enc_register(const char *, OnigEncodingType*);
extern "C" void rb_encdb_declare(const char *name);
extern OnigEncodingType OnigEncodingASCII;
extern OnigEncodingType OnigEncodingUS_ASCII;
extern OnigEncodingType OnigEncodingUTF_8;
extern OnigEncodingType OnigEncodingUTF_16BE;
extern OnigEncodingType OnigEncodingUTF_16LE;
extern OnigEncodingType OnigEncodingUTF_32BE;
extern OnigEncodingType OnigEncodingUTF_32LE;

int main()
{
    std::string resourcePath = Gosu::wstringToUTF8(Gosu::resourcePrefix());
    chdir(resourcePath.c_str());

    std::string mainPath = resourcePath + "Main.rb";

    char* argv[] = { "ruby", const_cast<char*>(mainPath.c_str()), 0 };
    int argc = 2;
    
    char** argvPointer = argv;
    ruby_sysinit(&argc, &argvPointer);
    { 
        RUBY_INIT_STACK; 

        ruby_init();

        rb_encdb_declare(OnigEncodingASCII.name);
        rb_encdb_declare(OnigEncodingUS_ASCII.name);
        rb_encdb_declare(OnigEncodingUTF_8.name);
        rb_enc_register(OnigEncodingUTF_16BE.name, &OnigEncodingUTF_16BE);
        rb_enc_register(OnigEncodingUTF_16LE.name, &OnigEncodingUTF_16LE);
        rb_enc_register(OnigEncodingUTF_32BE.name, &OnigEncodingUTF_32BE);
        rb_enc_register(OnigEncodingUTF_32LE.name, &OnigEncodingUTF_32LE);

        Init_gosu();
        rb_eval_string("$LOADED_FEATURES << 'gosu.bundle'");
        rb_eval_string("$LOADED_FEATURES << 'rubygems.rb'");

        return ruby_run_node(ruby_options(argc, argv)); 
    }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gosu-0.7.15 GosuImpl/RubyGosuStub.mm
gosu-0.7.14 GosuImpl/RubyGosuStub.mm
gosu-0.7.13.3 GosuImpl/RubyGosuStub.mm