diff --git a/binding-mruby/audio-binding.cpp b/binding-mruby/audio-binding.cpp index 5bcbc8f..798c7e9 100644 --- a/binding-mruby/audio-binding.cpp +++ b/binding-mruby/audio-binding.cpp @@ -25,9 +25,8 @@ #include "exception.h" #define DEF_PLAY_STOP(entity) \ - MRB_METHOD(audio_##entity##Play) \ + MRB_FUNCTION(audio_##entity##Play) \ { \ - MRB_UNUSED_PARAM; \ char *filename; \ mrb_int volume = 100; \ mrb_int pitch = 100; \ @@ -35,17 +34,16 @@ GUARD_EXC( gState->audio().entity##Play(filename, volume, pitch); ) \ return mrb_nil_value(); \ } \ - MRB_METHOD(audio_##entity##Stop) \ + MRB_FUNCTION(audio_##entity##Stop) \ { \ - MRB_UNUSED_PARAM; \ + MRB_FUN_UNUSED_PARAM; \ gState->audio().entity##Stop(); \ return mrb_nil_value(); \ } #define DEF_FADE(entity) \ -MRB_METHOD(audio_##entity##Fade) \ +MRB_FUNCTION(audio_##entity##Fade) \ { \ - MRB_UNUSED_PARAM; \ mrb_int time; \ mrb_get_args(mrb, "i", &time); \ gState->audio().entity##Fade(time); \ diff --git a/binding-mruby/binding-util.h b/binding-mruby/binding-util.h index c9b8472..d750794 100644 --- a/binding-mruby/binding-util.h +++ b/binding-mruby/binding-util.h @@ -129,9 +129,14 @@ getMrbData(mrb_state *mrb) #define MRB_METHOD(name) static MRB_METHOD_PUB(name) +#define MRB_FUNCTION(name) \ + static mrb_value name(mrb_state *mrb, mrb_value) + #define MRB_UNUSED_PARAM \ { (void) mrb; (void) self; } +#define MRB_FUN_UNUSED_PARAM { (void) mrb; } + /* If we're not binding a disposable class, * we want to #undef DEF_PROP_CHK_DISP */ #define DEF_PROP_CHK_DISP \ diff --git a/binding-mruby/font-binding.cpp b/binding-mruby/font-binding.cpp index d25bb93..cc31f58 100644 --- a/binding-mruby/font-binding.cpp +++ b/binding-mruby/font-binding.cpp @@ -28,10 +28,8 @@ DEF_TYPE(Font); -MRB_METHOD(fontDoesExist) +MRB_FUNCTION(fontDoesExist) { - MRB_UNUSED_PARAM; - const char *name; mrb_get_args(mrb, "z", &name); @@ -102,17 +100,13 @@ DEF_KLASS_PROP(Font, mrb_int, DefaultSize, "i", fixnum) DEF_KLASS_PROP(Font, mrb_bool, DefaultBold, "b", bool) DEF_KLASS_PROP(Font, mrb_bool, DefaultItalic, "b", bool) -MRB_METHOD(FontGetDefaultName) +MRB_FUNCTION(FontGetDefaultName) { - MRB_UNUSED_PARAM; - return mrb_str_new_cstr(mrb, Font::getDefaultName()); } -MRB_METHOD(FontSetDefaultName) +MRB_FUNCTION(FontSetDefaultName) { - MRB_UNUSED_PARAM; - mrb_value nameObj; mrb_get_args(mrb, "S", &nameObj); diff --git a/binding-mruby/graphics-binding.cpp b/binding-mruby/graphics-binding.cpp index d36e5bc..cecb698 100644 --- a/binding-mruby/graphics-binding.cpp +++ b/binding-mruby/graphics-binding.cpp @@ -25,28 +25,26 @@ #include "binding-util.h" #include "exception.h" -MRB_METHOD(graphicsUpdate) +MRB_FUNCTION(graphicsUpdate) { - MRB_UNUSED_PARAM; + MRB_FUN_UNUSED_PARAM; gState->graphics().update(); return mrb_nil_value(); } -MRB_METHOD(graphicsFreeze) +MRB_FUNCTION(graphicsFreeze) { - MRB_UNUSED_PARAM; + MRB_FUN_UNUSED_PARAM; gState->graphics().freeze(); return mrb_nil_value(); } -MRB_METHOD(graphicsTransition) +MRB_FUNCTION(graphicsTransition) { - MRB_UNUSED_PARAM; - mrb_int duration = 8; const char *filename = 0; mrb_int vague = 40; @@ -58,9 +56,9 @@ MRB_METHOD(graphicsTransition) return mrb_nil_value(); } -MRB_METHOD(graphicsFrameReset) +MRB_FUNCTION(graphicsFrameReset) { - MRB_UNUSED_PARAM; + MRB_FUN_UNUSED_PARAM; gState->graphics().frameReset(); @@ -68,14 +66,13 @@ MRB_METHOD(graphicsFrameReset) } #define DEF_GRA_PROP_I(PropName) \ - MRB_METHOD(graphics##Get##PropName) \ + MRB_FUNCTION(graphics##Get##PropName) \ { \ - MRB_UNUSED_PARAM; \ + MRB_FUN_UNUSED_PARAM; \ return mrb_fixnum_value(gState->graphics().get##PropName()); \ } \ - MRB_METHOD(graphics##Set##PropName) \ + MRB_FUNCTION(graphics##Set##PropName) \ { \ - MRB_UNUSED_PARAM; \ mrb_int value; \ mrb_get_args(mrb, "i", &value); \ gState->graphics().set##PropName(value); \ @@ -85,17 +82,15 @@ MRB_METHOD(graphicsFrameReset) DEF_GRA_PROP_I(FrameRate) DEF_GRA_PROP_I(FrameCount) -MRB_METHOD(graphicsGetFullscreen) +MRB_FUNCTION(graphicsGetFullscreen) { - MRB_UNUSED_PARAM; + MRB_FUN_UNUSED_PARAM; return mrb_bool_value(gState->graphics().getFullscreen()); } -MRB_METHOD(graphicsSetFullscreen) +MRB_FUNCTION(graphicsSetFullscreen) { - MRB_UNUSED_PARAM; - mrb_bool mode; mrb_get_args(mrb, "b", &mode); diff --git a/binding-mruby/input-binding.cpp b/binding-mruby/input-binding.cpp index cbacd4c..213e19d 100644 --- a/binding-mruby/input-binding.cpp +++ b/binding-mruby/input-binding.cpp @@ -24,19 +24,15 @@ #include "exception.h" #include "binding-util.h" -MRB_METHOD(inputUpdate) +MRB_FUNCTION(inputUpdate) { - MRB_UNUSED_PARAM; - gState->input().update(); return mrb_nil_value(); } -MRB_METHOD(inputPress) +MRB_FUNCTION(inputPress) { - MRB_UNUSED_PARAM; - mrb_int num; mrb_get_args(mrb, "i", &num); @@ -45,10 +41,8 @@ MRB_METHOD(inputPress) return mrb_bool_value(gState->input().isPressed(bc)); } -MRB_METHOD(inputTrigger) +MRB_FUNCTION(inputTrigger) { - MRB_UNUSED_PARAM; - mrb_int num; mrb_get_args(mrb, "i", &num); @@ -57,10 +51,8 @@ MRB_METHOD(inputTrigger) return mrb_bool_value(gState->input().isTriggered(bc)); } -MRB_METHOD(inputRepeat) +MRB_FUNCTION(inputRepeat) { - MRB_UNUSED_PARAM; - mrb_int num; mrb_get_args(mrb, "i", &num); @@ -69,32 +61,24 @@ MRB_METHOD(inputRepeat) return mrb_bool_value(gState->input().isRepeated(bc)); } -MRB_METHOD(inputDir4) +MRB_FUNCTION(inputDir4) { - MRB_UNUSED_PARAM; - return mrb_fixnum_value(gState->input().dir4Value()); } -MRB_METHOD(inputDir8) +MRB_FUNCTION(inputDir8) { - MRB_UNUSED_PARAM; - return mrb_fixnum_value(gState->input().dir8Value()); } /* Non-standard extensions */ -MRB_METHOD(inputMouseX) +MRB_FUNCTION(inputMouseX) { - MRB_UNUSED_PARAM; - return mrb_fixnum_value(gState->input().mouseX()); } -MRB_METHOD(inputMouseY) +MRB_FUNCTION(inputMouseY) { - MRB_UNUSED_PARAM; - return mrb_fixnum_value(gState->input().mouseY()); } diff --git a/binding-mruby/mrb-ext/file.cpp b/binding-mruby/mrb-ext/file.cpp index 3121626..c31c00c 100644 --- a/binding-mruby/mrb-ext/file.cpp +++ b/binding-mruby/mrb-ext/file.cpp @@ -156,10 +156,8 @@ findLastDot(char *str) } /* File class methods */ -MRB_METHOD(fileBasename) +MRB_FUNCTION(fileBasename) { - MRB_UNUSED_PARAM; - mrb_value filename; const char *suffix = 0; @@ -186,10 +184,8 @@ MRB_METHOD(fileBasename) return str; } -MRB_METHOD(fileDelete) +MRB_FUNCTION(fileDelete) { - MRB_UNUSED_PARAM; - mrb_int argc; mrb_value *argv; @@ -209,10 +205,8 @@ MRB_METHOD(fileDelete) return mrb_nil_value(); } -MRB_METHOD(fileDirname) +MRB_FUNCTION(fileDirname) { - MRB_UNUSED_PARAM; - mrb_value filename; mrb_get_args(mrb, "S", &filename); @@ -222,10 +216,8 @@ MRB_METHOD(fileDirname) return mrb_str_new_cstr(mrb, dir); } -MRB_METHOD(fileExpandPath) +MRB_FUNCTION(fileExpandPath) { - MRB_UNUSED_PARAM; - const char *path; const char *defDir = 0; @@ -242,10 +234,8 @@ MRB_METHOD(fileExpandPath) return mrb_str_new_cstr(mrb, buffer); } -MRB_METHOD(fileExtname) +MRB_FUNCTION(fileExtname) { - MRB_UNUSED_PARAM; - mrb_value filename; mrb_get_args(mrb, "S", &filename); @@ -254,10 +244,8 @@ MRB_METHOD(fileExtname) return mrb_str_new_cstr(mrb, ext); } -MRB_METHOD(fileOpen) +MRB_FUNCTION(fileOpen) { - MRB_UNUSED_PARAM; - mrb_value path; const char *mode = "r"; mrb_value block = mrb_nil_value(); @@ -294,10 +282,8 @@ MRB_METHOD(fileOpen) return obj; } -MRB_METHOD(fileRename) +MRB_FUNCTION(fileRename) { - MRB_UNUSED_PARAM; - const char *from, *to; mrb_get_args(mrb, "zz", &from, &to); @@ -307,11 +293,11 @@ MRB_METHOD(fileRename) } -MRB_METHOD(mrbNoop) +MRB_FUNCTION(mrbNoop) { - MRB_UNUSED_PARAM; + MRB_FUN_UNUSED_PARAM; - return self; + return mrb_nil_value(); } /* File instance methods */ @@ -540,10 +526,8 @@ MRB_METHOD(fileGetMtime) } /* FileTest module functions */ -MRB_METHOD(fileTestDoesExist) +MRB_FUNCTION(fileTestDoesExist) { - MRB_UNUSED_PARAM; - const char *filename; mrb_get_args(mrb, "z", &filename); @@ -552,30 +536,24 @@ MRB_METHOD(fileTestDoesExist) return mrb_bool_value(result == 0); } -MRB_METHOD(fileTestIsFile) +MRB_FUNCTION(fileTestIsFile) { - MRB_UNUSED_PARAM; - struct stat fileStat; getFileStat(mrb, fileStat); return mrb_bool_value(S_ISREG(fileStat.st_mode)); } -MRB_METHOD(fileTestIsDirectory) +MRB_FUNCTION(fileTestIsDirectory) { - MRB_UNUSED_PARAM; - struct stat fileStat; getFileStat(mrb, fileStat); return mrb_bool_value(S_ISDIR(fileStat.st_mode)); } -MRB_METHOD(fileTestSize) +MRB_FUNCTION(fileTestSize) { - MRB_UNUSED_PARAM; - struct stat fileStat; getFileStat(mrb, fileStat); diff --git a/binding-mruby/mrb-ext/kernel.cpp b/binding-mruby/mrb-ext/kernel.cpp index c0c0987..9056701 100644 --- a/binding-mruby/mrb-ext/kernel.cpp +++ b/binding-mruby/mrb-ext/kernel.cpp @@ -39,10 +39,8 @@ void mrbBindingTerminate(); -MRB_METHOD(kernelEval) +MRB_FUNCTION(kernelEval) { - MRB_UNUSED_PARAM; - const char *exp; mrb_int expLen; mrb_get_args(mrb, "s", &exp, &expLen); @@ -74,19 +72,15 @@ static void printP(mrb_state *mrb, gState->eThread().showMessageBox(RSTRING_PTR(buffer), SDL_MESSAGEBOX_INFORMATION); } -MRB_METHOD(kernelP) +MRB_FUNCTION(kernelP) { - MRB_UNUSED_PARAM; - printP(mrb, "inspect", "\n"); return mrb_nil_value(); } -MRB_METHOD(kernelPrint) +MRB_FUNCTION(kernelPrint) { - MRB_UNUSED_PARAM; - printP(mrb, "to_s", ""); return mrb_nil_value(); @@ -108,10 +102,8 @@ srandCurrentTime(int *currentSeed) srand(*currentSeed); } -MRB_METHOD(kernelRand) +MRB_FUNCTION(kernelRand) { - MRB_UNUSED_PARAM; - if (!srandCalled) { srandCurrentTime(¤tSeed); @@ -142,10 +134,8 @@ MRB_METHOD(kernelRand) } } -MRB_METHOD(kernelSrand) +MRB_FUNCTION(kernelSrand) { - MRB_UNUSED_PARAM; - srandCalled = true; if (mrb->c->ci->argc == 1) @@ -168,19 +158,17 @@ MRB_METHOD(kernelSrand) } } -MRB_METHOD(kernelExit) +MRB_FUNCTION(kernelExit) { - MRB_UNUSED_PARAM; + MRB_FUN_UNUSED_PARAM; mrbBindingTerminate(); return mrb_nil_value(); } -MRB_METHOD(kernelLoadData) +MRB_FUNCTION(kernelLoadData) { - MRB_UNUSED_PARAM; - const char *filename; mrb_get_args(mrb, "z", &filename); @@ -200,10 +188,8 @@ MRB_METHOD(kernelLoadData) return obj; } -MRB_METHOD(kernelSaveData) +MRB_FUNCTION(kernelSaveData) { - MRB_UNUSED_PARAM; - mrb_value obj; const char *filename; @@ -225,10 +211,8 @@ MRB_METHOD(kernelSaveData) return mrb_nil_value(); } -MRB_METHOD(kernelInteger) +MRB_FUNCTION(kernelInteger) { - MRB_UNUSED_PARAM; - mrb_value obj; mrb_get_args(mrb, "o", &obj); diff --git a/binding-mruby/mrb-ext/marshal.cpp b/binding-mruby/mrb-ext/marshal.cpp index 543dec6..62b08f7 100644 --- a/binding-mruby/mrb-ext/marshal.cpp +++ b/binding-mruby/mrb-ext/marshal.cpp @@ -882,10 +882,8 @@ verifyMarshalHeader(MarshalContext *ctx) throw Exception(Exception::TypeError, "incompatible marshal file format (can't be read)"); } -MRB_METHOD(marshalDump) +MRB_FUNCTION(marshalDump) { - MRB_UNUSED_PARAM; - mrb_value val; mrb_value port = mrb_nil_value(); mrb_int limit = 100; @@ -945,10 +943,8 @@ MRB_METHOD(marshalDump) return ret; } -MRB_METHOD(marshalLoad) +MRB_FUNCTION(marshalLoad) { - MRB_UNUSED_PARAM; - mrb_value port; mrb_get_args(mrb, "o", &port); diff --git a/binding-mruby/mrb-ext/time.cpp b/binding-mruby/mrb-ext/time.cpp index 6e27f1e..c9f0e4c 100644 --- a/binding-mruby/mrb-ext/time.cpp +++ b/binding-mruby/mrb-ext/time.cpp @@ -53,20 +53,16 @@ timeFromSecondsInt(mrb_state *mrb, time_t seconds) return obj; } -MRB_METHOD(timeAt) +MRB_FUNCTION(timeAt) { - MRB_UNUSED_PARAM; - mrb_int seconds; mrb_get_args(mrb, "i", &seconds); return timeFromSecondsInt(mrb, seconds); } -MRB_METHOD(timeNow) +MRB_FUNCTION(timeNow) { - MRB_UNUSED_PARAM; - TimeImpl *p = new TimeImpl; gettimeofday(&p->_tv, 0);