… | |
… | |
477 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
477 | || (SvSTASH (SvRV (sv)) != stash_cf_object_wrap |
478 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
478 | && SvSTASH (SvRV (sv)) != stash_cf_object_player_wrap |
479 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
479 | && SvSTASH (SvRV (sv)) != stash_cf_arch_wrap |
480 | && !sv_derived_from (sv, "cf::object"))) |
480 | && !sv_derived_from (sv, "cf::object"))) |
481 | croak ("object of type cf::object expected"); |
481 | croak ("object of type cf::object expected"); |
|
|
482 | |
|
|
483 | return SvPTR_nc (sv); |
|
|
484 | } |
|
|
485 | |
|
|
486 | static long noinline |
|
|
487 | SvPTR_ornull_maptile (SV *sv) |
|
|
488 | { |
|
|
489 | if (expect_false (!SvOK (sv))) return 0; |
|
|
490 | |
|
|
491 | if (!SvROK (sv) |
|
|
492 | || (SvSTASH (SvRV (sv)) != stash_cf_map_wrap |
|
|
493 | && !sv_derived_from (sv, "cf::map"))) |
|
|
494 | croak ("object of type cf::map expected"); |
482 | |
495 | |
483 | return SvPTR_nc (sv); |
496 | return SvPTR_nc (sv); |
484 | } |
497 | } |
485 | |
498 | |
486 | static long noinline |
499 | static long noinline |
… | |
… | |
563 | static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
576 | static inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
564 | static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
577 | static inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
565 | static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
578 | static inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
566 | static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
579 | static inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
567 | static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
580 | static inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
568 | static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); } |
581 | static inline void sv_to (SV *sv, client * &v) { v = (client *) (attachable *)SvPTR_ornull_client (sv); } |
569 | static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); } |
582 | static inline void sv_to (SV *sv, player * &v) { v = (player *) (attachable *)SvPTR_ornull_player (sv); } |
570 | static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } |
583 | static inline void sv_to (SV *sv, object * &v) { v = (object *) (attachable *)SvPTR_ornull_object (sv); } |
|
|
584 | static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull_maptile (sv); } |
571 | static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
585 | static inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)(attachable *)SvPTR_ornull (sv, "cf::arch"); } |
572 | static inline void sv_to (SV *sv, maptile * &v) { v = (maptile *) (attachable *)SvPTR_ornull (sv, "cf::map"); } |
|
|
573 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
586 | static inline void sv_to (SV *sv, region * &v) { v = (region *) (attachable *)SvPTR_ornull (sv, "cf::region"); } |
574 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
587 | static inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } |
575 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
588 | static inline void sv_to (SV *sv, partylist * &v) { v = (partylist *) SvPTR_ornull (sv, "cf::party"); } |
576 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
589 | static inline void sv_to (SV *sv, living * &v) { v = (living *) SvPTR_ornull (sv, "cf::living"); } |
577 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
590 | static inline void sv_to (SV *sv, mapspace * &v) { v = (mapspace *) SvPTR_ornull (sv, "cf::mapspace"); } |
… | |
… | |
693 | template<class type> |
706 | template<class type> |
694 | static void noinline |
707 | static void noinline |
695 | cf_obj_to (SV *arg, type &var) |
708 | cf_obj_to (SV *arg, type &var) |
696 | { |
709 | { |
697 | sv_to (arg, var); |
710 | sv_to (arg, var); |
698 | if (!var) |
711 | if (expect_false (!var)) |
699 | croak ("must not pass invalid/null cf_obj here"); |
712 | croak ("must not pass invalid/null cf_obj here"); |
700 | } |
713 | } |
701 | |
714 | |
702 | template<class object> |
715 | template<class object> |
703 | static void noinline |
716 | static void noinline |
704 | cf_obj_ornull_to (SV *arg, object *&var) |
717 | cf_obj_ornull_to (SV *arg, object *&var) |
705 | { |
718 | { |
706 | if (SvOK (arg)) |
719 | if (SvOK (arg)) |
707 | { |
720 | { |
708 | sv_to (arg, var); |
721 | sv_to (arg, var); |
709 | if (!var) |
722 | if (expect_false (!var)) |
710 | croak ("unable to convert perl object to C++ object"); |
723 | croak ("unable to convert perl object to C++ object"); |
711 | } |
724 | } |
712 | else |
725 | else |
713 | var = 0; |
726 | var = 0; |
714 | } |
727 | } |