| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#ifdef NO_TRAILING_USCORE |
| 10 |
|
| 11 |
#define PGFUNX pgfunx |
| 12 |
#define PGFUNY pgfuny |
| 13 |
#define PGFUNT pgfunt |
| 14 |
#define PGCONX pgconx |
| 15 |
|
| 16 |
#else |
| 17 |
|
| 18 |
#define PGFUNX pgfunx_ |
| 19 |
#define PGFUNY pgfuny_ |
| 20 |
#define PGFUNT pgfunt_ |
| 21 |
#define PGCONX pgconx_ |
| 22 |
|
| 23 |
#endif |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
static SV* pgfunname[2]; |
| 29 |
float pgfun1(float *x); |
| 30 |
float pgfun2(float *x); |
| 31 |
void pgfunplot(int *visible,float *x, float *y, float *z); |
| 32 |
void PGFUNX(float fy(), int *n, float *xmin, float *xmax, int *pgflag); |
| 33 |
void PGFUNY(float fx(), int *n, float *ymin, float *ymax, int *pgflag); |
| 34 |
void PGFUNT(float fx(), float fy(), int *n, float *tmin, float *tmax, int *pgflag); |
| 35 |
void PGCONX(float *a, int *idim, int *jdim, int *i1, int *i2, int *j1, int *j2, |
| 36 |
float *c, int *nc, void plot()); |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
void cpgfunx (float pgfun1(), int n, float xmin, float xmax, int pgflag) { |
| 48 |
|
| 49 |
PGFUNX(pgfun1,&n,&xmin,&xmax,&pgflag); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
void cpgfuny (float pgfun1(), int n, float ymin, float ymax, int pgflag) { |
| 54 |
|
| 55 |
PGFUNY(pgfun1,&n,&ymin,&ymax,&pgflag); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
void cpgfunt (float pgfun1(), float pgfun2(), int n, float tmin, float tmax, |
| 60 |
int pgflag) { |
| 61 |
|
| 62 |
PGFUNT(pgfun1,pgfun2,&n,&tmin,&tmax,&pgflag); |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
void cpgconx ( float* a, int idim, int jdim, int i1, int i2, |
| 67 |
int j1, int j2, float* c, int nc, void pgfunplot()) { |
| 68 |
|
| 69 |
PGCONX(a,&idim,&jdim,&i1,&i2,&j1,&j2,c,&nc,pgfunplot); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
float pgfun1(float *x) { |
| 79 |
|
| 80 |
dSP ; |
| 81 |
int count; |
| 82 |
SV* funname; |
| 83 |
float retval; |
| 84 |
|
| 85 |
funname = pgfunname[0]; |
| 86 |
|
| 87 |
ENTER ; |
| 88 |
SAVETMPS ; |
| 89 |
|
| 90 |
PUSHMARK(sp) ; |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
XPUSHs(sv_2mortal(newSVnv(*x))); |
| 95 |
|
| 96 |
PUTBACK ; |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
count = perl_call_sv(funname, G_SCALAR); |
| 101 |
|
| 102 |
SPAGAIN; |
| 103 |
|
| 104 |
if (count !=1) |
| 105 |
croak("Error calling perl function\n"); |
| 106 |
|
| 107 |
retval = (float) POPn ; |
| 108 |
|
| 109 |
PUTBACK ; |
| 110 |
FREETMPS ; |
| 111 |
LEAVE ; |
| 112 |
|
| 113 |
return retval; |
| 114 |
} |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
float pgfun2(float *x) { |
| 120 |
|
| 121 |
dSP ; |
| 122 |
int count; |
| 123 |
SV* funname; |
| 124 |
float retval; |
| 125 |
|
| 126 |
funname = pgfunname[1]; |
| 127 |
|
| 128 |
ENTER ; |
| 129 |
SAVETMPS ; |
| 130 |
|
| 131 |
PUSHMARK(sp) ; |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
XPUSHs(sv_2mortal(newSVnv(*x))); |
| 136 |
|
| 137 |
PUTBACK ; |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
count = perl_call_sv(funname, G_SCALAR); |
| 142 |
|
| 143 |
SPAGAIN; |
| 144 |
|
| 145 |
if (count !=1) |
| 146 |
croak("Error calling perl function\n"); |
| 147 |
|
| 148 |
retval = (float) POPn ; |
| 149 |
|
| 150 |
PUTBACK ; |
| 151 |
FREETMPS ; |
| 152 |
LEAVE ; |
| 153 |
|
| 154 |
return retval; |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
void pgfunplot(int *visible, float *x, float *y, float *z) { |
| 160 |
|
| 161 |
dSP ; |
| 162 |
int count; |
| 163 |
SV* funname; |
| 164 |
float retval; |
| 165 |
|
| 166 |
funname = pgfunname[0]; |
| 167 |
|
| 168 |
ENTER ; |
| 169 |
SAVETMPS ; |
| 170 |
|
| 171 |
PUSHMARK(sp) ; |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
XPUSHs(sv_2mortal(newSViv(*visible))); |
| 176 |
XPUSHs(sv_2mortal(newSVnv(*x))); |
| 177 |
XPUSHs(sv_2mortal(newSVnv(*y))); |
| 178 |
XPUSHs(sv_2mortal(newSVnv(*z))); |
| 179 |
|
| 180 |
PUTBACK ; |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
count = perl_call_sv(funname, G_SCALAR); |
| 185 |
|
| 186 |
SPAGAIN; |
| 187 |
|
| 188 |
if (count !=1) |
| 189 |
croak("Error calling perl function\n"); |
| 190 |
|
| 191 |
|
| 192 |
PUTBACK ; |
| 193 |
FREETMPS ; |
| 194 |
LEAVE ; |
| 195 |
} |
| 196 |
|