… | |
… | |
441 | SvPTR_nc (SV *sv) |
441 | SvPTR_nc (SV *sv) |
442 | { |
442 | { |
443 | sv = SvRV (sv); |
443 | sv = SvRV (sv); |
444 | |
444 | |
445 | // very important shortcut |
445 | // very important shortcut |
446 | if (expect_true (SvMAGIC (sv) && SvMAGIC (sv)->mg_type == PERL_MAGIC_ext)) |
446 | if (ecb_expect_true (SvMAGIC (sv) && SvMAGIC (sv)->mg_type == PERL_MAGIC_ext)) |
447 | return (long)SvMAGIC (sv)->mg_ptr; |
447 | return (long)SvMAGIC (sv)->mg_ptr; |
448 | |
448 | |
449 | if (MAGIC *mg = mg_find (sv, PERL_MAGIC_ext)) |
449 | if (MAGIC *mg = mg_find (sv, PERL_MAGIC_ext)) |
450 | return (long)mg->mg_ptr; |
450 | return (long)mg->mg_ptr; |
451 | |
451 | |
… | |
… | |
462 | } |
462 | } |
463 | |
463 | |
464 | ecb_noinline static long |
464 | ecb_noinline static long |
465 | SvPTR_ornull (SV *sv, const char *klass) |
465 | SvPTR_ornull (SV *sv, const char *klass) |
466 | { |
466 | { |
467 | if (expect_false (!SvOK (sv))) return 0; |
467 | if (ecb_expect_false (!SvOK (sv))) return 0; |
468 | |
468 | |
469 | return SvPTR (sv, klass); |
469 | return SvPTR (sv, klass); |
470 | } |
470 | } |
471 | |
471 | |
472 | ecb_noinline static long |
472 | ecb_noinline static long |
473 | SvPTR_ornull_client (SV *sv) |
473 | SvPTR_ornull_client (SV *sv) |
474 | { |
474 | { |
475 | if (expect_false (!SvOK (sv))) return 0; |
475 | if (ecb_expect_false (!SvOK (sv))) return 0; |
476 | |
476 | |
477 | if (!SvROK (sv) |
477 | if (!SvROK (sv) |
478 | || (SvSTASH (SvRV (sv)) != stash_cf_client_wrap |
478 | || (SvSTASH (SvRV (sv)) != stash_cf_client_wrap |
479 | && !sv_derived_from (sv, "cf::client"))) |
479 | && !sv_derived_from (sv, "cf::client"))) |
480 | croak ("object of type cf::client expected"); |
480 | croak ("object of type cf::client expected"); |
… | |
… | |
483 | } |
483 | } |
484 | |
484 | |
485 | ecb_noinline static long |
485 | ecb_noinline static long |
486 | SvPTR_ornull_object (SV *sv) |
486 | SvPTR_ornull_object (SV *sv) |
487 | { |
487 | { |
488 | if (expect_false (!SvOK (sv))) return 0; |
488 | if (ecb_expect_false (!SvOK (sv))) return 0; |
489 | |
489 | |
490 | if (!SvROK (sv) |
490 | if (!SvROK (sv) |
491 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
491 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
492 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
492 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
493 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
493 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
… | |
… | |
498 | } |
498 | } |
499 | |
499 | |
500 | ecb_noinline static long |
500 | ecb_noinline static long |
501 | SvPTR_ornull_maptile (SV *sv) |
501 | SvPTR_ornull_maptile (SV *sv) |
502 | { |
502 | { |
503 | if (expect_false (!SvOK (sv))) return 0; |
503 | if (ecb_expect_false (!SvOK (sv))) return 0; |
504 | |
504 | |
505 | if (!SvROK (sv) |
505 | if (!SvROK (sv) |
506 | || (SvSTASH (SvRV (sv)) != stash_cf_map_wrap |
506 | || (SvSTASH (SvRV (sv)) != stash_cf_map_wrap |
507 | && SvSTASH (SvRV (sv)) != stash_ext_map_world |
507 | && SvSTASH (SvRV (sv)) != stash_ext_map_world |
508 | && !sv_derived_from (sv, "cf::map"))) |
508 | && !sv_derived_from (sv, "cf::map"))) |
… | |
… | |
512 | } |
512 | } |
513 | |
513 | |
514 | ecb_noinline static long |
514 | ecb_noinline static long |
515 | SvPTR_ornull_player (SV *sv) |
515 | SvPTR_ornull_player (SV *sv) |
516 | { |
516 | { |
517 | if (expect_false (!SvOK (sv))) return 0; |
517 | if (ecb_expect_false (!SvOK (sv))) return 0; |
518 | |
518 | |
519 | if (!SvROK (sv) |
519 | if (!SvROK (sv) |
520 | || (SvSTASH (SvRV (sv)) != stash_cf_player_wrap |
520 | || (SvSTASH (SvRV (sv)) != stash_cf_player_wrap |
521 | && !sv_derived_from (sv, "cf::player"))) |
521 | && !sv_derived_from (sv, "cf::player"))) |
522 | croak ("object of type cf::player expected"); |
522 | croak ("object of type cf::player expected"); |
… | |
… | |
733 | template<class type> |
733 | template<class type> |
734 | ecb_noinline static void |
734 | ecb_noinline static void |
735 | cf_obj_to (SV *arg, type &var) |
735 | cf_obj_to (SV *arg, type &var) |
736 | { |
736 | { |
737 | sv_to (arg, var); |
737 | sv_to (arg, var); |
738 | if (expect_false (!var)) |
738 | if (ecb_expect_false (!var)) |
739 | croak ("must not pass invalid/null cf_obj here"); |
739 | croak ("must not pass invalid/null cf_obj here"); |
740 | } |
740 | } |
741 | |
741 | |
742 | template<class object> |
742 | template<class object> |
743 | ecb_noinline static void |
743 | ecb_noinline static void |
744 | cf_obj_ornull_to (SV *arg, object *&var) |
744 | cf_obj_ornull_to (SV *arg, object *&var) |
745 | { |
745 | { |
746 | if (SvOK (arg)) |
746 | if (SvOK (arg)) |
747 | { |
747 | { |
748 | sv_to (arg, var); |
748 | sv_to (arg, var); |
749 | if (expect_false (!var)) |
749 | if (ecb_expect_false (!var)) |
750 | croak ("unable to convert perl object to C++ object"); |
750 | croak ("unable to convert perl object to C++ object"); |
751 | } |
751 | } |
752 | else |
752 | else |
753 | var = 0; |
753 | var = 0; |
754 | } |
754 | } |