@@ -560,209 +560,34 @@ template<> void VMCheckReturn<double>(VMFunction* func);
560
560
template <> void VMCheckReturn<FString>(VMFunction* func);
561
561
template <> void VMCheckReturn<DObject*>(VMFunction* func);
562
562
563
- template <typename RetVal> void VMValidateSignature (VMFunction* func)
563
+ template <typename RetVal, typename ... Args, size_t ... I>
564
+ void VMValidateSignatureSingle (VMFunction* func, std::index_sequence<I...>)
564
565
{
565
- VMCheckParamCount<RetVal>(func, 0 );
566
+ VMCheckParamCount<RetVal>(func, sizeof ...(Args) );
566
567
VMCheckReturn<RetVal>(func);
567
- }
568
-
569
- template <typename RetVal, typename P1> void VMValidateSignature (VMFunction* func)
570
- {
571
- VMCheckParamCount<RetVal>(func, 1 );
572
- VMCheckReturn<RetVal>(func);
573
- VMCheckParam<P1>(func, 0 );
574
- }
575
-
576
- template <typename RetVal, typename P1, typename P2> void VMValidateSignature (VMFunction* func)
577
- {
578
- VMCheckParamCount<RetVal>(func, 2 );
579
- VMCheckReturn<RetVal>(func);
580
- VMCheckParam<P1>(func, 0 );
581
- VMCheckParam<P2>(func, 1 );
582
- }
583
-
584
- template <typename RetVal, typename P1, typename P2, typename P3> void VMValidateSignature (VMFunction* func)
585
- {
586
- VMCheckParamCount<RetVal>(func, 3 );
587
- VMCheckReturn<RetVal>(func);
588
- VMCheckParam<P1>(func, 0 );
589
- VMCheckParam<P2>(func, 1 );
590
- VMCheckParam<P3>(func, 2 );
591
- }
592
-
593
- template <typename RetVal, typename P1, typename P2, typename P3, typename P4> void VMValidateSignature (VMFunction* func)
594
- {
595
- VMCheckParamCount<RetVal>(func, 4 );
596
- VMCheckReturn<RetVal>(func);
597
- VMCheckParam<P1>(func, 0 );
598
- VMCheckParam<P2>(func, 1 );
599
- VMCheckParam<P3>(func, 2 );
600
- VMCheckParam<P4>(func, 3 );
601
- }
602
-
603
- template <typename RetVal, typename P1, typename P2, typename P3, typename P4, typename P5> void VMValidateSignature (VMFunction* func)
604
- {
605
- VMCheckParamCount<RetVal>(func, 5 );
606
- VMCheckReturn<RetVal>(func);
607
- VMCheckParam<P1>(func, 0 );
608
- VMCheckParam<P2>(func, 1 );
609
- VMCheckParam<P3>(func, 2 );
610
- VMCheckParam<P4>(func, 3 );
611
- VMCheckParam<P5>(func, 4 );
612
- }
613
-
614
- template <typename RetVal, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6> void VMValidateSignature (VMFunction* func)
615
- {
616
- VMCheckParamCount<RetVal>(func, 6 );
617
- VMCheckReturn<RetVal>(func);
618
- VMCheckParam<P1>(func, 0 );
619
- VMCheckParam<P2>(func, 1 );
620
- VMCheckParam<P3>(func, 2 );
621
- VMCheckParam<P4>(func, 3 );
622
- VMCheckParam<P5>(func, 4 );
623
- VMCheckParam<P6>(func, 5 );
624
- }
625
-
626
- template <typename RetVal, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7> void VMValidateSignature (VMFunction* func)
627
- {
628
- VMCheckParamCount<RetVal>(func, 7 );
629
- VMCheckReturn<RetVal>(func);
630
- VMCheckParam<P1>(func, 0 );
631
- VMCheckParam<P2>(func, 1 );
632
- VMCheckParam<P3>(func, 2 );
633
- VMCheckParam<P4>(func, 3 );
634
- VMCheckParam<P5>(func, 4 );
635
- VMCheckParam<P6>(func, 5 );
636
- VMCheckParam<P7>(func, 6 );
568
+ (VMCheckParam<Args>(func, I)...);
637
569
}
638
570
639
571
void VMCallCheckResult (VMFunction* func, VMValue* params, int numparams, VMReturn* results, int numresults);
640
572
641
- template <typename RetVal, typename P1>
642
- typename VMReturnTypeTrait<RetVal>::type VMCallScript (VMFunction* func, P1 p1)
643
- {
644
- VMValidateSignature<RetVal, P1>(func);
645
- VMValue params[] = { p1 };
646
- RetVal resultval; VMReturn results (&resultval);
647
- VMCallCheckResult (func, params, 1 , &results, 1 );
648
- return resultval;
649
- }
650
-
651
- template <typename RetVal, typename P1, typename P2>
652
- typename VMReturnTypeTrait<RetVal>::type VMCallScript (VMFunction* func, P1 p1, P2 p2)
653
- {
654
- VMValidateSignature<RetVal, P1, P2>(func);
655
- VMValue params[] = { p1, p2 };
656
- RetVal resultval; VMReturn results (&resultval);
657
- VMCallCheckResult (func, params, 2 , &results, 1 );
658
- return resultval;
659
- }
660
-
661
- template <typename RetVal, typename P1, typename P2, typename P3>
662
- typename VMReturnTypeTrait<RetVal>::type VMCallScript (VMFunction* func, P1 p1, P2 p2, P3 p3)
573
+ template <typename RetVal, typename ... Args>
574
+ typename VMReturnTypeTrait<RetVal>::type VMCallSingle (VMFunction* func, Args... args)
663
575
{
664
- VMValidateSignature<RetVal, P1, P2, P3 >(func);
665
- VMValue params[] = { p1, p2, p3 };
576
+ VMValidateSignature<RetVal, Args... >(func);
577
+ VMValue params[] = { args... };
666
578
RetVal resultval; VMReturn results (&resultval);
667
- VMCallCheckResult (func, params, 3 , &results, 1 );
579
+ VMCallCheckResult (func, params, sizeof ...(Args) , &results, 1 );
668
580
return resultval;
669
581
}
670
582
671
- template <typename RetVal, typename P1, typename P2, typename P3, typename P4>
672
- typename VMReturnTypeTrait<RetVal>::type VMCallScript (VMFunction* func, P1 p1, P2 p2, P3 p3, P4 p4)
673
- {
674
- VMValidateSignature<RetVal, P1, P2, P3, P4>(func);
675
- VMValue params[] = { p1, p2, p3, p4 };
676
- RetVal resultval; VMReturn results (&resultval);
677
- VMCallCheckResult (func, params, 4 , &results, 1 );
678
- return resultval;
679
- }
680
-
681
- template <typename RetVal, typename P1, typename P2, typename P3, typename P4, typename P5>
682
- typename VMReturnTypeTrait<RetVal>::type VMCallScript (VMFunction* func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
683
- {
684
- VMValidateSignature<RetVal, P1, P2, P3, P4, P5>(func);
685
- VMValue params[] = { p1, p2, p3, p4, p5 };
686
- RetVal resultval; VMReturn results (&resultval);
687
- VMCallCheckResult (func, params, 5 , &results, 1 );
688
- return resultval;
689
- }
690
-
691
- template <typename RetVal, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
692
- typename VMReturnTypeTrait<RetVal>::type VMCallScript (VMFunction* func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
693
- {
694
- VMValidateSignature<RetVal, P1, P2, P3, P4, P5, P6>(func);
695
- VMValue params[] = { p1, p2, p3, p4, p5, p6 };
696
- RetVal resultval; VMReturn results (&resultval);
697
- VMCallCheckResult (func, params, 6 , &results, 1 );
698
- return resultval;
699
- }
700
-
701
- template <typename RetVal, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
702
- typename VMReturnTypeTrait<RetVal>::type VMCallScript (VMFunction* func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7)
703
- {
704
- VMValidateSignature<RetVal, P1, P2, P3, P4, P5, P6, P7>(func);
705
- VMValue params[] = { p1, p2, p3, p4, p5, p6, p7 };
706
- RetVal resultval; VMReturn results (&resultval);
707
- VMCallCheckResult (func, params, 7 , &results, 1 );
708
- return resultval;
709
- }
710
-
711
- template <typename P1>
712
- typename VMReturnTypeTrait<void >::type VMCallScript (VMFunction* func, P1 p1)
583
+ template <typename ... Args>
584
+ typename VMReturnTypeTrait<void >::type VMCallSingle (VMFunction* func, Args... args)
713
585
{
714
586
VMValidateSignature<void , P1>(func);
715
- VMValue params[1 ] = { p1 };
716
- VMCallCheckResult (func, params, 1 , nullptr , 0 );
717
- }
718
-
719
- template <typename P1, typename P2>
720
- typename VMReturnTypeTrait<void >::type VMCallScript (VMFunction* func, P1 p1, P2 p2)
721
- {
722
- VMValidateSignature<void , P1, P2>(func);
723
- VMValue params[] = { p1, p2 };
724
- VMCallCheckResult (func, params, 2 , nullptr , 0 );
725
- }
726
-
727
- template <typename P1, typename P2, typename P3>
728
- typename VMReturnTypeTrait<void >::type VMCallScript (VMFunction* func, P1 p1, P2 p2, P3 p3)
729
- {
730
- VMValidateSignature<void , P1, P2, P3>(func);
731
- VMValue params[] = { p1, p2, p3 };
732
- VMCallCheckResult (func, params, 3 , nullptr , 0 );
733
- }
734
-
735
- template <typename P1, typename P2, typename P3, typename P4>
736
- typename VMReturnTypeTrait<void >::type VMCallScript (VMFunction* func, P1 p1, P2 p2, P3 p3, P4 p4)
737
- {
738
- VMValidateSignature<void , P1, P2, P3, P4>(func);
739
- VMValue params[] = { p1, p2, p3, p4 };
740
- VMCallCheckResult (func, params, 4 , nullptr , 0 );
587
+ VMValue params[] = { args... };
588
+ VMCallCheckResult (func, params, sizeof ...(Args), nullptr , 0 );
741
589
}
742
590
743
- template <typename P1, typename P2, typename P3, typename P4, typename P5>
744
- typename VMReturnTypeTrait<void >::type VMCallScript (VMFunction* func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
745
- {
746
- VMValidateSignature<void , P1, P2, P3, P4, P5>(func);
747
- VMValue params[] = { p1, p2, p3, p4, p5 };
748
- VMCallCheckResult (func, params, 5 , nullptr , 0 );
749
- }
750
-
751
- template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
752
- typename VMReturnTypeTrait<void >::type VMCallScript (VMFunction* func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
753
- {
754
- VMValidateSignature<void , P1, P2, P3, P4, P5, P6>(func);
755
- VMValue params[] = { p1, p2, p3, p4, p5, p6 };
756
- VMCallCheckResult (func, params, 6 , nullptr , 0 );
757
- }
758
-
759
- template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
760
- typename VMReturnTypeTrait<void >::type VMCallScript (VMFunction* func, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7)
761
- {
762
- VMValidateSignature<void , P1, P2, P3, P4, P5, P6, P7>(func);
763
- VMValue params[] = { p1, p2, p3, p4, p5, p6, p7 };
764
- VMCallCheckResult (func, params, 7 , nullptr , 0 );
765
- }
766
591
767
592
// Use these to collect the parameters in a native function.
768
593
// variable name <x> at position <p>
0 commit comments