perlvdb_oohelpers.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "perlvdb_oohelpers.h"
00028
00029 #include "../../mem/mem.h"
00030
00031 SV *perlvdb_perlmethod(SV *class,
00032 const char* method,
00033 SV *param1,
00034 SV *param2,
00035 SV *param3,
00036 SV *param4) {
00037
00038 I32 res;
00039 SV *retval = NULL;
00040
00041 dSP;
00042
00043 ENTER;
00044 SAVETMPS;
00045
00046 PUSHMARK(SP);
00047
00048
00049
00050
00051 XPUSHs(class);
00052
00053 if (param1) {
00054 XPUSHs(param1);
00055 }
00056
00057 if (param2) {
00058 XPUSHs(param2);
00059 }
00060
00061 if (param3) {
00062 XPUSHs(param3);
00063 }
00064
00065 if (param4) {
00066 XPUSHs(param4);
00067 }
00068
00069 PUTBACK;
00070
00071 res = call_method(method, G_SCALAR | G_EVAL);
00072
00073 SPAGAIN;
00074
00075 if (res == 0) {
00076 retval = &PL_sv_undef;
00077 } else if (res == 1) {
00078 retval = POPs;
00079 } else {
00080
00081 LM_CRIT("got more than one result from scalar method!");
00082 while (res--) {
00083
00084 retval = POPs;
00085 }
00086 }
00087
00088 SPAGAIN;
00089
00090
00091 SvREFCNT_inc(retval);
00092
00093 FREETMPS;
00094 LEAVE;
00095
00096 return retval;
00097 }
00098