@@ -528,14 +528,15 @@ RB_METHOD(mkxpSystemMemory) {
528
528
return INT2NUM (SDL_GetSystemRAM ());
529
529
}
530
530
531
- RB_METHOD (mkxpReloadPathCache) {
531
+ RB_METHOD_GUARD (mkxpReloadPathCache) {
532
532
RB_UNUSED_PARAM;
533
533
534
- GUARD_EXC ( shState->fileSystem ().reloadPathCache (); );
534
+ shState->fileSystem ().reloadPathCache ();
535
535
return Qnil;
536
536
}
537
+ RB_METHOD_GUARD_END
537
538
538
- RB_METHOD (mkxpAddPath) {
539
+ RB_METHOD_GUARD (mkxpAddPath) {
539
540
RB_UNUSED_PARAM;
540
541
541
542
VALUE path, mountpoint, reload;
@@ -545,36 +546,32 @@ RB_METHOD(mkxpAddPath) {
545
546
546
547
const char *mp = (mountpoint == Qnil) ? 0 : RSTRING_PTR (mountpoint);
547
548
548
- try {
549
- bool rl = true ;
550
- if (reload != Qnil)
551
- rb_bool_arg (reload, &rl);
552
-
553
- shState->fileSystem ().addPath (RSTRING_PTR (path), mp, rl);
554
- } catch (Exception &e) {
555
- raiseRbExc (e);
556
- }
549
+ bool rl = true ;
550
+ if (reload != Qnil)
551
+ rb_bool_arg (reload, &rl);
552
+
553
+ shState->fileSystem ().addPath (RSTRING_PTR (path), mp, rl);
554
+
557
555
return path;
558
556
}
557
+ RB_METHOD_GUARD_END
559
558
560
- RB_METHOD (mkxpRemovePath) {
559
+ RB_METHOD_GUARD (mkxpRemovePath) {
561
560
RB_UNUSED_PARAM;
562
561
563
562
VALUE path, reload;
564
563
rb_scan_args (argc, argv, " 11" , &path, &reload);
565
564
SafeStringValue (path);
566
565
567
- try {
568
- bool rl = true ;
569
- if (reload != Qnil)
570
- rb_bool_arg (reload, &rl);
571
-
572
- shState->fileSystem ().removePath (RSTRING_PTR (path), rl);
573
- } catch (Exception &e) {
574
- raiseRbExc (e);
575
- }
566
+ bool rl = true ;
567
+ if (reload != Qnil)
568
+ rb_bool_arg (reload, &rl);
569
+
570
+ shState->fileSystem ().removePath (RSTRING_PTR (path), rl);
571
+
576
572
return path;
577
573
}
574
+ RB_METHOD_GUARD_END
578
575
579
576
RB_METHOD (mkxpFileExists) {
580
577
RB_UNUSED_PARAM;
@@ -601,24 +598,25 @@ RB_METHOD(mkxpSetDefaultFontFamily) {
601
598
return Qnil;
602
599
}
603
600
604
- RB_METHOD (mkxpStringToUTF8) {
601
+ RB_METHOD_GUARD (mkxpStringToUTF8) {
605
602
RB_UNUSED_PARAM;
606
603
607
604
rb_check_argc (argc, 0 );
608
605
609
606
std::string ret (RSTRING_PTR (self), RSTRING_LEN (self));
610
- GUARD_EXC ( ret = Encoding::convertString (ret); );
607
+ ret = Encoding::convertString (ret);
611
608
612
609
return rb_utf8_str_new (ret.c_str (), ret.length ());
613
610
}
611
+ RB_METHOD_GUARD_END
614
612
615
- RB_METHOD (mkxpStringToUTF8Bang) {
613
+ RB_METHOD_GUARD (mkxpStringToUTF8Bang) {
616
614
RB_UNUSED_PARAM;
617
615
618
616
rb_check_argc (argc, 0 );
619
617
620
618
std::string ret (RSTRING_PTR (self), RSTRING_LEN (self));
621
- GUARD_EXC ( ret = Encoding::convertString (ret); );
619
+ ret = Encoding::convertString (ret);
622
620
623
621
rb_str_resize (self, ret.length ());
624
622
memcpy (RSTRING_PTR (self), ret.c_str (), RSTRING_LEN (self));
@@ -629,6 +627,7 @@ RB_METHOD(mkxpStringToUTF8Bang) {
629
627
630
628
return self;
631
629
}
630
+ RB_METHOD_GUARD_END
632
631
633
632
#ifdef __APPLE__
634
633
#define OPENCMD " open "
@@ -641,7 +640,7 @@ RB_METHOD(mkxpStringToUTF8Bang) {
641
640
#define OPENARGS " "
642
641
#endif
643
642
644
- RB_METHOD (mkxpLaunch) {
643
+ RB_METHOD_GUARD (mkxpLaunch) {
645
644
RB_UNUSED_PARAM;
646
645
647
646
VALUE cmdname, args;
@@ -674,11 +673,12 @@ RB_METHOD(mkxpLaunch) {
674
673
}
675
674
676
675
if (std::system (command.c_str ()) != 0 ) {
677
- raiseRbExc ( Exception (Exception::MKXPError, " Failed to launch \" %s\" " , RSTRING_PTR (cmdname) ));
676
+ throw Exception (Exception::MKXPError, " Failed to launch \" %s\" " , RSTRING_PTR (cmdname));
678
677
}
679
678
680
679
return RUBY_Qnil;
681
680
}
681
+ RB_METHOD_GUARD_END
682
682
683
683
json5pp::value loadUserSettings () {
684
684
json5pp::value ret;
@@ -722,7 +722,7 @@ RB_METHOD(mkxpGetJSONSetting) {
722
722
723
723
}
724
724
725
- RB_METHOD (mkxpSetJSONSetting) {
725
+ RB_METHOD_GUARD (mkxpSetJSONSetting) {
726
726
RB_UNUSED_PARAM;
727
727
728
728
VALUE sname, svalue;
@@ -736,6 +736,7 @@ RB_METHOD(mkxpSetJSONSetting) {
736
736
737
737
return Qnil;
738
738
}
739
+ RB_METHOD_GUARD_END
739
740
740
741
RB_METHOD (mkxpGetAllJSONSettings) {
741
742
RB_UNUSED_PARAM;
0 commit comments