| 1 |
/* DO NOT MODIFY THIS FILE it is generated from these files: |
| 2 |
* inc/template/accessor.tt |
| 3 |
* inc/template/accessor_wrapper.tt |
| 4 |
* inc/run/generate_record_accessor.pl |
| 5 |
*/ |
| 6 |
#include "EXTERN.h" |
| 7 |
#include "perl.h" |
| 8 |
#include "XSUB.h" |
| 9 |
#include "ppport.h" |
| 10 |
#include "ffi_platypus.h" |
| 11 |
#include "ffi_platypus_guts.h" |
| 12 |
|
| 13 |
|
| 14 |
XS(ffi_pl_record_accessor_uint8) |
| 15 |
{ |
| 16 |
ffi_pl_record_member *member; |
| 17 |
SV *self; |
| 18 |
char *ptr1; |
| 19 |
uint8_t *ptr2; |
| 20 |
|
| 21 |
dVAR; dXSARGS; |
| 22 |
|
| 23 |
if(items == 0) |
| 24 |
croak("This is a method, you must provide at least the object"); |
| 25 |
|
| 26 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 27 |
|
| 28 |
self = ST(0); |
| 29 |
if(SvROK(self)) |
| 30 |
self = SvRV(self); |
| 31 |
|
| 32 |
if(!SvOK(self)) |
| 33 |
croak("Null record error"); |
| 34 |
|
| 35 |
ptr1 = (char*) SvPV_nolen(self); |
| 36 |
ptr2 = (uint8_t*) &ptr1[member->offset]; |
| 37 |
|
| 38 |
if(items > 1) |
| 39 |
{ |
| 40 |
if(SvREADONLY(self)) |
| 41 |
{ |
| 42 |
croak("record is read-only"); |
| 43 |
} |
| 44 |
else |
| 45 |
{ |
| 46 |
*ptr2 = (uint8_t) SvUV(ST(1)); |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
if(GIMME_V == G_VOID) |
| 51 |
XSRETURN_EMPTY; |
| 52 |
|
| 53 |
XSRETURN_UV(*ptr2); |
| 54 |
} |
| 55 |
|
| 56 |
XS(ffi_pl_record_accessor_uint8_array) |
| 57 |
{ |
| 58 |
ffi_pl_record_member *member; |
| 59 |
SV *self; |
| 60 |
SV *arg; |
| 61 |
SV **item; |
| 62 |
AV *av; |
| 63 |
char *ptr1; |
| 64 |
int i; |
| 65 |
uint8_t *ptr2; |
| 66 |
|
| 67 |
dVAR; dXSARGS; |
| 68 |
|
| 69 |
if(items == 0) |
| 70 |
croak("This is a method, you must provide at least the object"); |
| 71 |
|
| 72 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 73 |
|
| 74 |
self = ST(0); |
| 75 |
if(SvROK(self)) |
| 76 |
self = SvRV(self); |
| 77 |
|
| 78 |
ptr1 = (char*) SvPV_nolen(self); |
| 79 |
ptr2 = (uint8_t*) &ptr1[member->offset]; |
| 80 |
|
| 81 |
if(items > 1 && SvREADONLY(self)) |
| 82 |
{ |
| 83 |
croak("record is read-only"); |
| 84 |
} |
| 85 |
|
| 86 |
if(items > 2) |
| 87 |
{ |
| 88 |
i = SvIV(ST(1)); |
| 89 |
if(i >= 0 && i < member->count) |
| 90 |
{ |
| 91 |
arg = ST(2); |
| 92 |
ptr2[i] = SvUV(arg); |
| 93 |
} |
| 94 |
else |
| 95 |
{ |
| 96 |
warn("illegal index %d", i); |
| 97 |
} |
| 98 |
} |
| 99 |
else if(items > 1) |
| 100 |
{ |
| 101 |
arg = ST(1); |
| 102 |
if(SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVAV) |
| 103 |
{ |
| 104 |
av = (AV*) SvRV(arg); |
| 105 |
for(i=0; i < member->count; i++) |
| 106 |
{ |
| 107 |
item = av_fetch(av, i, 0); |
| 108 |
if(item != NULL && SvOK(*item)) |
| 109 |
{ |
| 110 |
ptr2[i] = SvUV(*item); |
| 111 |
} |
| 112 |
else |
| 113 |
{ |
| 114 |
ptr2[i] = 0; |
| 115 |
} |
| 116 |
} |
| 117 |
} |
| 118 |
else |
| 119 |
{ |
| 120 |
i = SvIV(ST(1)); |
| 121 |
if(i >= 0 && i < member->count) |
| 122 |
{ |
| 123 |
XSRETURN_UV(ptr2[i]); |
| 124 |
} |
| 125 |
else |
| 126 |
{ |
| 127 |
warn("illegal index %d", i); |
| 128 |
XSRETURN_EMPTY; |
| 129 |
} |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
if(GIMME_V == G_VOID) |
| 134 |
XSRETURN_EMPTY; |
| 135 |
|
| 136 |
av = newAV(); |
| 137 |
av_fill(av, member->count-1); |
| 138 |
for(i=0; i < member->count; i++) |
| 139 |
{ |
| 140 |
sv_setuv(*av_fetch(av, i, 1), ptr2[i]); |
| 141 |
} |
| 142 |
ST(0) = newRV_inc((SV*)av); |
| 143 |
XSRETURN(1); |
| 144 |
} |
| 145 |
|
| 146 |
XS(ffi_pl_record_accessor_sint8) |
| 147 |
{ |
| 148 |
ffi_pl_record_member *member; |
| 149 |
SV *self; |
| 150 |
char *ptr1; |
| 151 |
int8_t *ptr2; |
| 152 |
|
| 153 |
dVAR; dXSARGS; |
| 154 |
|
| 155 |
if(items == 0) |
| 156 |
croak("This is a method, you must provide at least the object"); |
| 157 |
|
| 158 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 159 |
|
| 160 |
self = ST(0); |
| 161 |
if(SvROK(self)) |
| 162 |
self = SvRV(self); |
| 163 |
|
| 164 |
if(!SvOK(self)) |
| 165 |
croak("Null record error"); |
| 166 |
|
| 167 |
ptr1 = (char*) SvPV_nolen(self); |
| 168 |
ptr2 = (int8_t*) &ptr1[member->offset]; |
| 169 |
|
| 170 |
if(items > 1) |
| 171 |
{ |
| 172 |
if(SvREADONLY(self)) |
| 173 |
{ |
| 174 |
croak("record is read-only"); |
| 175 |
} |
| 176 |
else |
| 177 |
{ |
| 178 |
*ptr2 = (int8_t) SvIV(ST(1)); |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
if(GIMME_V == G_VOID) |
| 183 |
XSRETURN_EMPTY; |
| 184 |
|
| 185 |
XSRETURN_IV(*ptr2); |
| 186 |
} |
| 187 |
|
| 188 |
XS(ffi_pl_record_accessor_sint8_array) |
| 189 |
{ |
| 190 |
ffi_pl_record_member *member; |
| 191 |
SV *self; |
| 192 |
SV *arg; |
| 193 |
SV **item; |
| 194 |
AV *av; |
| 195 |
char *ptr1; |
| 196 |
int i; |
| 197 |
int8_t *ptr2; |
| 198 |
|
| 199 |
dVAR; dXSARGS; |
| 200 |
|
| 201 |
if(items == 0) |
| 202 |
croak("This is a method, you must provide at least the object"); |
| 203 |
|
| 204 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 205 |
|
| 206 |
self = ST(0); |
| 207 |
if(SvROK(self)) |
| 208 |
self = SvRV(self); |
| 209 |
|
| 210 |
ptr1 = (char*) SvPV_nolen(self); |
| 211 |
ptr2 = (int8_t*) &ptr1[member->offset]; |
| 212 |
|
| 213 |
if(items > 1 && SvREADONLY(self)) |
| 214 |
{ |
| 215 |
croak("record is read-only"); |
| 216 |
} |
| 217 |
|
| 218 |
if(items > 2) |
| 219 |
{ |
| 220 |
i = SvIV(ST(1)); |
| 221 |
if(i >= 0 && i < member->count) |
| 222 |
{ |
| 223 |
arg = ST(2); |
| 224 |
ptr2[i] = SvIV(arg); |
| 225 |
} |
| 226 |
else |
| 227 |
{ |
| 228 |
warn("illegal index %d", i); |
| 229 |
} |
| 230 |
} |
| 231 |
else if(items > 1) |
| 232 |
{ |
| 233 |
arg = ST(1); |
| 234 |
if(SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVAV) |
| 235 |
{ |
| 236 |
av = (AV*) SvRV(arg); |
| 237 |
for(i=0; i < member->count; i++) |
| 238 |
{ |
| 239 |
item = av_fetch(av, i, 0); |
| 240 |
if(item != NULL && SvOK(*item)) |
| 241 |
{ |
| 242 |
ptr2[i] = SvIV(*item); |
| 243 |
} |
| 244 |
else |
| 245 |
{ |
| 246 |
ptr2[i] = 0; |
| 247 |
} |
| 248 |
} |
| 249 |
} |
| 250 |
else |
| 251 |
{ |
| 252 |
i = SvIV(ST(1)); |
| 253 |
if(i >= 0 && i < member->count) |
| 254 |
{ |
| 255 |
XSRETURN_IV(ptr2[i]); |
| 256 |
} |
| 257 |
else |
| 258 |
{ |
| 259 |
warn("illegal index %d", i); |
| 260 |
XSRETURN_EMPTY; |
| 261 |
} |
| 262 |
} |
| 263 |
} |
| 264 |
|
| 265 |
if(GIMME_V == G_VOID) |
| 266 |
XSRETURN_EMPTY; |
| 267 |
|
| 268 |
av = newAV(); |
| 269 |
av_fill(av, member->count-1); |
| 270 |
for(i=0; i < member->count; i++) |
| 271 |
{ |
| 272 |
sv_setiv(*av_fetch(av, i, 1), ptr2[i]); |
| 273 |
} |
| 274 |
ST(0) = newRV_inc((SV*)av); |
| 275 |
XSRETURN(1); |
| 276 |
} |
| 277 |
|
| 278 |
XS(ffi_pl_record_accessor_uint16) |
| 279 |
{ |
| 280 |
ffi_pl_record_member *member; |
| 281 |
SV *self; |
| 282 |
char *ptr1; |
| 283 |
uint16_t *ptr2; |
| 284 |
|
| 285 |
dVAR; dXSARGS; |
| 286 |
|
| 287 |
if(items == 0) |
| 288 |
croak("This is a method, you must provide at least the object"); |
| 289 |
|
| 290 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 291 |
|
| 292 |
self = ST(0); |
| 293 |
if(SvROK(self)) |
| 294 |
self = SvRV(self); |
| 295 |
|
| 296 |
if(!SvOK(self)) |
| 297 |
croak("Null record error"); |
| 298 |
|
| 299 |
ptr1 = (char*) SvPV_nolen(self); |
| 300 |
ptr2 = (uint16_t*) &ptr1[member->offset]; |
| 301 |
|
| 302 |
if(items > 1) |
| 303 |
{ |
| 304 |
if(SvREADONLY(self)) |
| 305 |
{ |
| 306 |
croak("record is read-only"); |
| 307 |
} |
| 308 |
else |
| 309 |
{ |
| 310 |
*ptr2 = (uint16_t) SvUV(ST(1)); |
| 311 |
} |
| 312 |
} |
| 313 |
|
| 314 |
if(GIMME_V == G_VOID) |
| 315 |
XSRETURN_EMPTY; |
| 316 |
|
| 317 |
XSRETURN_UV(*ptr2); |
| 318 |
} |
| 319 |
|
| 320 |
XS(ffi_pl_record_accessor_uint16_array) |
| 321 |
{ |
| 322 |
ffi_pl_record_member *member; |
| 323 |
SV *self; |
| 324 |
SV *arg; |
| 325 |
SV **item; |
| 326 |
AV *av; |
| 327 |
char *ptr1; |
| 328 |
int i; |
| 329 |
uint16_t *ptr2; |
| 330 |
|
| 331 |
dVAR; dXSARGS; |
| 332 |
|
| 333 |
if(items == 0) |
| 334 |
croak("This is a method, you must provide at least the object"); |
| 335 |
|
| 336 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 337 |
|
| 338 |
self = ST(0); |
| 339 |
if(SvROK(self)) |
| 340 |
self = SvRV(self); |
| 341 |
|
| 342 |
ptr1 = (char*) SvPV_nolen(self); |
| 343 |
ptr2 = (uint16_t*) &ptr1[member->offset]; |
| 344 |
|
| 345 |
if(items > 1 && SvREADONLY(self)) |
| 346 |
{ |
| 347 |
croak("record is read-only"); |
| 348 |
} |
| 349 |
|
| 350 |
if(items > 2) |
| 351 |
{ |
| 352 |
i = SvIV(ST(1)); |
| 353 |
if(i >= 0 && i < member->count) |
| 354 |
{ |
| 355 |
arg = ST(2); |
| 356 |
ptr2[i] = SvUV(arg); |
| 357 |
} |
| 358 |
else |
| 359 |
{ |
| 360 |
warn("illegal index %d", i); |
| 361 |
} |
| 362 |
} |
| 363 |
else if(items > 1) |
| 364 |
{ |
| 365 |
arg = ST(1); |
| 366 |
if(SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVAV) |
| 367 |
{ |
| 368 |
av = (AV*) SvRV(arg); |
| 369 |
for(i=0; i < member->count; i++) |
| 370 |
{ |
| 371 |
item = av_fetch(av, i, 0); |
| 372 |
if(item != NULL && SvOK(*item)) |
| 373 |
{ |
| 374 |
ptr2[i] = SvUV(*item); |
| 375 |
} |
| 376 |
else |
| 377 |
{ |
| 378 |
ptr2[i] = 0; |
| 379 |
} |
| 380 |
} |
| 381 |
} |
| 382 |
else |
| 383 |
{ |
| 384 |
i = SvIV(ST(1)); |
| 385 |
if(i >= 0 && i < member->count) |
| 386 |
{ |
| 387 |
XSRETURN_UV(ptr2[i]); |
| 388 |
} |
| 389 |
else |
| 390 |
{ |
| 391 |
warn("illegal index %d", i); |
| 392 |
XSRETURN_EMPTY; |
| 393 |
} |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
if(GIMME_V == G_VOID) |
| 398 |
XSRETURN_EMPTY; |
| 399 |
|
| 400 |
av = newAV(); |
| 401 |
av_fill(av, member->count-1); |
| 402 |
for(i=0; i < member->count; i++) |
| 403 |
{ |
| 404 |
sv_setuv(*av_fetch(av, i, 1), ptr2[i]); |
| 405 |
} |
| 406 |
ST(0) = newRV_inc((SV*)av); |
| 407 |
XSRETURN(1); |
| 408 |
} |
| 409 |
|
| 410 |
XS(ffi_pl_record_accessor_sint16) |
| 411 |
{ |
| 412 |
ffi_pl_record_member *member; |
| 413 |
SV *self; |
| 414 |
char *ptr1; |
| 415 |
int16_t *ptr2; |
| 416 |
|
| 417 |
dVAR; dXSARGS; |
| 418 |
|
| 419 |
if(items == 0) |
| 420 |
croak("This is a method, you must provide at least the object"); |
| 421 |
|
| 422 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 423 |
|
| 424 |
self = ST(0); |
| 425 |
if(SvROK(self)) |
| 426 |
self = SvRV(self); |
| 427 |
|
| 428 |
if(!SvOK(self)) |
| 429 |
croak("Null record error"); |
| 430 |
|
| 431 |
ptr1 = (char*) SvPV_nolen(self); |
| 432 |
ptr2 = (int16_t*) &ptr1[member->offset]; |
| 433 |
|
| 434 |
if(items > 1) |
| 435 |
{ |
| 436 |
if(SvREADONLY(self)) |
| 437 |
{ |
| 438 |
croak("record is read-only"); |
| 439 |
} |
| 440 |
else |
| 441 |
{ |
| 442 |
*ptr2 = (int16_t) SvIV(ST(1)); |
| 443 |
} |
| 444 |
} |
| 445 |
|
| 446 |
if(GIMME_V == G_VOID) |
| 447 |
XSRETURN_EMPTY; |
| 448 |
|
| 449 |
XSRETURN_IV(*ptr2); |
| 450 |
} |
| 451 |
|
| 452 |
XS(ffi_pl_record_accessor_sint16_array) |
| 453 |
{ |
| 454 |
ffi_pl_record_member *member; |
| 455 |
SV *self; |
| 456 |
SV *arg; |
| 457 |
SV **item; |
| 458 |
AV *av; |
| 459 |
char *ptr1; |
| 460 |
int i; |
| 461 |
int16_t *ptr2; |
| 462 |
|
| 463 |
dVAR; dXSARGS; |
| 464 |
|
| 465 |
if(items == 0) |
| 466 |
croak("This is a method, you must provide at least the object"); |
| 467 |
|
| 468 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 469 |
|
| 470 |
self = ST(0); |
| 471 |
if(SvROK(self)) |
| 472 |
self = SvRV(self); |
| 473 |
|
| 474 |
ptr1 = (char*) SvPV_nolen(self); |
| 475 |
ptr2 = (int16_t*) &ptr1[member->offset]; |
| 476 |
|
| 477 |
if(items > 1 && SvREADONLY(self)) |
| 478 |
{ |
| 479 |
croak("record is read-only"); |
| 480 |
} |
| 481 |
|
| 482 |
if(items > 2) |
| 483 |
{ |
| 484 |
i = SvIV(ST(1)); |
| 485 |
if(i >= 0 && i < member->count) |
| 486 |
{ |
| 487 |
arg = ST(2); |
| 488 |
ptr2[i] = SvIV(arg); |
| 489 |
} |
| 490 |
else |
| 491 |
{ |
| 492 |
warn("illegal index %d", i); |
| 493 |
} |
| 494 |
} |
| 495 |
else if(items > 1) |
| 496 |
{ |
| 497 |
arg = ST(1); |
| 498 |
if(SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVAV) |
| 499 |
{ |
| 500 |
av = (AV*) SvRV(arg); |
| 501 |
for(i=0; i < member->count; i++) |
| 502 |
{ |
| 503 |
item = av_fetch(av, i, 0); |
| 504 |
if(item != NULL && SvOK(*item)) |
| 505 |
{ |
| 506 |
ptr2[i] = SvIV(*item); |
| 507 |
} |
| 508 |
else |
| 509 |
{ |
| 510 |
ptr2[i] = 0; |
| 511 |
} |
| 512 |
} |
| 513 |
} |
| 514 |
else |
| 515 |
{ |
| 516 |
i = SvIV(ST(1)); |
| 517 |
if(i >= 0 && i < member->count) |
| 518 |
{ |
| 519 |
XSRETURN_IV(ptr2[i]); |
| 520 |
} |
| 521 |
else |
| 522 |
{ |
| 523 |
warn("illegal index %d", i); |
| 524 |
XSRETURN_EMPTY; |
| 525 |
} |
| 526 |
} |
| 527 |
} |
| 528 |
|
| 529 |
if(GIMME_V == G_VOID) |
| 530 |
XSRETURN_EMPTY; |
| 531 |
|
| 532 |
av = newAV(); |
| 533 |
av_fill(av, member->count-1); |
| 534 |
for(i=0; i < member->count; i++) |
| 535 |
{ |
| 536 |
sv_setiv(*av_fetch(av, i, 1), ptr2[i]); |
| 537 |
} |
| 538 |
ST(0) = newRV_inc((SV*)av); |
| 539 |
XSRETURN(1); |
| 540 |
} |
| 541 |
|
| 542 |
XS(ffi_pl_record_accessor_uint32) |
| 543 |
{ |
| 544 |
ffi_pl_record_member *member; |
| 545 |
SV *self; |
| 546 |
char *ptr1; |
| 547 |
uint32_t *ptr2; |
| 548 |
|
| 549 |
dVAR; dXSARGS; |
| 550 |
|
| 551 |
if(items == 0) |
| 552 |
croak("This is a method, you must provide at least the object"); |
| 553 |
|
| 554 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 555 |
|
| 556 |
self = ST(0); |
| 557 |
if(SvROK(self)) |
| 558 |
self = SvRV(self); |
| 559 |
|
| 560 |
if(!SvOK(self)) |
| 561 |
croak("Null record error"); |
| 562 |
|
| 563 |
ptr1 = (char*) SvPV_nolen(self); |
| 564 |
ptr2 = (uint32_t*) &ptr1[member->offset]; |
| 565 |
|
| 566 |
if(items > 1) |
| 567 |
{ |
| 568 |
if(SvREADONLY(self)) |
| 569 |
{ |
| 570 |
croak("record is read-only"); |
| 571 |
} |
| 572 |
else |
| 573 |
{ |
| 574 |
*ptr2 = (uint32_t) SvUV(ST(1)); |
| 575 |
} |
| 576 |
} |
| 577 |
|
| 578 |
if(GIMME_V == G_VOID) |
| 579 |
XSRETURN_EMPTY; |
| 580 |
|
| 581 |
XSRETURN_UV(*ptr2); |
| 582 |
} |
| 583 |
|
| 584 |
XS(ffi_pl_record_accessor_uint32_array) |
| 585 |
{ |
| 586 |
ffi_pl_record_member *member; |
| 587 |
SV *self; |
| 588 |
SV *arg; |
| 589 |
SV **item; |
| 590 |
AV *av; |
| 591 |
char *ptr1; |
| 592 |
int i; |
| 593 |
uint32_t *ptr2; |
| 594 |
|
| 595 |
dVAR; dXSARGS; |
| 596 |
|
| 597 |
if(items == 0) |
| 598 |
croak("This is a method, you must provide at least the object"); |
| 599 |
|
| 600 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 601 |
|
| 602 |
self = ST(0); |
| 603 |
if(SvROK(self)) |
| 604 |
self = SvRV(self); |
| 605 |
|
| 606 |
ptr1 = (char*) SvPV_nolen(self); |
| 607 |
ptr2 = (uint32_t*) &ptr1[member->offset]; |
| 608 |
|
| 609 |
if(items > 1 && SvREADONLY(self)) |
| 610 |
{ |
| 611 |
croak("record is read-only"); |
| 612 |
} |
| 613 |
|
| 614 |
if(items > 2) |
| 615 |
{ |
| 616 |
i = SvIV(ST(1)); |
| 617 |
if(i >= 0 && i < member->count) |
| 618 |
{ |
| 619 |
arg = ST(2); |
| 620 |
ptr2[i] = SvUV(arg); |
| 621 |
} |
| 622 |
else |
| 623 |
{ |
| 624 |
warn("illegal index %d", i); |
| 625 |
} |
| 626 |
} |
| 627 |
else if(items > 1) |
| 628 |
{ |
| 629 |
arg = ST(1); |
| 630 |
if(SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVAV) |
| 631 |
{ |
| 632 |
av = (AV*) SvRV(arg); |
| 633 |
for(i=0; i < member->count; i++) |
| 634 |
{ |
| 635 |
item = av_fetch(av, i, 0); |
| 636 |
if(item != NULL && SvOK(*item)) |
| 637 |
{ |
| 638 |
ptr2[i] = SvUV(*item); |
| 639 |
} |
| 640 |
else |
| 641 |
{ |
| 642 |
ptr2[i] = 0; |
| 643 |
} |
| 644 |
} |
| 645 |
} |
| 646 |
else |
| 647 |
{ |
| 648 |
i = SvIV(ST(1)); |
| 649 |
if(i >= 0 && i < member->count) |
| 650 |
{ |
| 651 |
XSRETURN_UV(ptr2[i]); |
| 652 |
} |
| 653 |
else |
| 654 |
{ |
| 655 |
warn("illegal index %d", i); |
| 656 |
XSRETURN_EMPTY; |
| 657 |
} |
| 658 |
} |
| 659 |
} |
| 660 |
|
| 661 |
if(GIMME_V == G_VOID) |
| 662 |
XSRETURN_EMPTY; |
| 663 |
|
| 664 |
av = newAV(); |
| 665 |
av_fill(av, member->count-1); |
| 666 |
for(i=0; i < member->count; i++) |
| 667 |
{ |
| 668 |
sv_setuv(*av_fetch(av, i, 1), ptr2[i]); |
| 669 |
} |
| 670 |
ST(0) = newRV_inc((SV*)av); |
| 671 |
XSRETURN(1); |
| 672 |
} |
| 673 |
|
| 674 |
XS(ffi_pl_record_accessor_sint32) |
| 675 |
{ |
| 676 |
ffi_pl_record_member *member; |
| 677 |
SV *self; |
| 678 |
char *ptr1; |
| 679 |
int32_t *ptr2; |
| 680 |
|
| 681 |
dVAR; dXSARGS; |
| 682 |
|
| 683 |
if(items == 0) |
| 684 |
croak("This is a method, you must provide at least the object"); |
| 685 |
|
| 686 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 687 |
|
| 688 |
self = ST(0); |
| 689 |
if(SvROK(self)) |
| 690 |
self = SvRV(self); |
| 691 |
|
| 692 |
if(!SvOK(self)) |
| 693 |
croak("Null record error"); |
| 694 |
|
| 695 |
ptr1 = (char*) SvPV_nolen(self); |
| 696 |
ptr2 = (int32_t*) &ptr1[member->offset]; |
| 697 |
|
| 698 |
if(items > 1) |
| 699 |
{ |
| 700 |
if(SvREADONLY(self)) |
| 701 |
{ |
| 702 |
croak("record is read-only"); |
| 703 |
} |
| 704 |
else |
| 705 |
{ |
| 706 |
*ptr2 = (int32_t) SvIV(ST(1)); |
| 707 |
} |
| 708 |
} |
| 709 |
|
| 710 |
if(GIMME_V == G_VOID) |
| 711 |
XSRETURN_EMPTY; |
| 712 |
|
| 713 |
XSRETURN_IV(*ptr2); |
| 714 |
} |
| 715 |
|
| 716 |
XS(ffi_pl_record_accessor_sint32_array) |
| 717 |
{ |
| 718 |
ffi_pl_record_member *member; |
| 719 |
SV *self; |
| 720 |
SV *arg; |
| 721 |
SV **item; |
| 722 |
AV *av; |
| 723 |
char *ptr1; |
| 724 |
int i; |
| 725 |
int32_t *ptr2; |
| 726 |
|
| 727 |
dVAR; dXSARGS; |
| 728 |
|
| 729 |
if(items == 0) |
| 730 |
croak("This is a method, you must provide at least the object"); |
| 731 |
|
| 732 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 733 |
|
| 734 |
self = ST(0); |
| 735 |
if(SvROK(self)) |
| 736 |
self = SvRV(self); |
| 737 |
|
| 738 |
ptr1 = (char*) SvPV_nolen(self); |
| 739 |
ptr2 = (int32_t*) &ptr1[member->offset]; |
| 740 |
|
| 741 |
if(items > 1 && SvREADONLY(self)) |
| 742 |
{ |
| 743 |
croak("record is read-only"); |
| 744 |
} |
| 745 |
|
| 746 |
if(items > 2) |
| 747 |
{ |
| 748 |
i = SvIV(ST(1)); |
| 749 |
if(i >= 0 && i < member->count) |
| 750 |
{ |
| 751 |
arg = ST(2); |
| 752 |
ptr2[i] = SvIV(arg); |
| 753 |
} |
| 754 |
else |
| 755 |
{ |
| 756 |
warn("illegal index %d", i); |
| 757 |
} |
| 758 |
} |
| 759 |
else if(items > 1) |
| 760 |
{ |
| 761 |
arg = ST(1); |
| 762 |
if(SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVAV) |
| 763 |
{ |
| 764 |
av = (AV*) SvRV(arg); |
| 765 |
for(i=0; i < member->count; i++) |
| 766 |
{ |
| 767 |
item = av_fetch(av, i, 0); |
| 768 |
if(item != NULL && SvOK(*item)) |
| 769 |
{ |
| 770 |
ptr2[i] = SvIV(*item); |
| 771 |
} |
| 772 |
else |
| 773 |
{ |
| 774 |
ptr2[i] = 0; |
| 775 |
} |
| 776 |
} |
| 777 |
} |
| 778 |
else |
| 779 |
{ |
| 780 |
i = SvIV(ST(1)); |
| 781 |
if(i >= 0 && i < member->count) |
| 782 |
{ |
| 783 |
XSRETURN_IV(ptr2[i]); |
| 784 |
} |
| 785 |
else |
| 786 |
{ |
| 787 |
warn("illegal index %d", i); |
| 788 |
XSRETURN_EMPTY; |
| 789 |
} |
| 790 |
} |
| 791 |
} |
| 792 |
|
| 793 |
if(GIMME_V == G_VOID) |
| 794 |
XSRETURN_EMPTY; |
| 795 |
|
| 796 |
av = newAV(); |
| 797 |
av_fill(av, member->count-1); |
| 798 |
for(i=0; i < member->count; i++) |
| 799 |
{ |
| 800 |
sv_setiv(*av_fetch(av, i, 1), ptr2[i]); |
| 801 |
} |
| 802 |
ST(0) = newRV_inc((SV*)av); |
| 803 |
XSRETURN(1); |
| 804 |
} |
| 805 |
|
| 806 |
XS(ffi_pl_record_accessor_uint64) |
| 807 |
{ |
| 808 |
ffi_pl_record_member *member; |
| 809 |
SV *self; |
| 810 |
char *ptr1; |
| 811 |
uint64_t *ptr2; |
| 812 |
|
| 813 |
dVAR; dXSARGS; |
| 814 |
|
| 815 |
if(items == 0) |
| 816 |
croak("This is a method, you must provide at least the object"); |
| 817 |
|
| 818 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 819 |
|
| 820 |
self = ST(0); |
| 821 |
if(SvROK(self)) |
| 822 |
self = SvRV(self); |
| 823 |
|
| 824 |
if(!SvOK(self)) |
| 825 |
croak("Null record error"); |
| 826 |
|
| 827 |
ptr1 = (char*) SvPV_nolen(self); |
| 828 |
ptr2 = (uint64_t*) &ptr1[member->offset]; |
| 829 |
|
| 830 |
if(items > 1) |
| 831 |
{ |
| 832 |
if(SvREADONLY(self)) |
| 833 |
{ |
| 834 |
croak("record is read-only"); |
| 835 |
} |
| 836 |
else |
| 837 |
{ |
| 838 |
*ptr2 = (uint64_t) SvUV(ST(1)); |
| 839 |
} |
| 840 |
} |
| 841 |
|
| 842 |
if(GIMME_V == G_VOID) |
| 843 |
XSRETURN_EMPTY; |
| 844 |
|
| 845 |
XSRETURN_UV(*ptr2); |
| 846 |
} |
| 847 |
|
| 848 |
XS(ffi_pl_record_accessor_uint64_array) |
| 849 |
{ |
| 850 |
ffi_pl_record_member *member; |
| 851 |
SV *self; |
| 852 |
SV *arg; |
| 853 |
SV **item; |
| 854 |
AV *av; |
| 855 |
char *ptr1; |
| 856 |
int i; |
| 857 |
uint64_t *ptr2; |
| 858 |
|
| 859 |
dVAR; dXSARGS; |
| 860 |
|
| 861 |
if(items == 0) |
| 862 |
croak("This is a method, you must provide at least the object"); |
| 863 |
|
| 864 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 865 |
|
| 866 |
self = ST(0); |
| 867 |
if(SvROK(self)) |
| 868 |
self = SvRV(self); |
| 869 |
|
| 870 |
ptr1 = (char*) SvPV_nolen(self); |
| 871 |
ptr2 = (uint64_t*) &ptr1[member->offset]; |
| 872 |
|
| 873 |
if(items > 1 && SvREADONLY(self)) |
| 874 |
{ |
| 875 |
croak("record is read-only"); |
| 876 |
} |
| 877 |
|
| 878 |
if(items > 2) |
| 879 |
{ |
| 880 |
i = SvIV(ST(1)); |
| 881 |
if(i >= 0 && i < member->count) |
| 882 |
{ |
| 883 |
arg = ST(2); |
| 884 |
ptr2[i] = SvUV(arg); |
| 885 |
} |
| 886 |
else |
| 887 |
{ |
| 888 |
warn("illegal index %d", i); |
| 889 |
} |
| 890 |
} |
| 891 |
else if(items > 1) |
| 892 |
{ |
| 893 |
arg = ST(1); |
| 894 |
if(SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVAV) |
| 895 |
{ |
| 896 |
av = (AV*) SvRV(arg); |
| 897 |
for(i=0; i < member->count; i++) |
| 898 |
{ |
| 899 |
item = av_fetch(av, i, 0); |
| 900 |
if(item != NULL && SvOK(*item)) |
| 901 |
{ |
| 902 |
ptr2[i] = SvUV(*item); |
| 903 |
} |
| 904 |
else |
| 905 |
{ |
| 906 |
ptr2[i] = 0; |
| 907 |
} |
| 908 |
} |
| 909 |
} |
| 910 |
else |
| 911 |
{ |
| 912 |
i = SvIV(ST(1)); |
| 913 |
if(i >= 0 && i < member->count) |
| 914 |
{ |
| 915 |
XSRETURN_UV(ptr2[i]); |
| 916 |
} |
| 917 |
else |
| 918 |
{ |
| 919 |
warn("illegal index %d", i); |
| 920 |
XSRETURN_EMPTY; |
| 921 |
} |
| 922 |
} |
| 923 |
} |
| 924 |
|
| 925 |
if(GIMME_V == G_VOID) |
| 926 |
XSRETURN_EMPTY; |
| 927 |
|
| 928 |
av = newAV(); |
| 929 |
av_fill(av, member->count-1); |
| 930 |
for(i=0; i < member->count; i++) |
| 931 |
{ |
| 932 |
sv_setuv(*av_fetch(av, i, 1), ptr2[i]); |
| 933 |
} |
| 934 |
ST(0) = newRV_inc((SV*)av); |
| 935 |
XSRETURN(1); |
| 936 |
} |
| 937 |
|
| 938 |
XS(ffi_pl_record_accessor_sint64) |
| 939 |
{ |
| 940 |
ffi_pl_record_member *member; |
| 941 |
SV *self; |
| 942 |
char *ptr1; |
| 943 |
int64_t *ptr2; |
| 944 |
|
| 945 |
dVAR; dXSARGS; |
| 946 |
|
| 947 |
if(items == 0) |
| 948 |
croak("This is a method, you must provide at least the object"); |
| 949 |
|
| 950 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 951 |
|
| 952 |
self = ST(0); |
| 953 |
if(SvROK(self)) |
| 954 |
self = SvRV(self); |
| 955 |
|
| 956 |
if(!SvOK(self)) |
| 957 |
croak("Null record error"); |
| 958 |
|
| 959 |
ptr1 = (char*) SvPV_nolen(self); |
| 960 |
ptr2 = (int64_t*) &ptr1[member->offset]; |
| 961 |
|
| 962 |
if(items > 1) |
| 963 |
{ |
| 964 |
if(SvREADONLY(self)) |
| 965 |
{ |
| 966 |
croak("record is read-only"); |
| 967 |
} |
| 968 |
else |
| 969 |
{ |
| 970 |
*ptr2 = (int64_t) SvIV(ST(1)); |
| 971 |
} |
| 972 |
} |
| 973 |
|
| 974 |
if(GIMME_V == G_VOID) |
| 975 |
XSRETURN_EMPTY; |
| 976 |
|
| 977 |
XSRETURN_IV(*ptr2); |
| 978 |
} |
| 979 |
|
| 980 |
XS(ffi_pl_record_accessor_sint64_array) |
| 981 |
{ |
| 982 |
ffi_pl_record_member *member; |
| 983 |
SV *self; |
| 984 |
SV *arg; |
| 985 |
SV **item; |
| 986 |
AV *av; |
| 987 |
char *ptr1; |
| 988 |
int i; |
| 989 |
int64_t *ptr2; |
| 990 |
|
| 991 |
dVAR; dXSARGS; |
| 992 |
|
| 993 |
if(items == 0) |
| 994 |
croak("This is a method, you must provide at least the object"); |
| 995 |
|
| 996 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 997 |
|
| 998 |
self = ST(0); |
| 999 |
if(SvROK(self)) |
| 1000 |
self = SvRV(self); |
| 1001 |
|
| 1002 |
ptr1 = (char*) SvPV_nolen(self); |
| 1003 |
ptr2 = (int64_t*) &ptr1[member->offset]; |
| 1004 |
|
| 1005 |
if(items > 1 && SvREADONLY(self)) |
| 1006 |
{ |
| 1007 |
croak("record is read-only"); |
| 1008 |
} |
| 1009 |
|
| 1010 |
if(items > 2) |
| 1011 |
{ |
| 1012 |
i = SvIV(ST(1)); |
| 1013 |
if(i >= 0 && i < member->count) |
| 1014 |
{ |
| 1015 |
arg = ST(2); |
| 1016 |
ptr2[i] = SvIV(arg); |
| 1017 |
} |
| 1018 |
else |
| 1019 |
{ |
| 1020 |
warn("illegal index %d", i); |
| 1021 |
} |
| 1022 |
} |
| 1023 |
else if(items > 1) |
| 1024 |
{ |
| 1025 |
arg = ST(1); |
| 1026 |
if(SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVAV) |
| 1027 |
{ |
| 1028 |
av = (AV*) SvRV(arg); |
| 1029 |
for(i=0; i < member->count; i++) |
| 1030 |
{ |
| 1031 |
item = av_fetch(av, i, 0); |
| 1032 |
if(item != NULL && SvOK(*item)) |
| 1033 |
{ |
| 1034 |
ptr2[i] = SvIV(*item); |
| 1035 |
} |
| 1036 |
else |
| 1037 |
{ |
| 1038 |
ptr2[i] = 0; |
| 1039 |
} |
| 1040 |
} |
| 1041 |
} |
| 1042 |
else |
| 1043 |
{ |
| 1044 |
i = SvIV(ST(1)); |
| 1045 |
if(i >= 0 && i < member->count) |
| 1046 |
{ |
| 1047 |
XSRETURN_IV(ptr2[i]); |
| 1048 |
} |
| 1049 |
else |
| 1050 |
{ |
| 1051 |
warn("illegal index %d", i); |
| 1052 |
XSRETURN_EMPTY; |
| 1053 |
} |
| 1054 |
} |
| 1055 |
} |
| 1056 |
|
| 1057 |
if(GIMME_V == G_VOID) |
| 1058 |
XSRETURN_EMPTY; |
| 1059 |
|
| 1060 |
av = newAV(); |
| 1061 |
av_fill(av, member->count-1); |
| 1062 |
for(i=0; i < member->count; i++) |
| 1063 |
{ |
| 1064 |
sv_setiv(*av_fetch(av, i, 1), ptr2[i]); |
| 1065 |
} |
| 1066 |
ST(0) = newRV_inc((SV*)av); |
| 1067 |
XSRETURN(1); |
| 1068 |
} |
| 1069 |
|
| 1070 |
XS(ffi_pl_record_accessor_float) |
| 1071 |
{ |
| 1072 |
ffi_pl_record_member *member; |
| 1073 |
SV *self; |
| 1074 |
char *ptr1; |
| 1075 |
float *ptr2; |
| 1076 |
|
| 1077 |
dVAR; dXSARGS; |
| 1078 |
|
| 1079 |
if(items == 0) |
| 1080 |
croak("This is a method, you must provide at least the object"); |
| 1081 |
|
| 1082 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 1083 |
|
| 1084 |
self = ST(0); |
| 1085 |
if(SvROK(self)) |
| 1086 |
self = SvRV(self); |
| 1087 |
|
| 1088 |
if(!SvOK(self)) |
| 1089 |
croak("Null record error"); |
| 1090 |
|
| 1091 |
ptr1 = (char*) SvPV_nolen(self); |
| 1092 |
ptr2 = (float*) &ptr1[member->offset]; |
| 1093 |
|
| 1094 |
if(items > 1) |
| 1095 |
{ |
| 1096 |
if(SvREADONLY(self)) |
| 1097 |
{ |
| 1098 |
croak("record is read-only"); |
| 1099 |
} |
| 1100 |
else |
| 1101 |
{ |
| 1102 |
*ptr2 = (float) SvNV(ST(1)); |
| 1103 |
} |
| 1104 |
} |
| 1105 |
|
| 1106 |
if(GIMME_V == G_VOID) |
| 1107 |
XSRETURN_EMPTY; |
| 1108 |
|
| 1109 |
XSRETURN_NV(*ptr2); |
| 1110 |
} |
| 1111 |
|
| 1112 |
XS(ffi_pl_record_accessor_float_array) |
| 1113 |
{ |
| 1114 |
ffi_pl_record_member *member; |
| 1115 |
SV *self; |
| 1116 |
SV *arg; |
| 1117 |
SV **item; |
| 1118 |
AV *av; |
| 1119 |
char *ptr1; |
| 1120 |
int i; |
| 1121 |
float *ptr2; |
| 1122 |
|
| 1123 |
dVAR; dXSARGS; |
| 1124 |
|
| 1125 |
if(items == 0) |
| 1126 |
croak("This is a method, you must provide at least the object"); |
| 1127 |
|
| 1128 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 1129 |
|
| 1130 |
self = ST(0); |
| 1131 |
if(SvROK(self)) |
| 1132 |
self = SvRV(self); |
| 1133 |
|
| 1134 |
ptr1 = (char*) SvPV_nolen(self); |
| 1135 |
ptr2 = (float*) &ptr1[member->offset]; |
| 1136 |
|
| 1137 |
if(items > 1 && SvREADONLY(self)) |
| 1138 |
{ |
| 1139 |
croak("record is read-only"); |
| 1140 |
} |
| 1141 |
|
| 1142 |
if(items > 2) |
| 1143 |
{ |
| 1144 |
i = SvIV(ST(1)); |
| 1145 |
if(i >= 0 && i < member->count) |
| 1146 |
{ |
| 1147 |
arg = ST(2); |
| 1148 |
ptr2[i] = SvNV(arg); |
| 1149 |
} |
| 1150 |
else |
| 1151 |
{ |
| 1152 |
warn("illegal index %d", i); |
| 1153 |
} |
| 1154 |
} |
| 1155 |
else if(items > 1) |
| 1156 |
{ |
| 1157 |
arg = ST(1); |
| 1158 |
if(SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVAV) |
| 1159 |
{ |
| 1160 |
av = (AV*) SvRV(arg); |
| 1161 |
for(i=0; i < member->count; i++) |
| 1162 |
{ |
| 1163 |
item = av_fetch(av, i, 0); |
| 1164 |
if(item != NULL && SvOK(*item)) |
| 1165 |
{ |
| 1166 |
ptr2[i] = SvNV(*item); |
| 1167 |
} |
| 1168 |
else |
| 1169 |
{ |
| 1170 |
ptr2[i] = 0.0; |
| 1171 |
} |
| 1172 |
} |
| 1173 |
} |
| 1174 |
else |
| 1175 |
{ |
| 1176 |
i = SvIV(ST(1)); |
| 1177 |
if(i >= 0 && i < member->count) |
| 1178 |
{ |
| 1179 |
XSRETURN_NV(ptr2[i]); |
| 1180 |
} |
| 1181 |
else |
| 1182 |
{ |
| 1183 |
warn("illegal index %d", i); |
| 1184 |
XSRETURN_EMPTY; |
| 1185 |
} |
| 1186 |
} |
| 1187 |
} |
| 1188 |
|
| 1189 |
if(GIMME_V == G_VOID) |
| 1190 |
XSRETURN_EMPTY; |
| 1191 |
|
| 1192 |
av = newAV(); |
| 1193 |
av_fill(av, member->count-1); |
| 1194 |
for(i=0; i < member->count; i++) |
| 1195 |
{ |
| 1196 |
sv_setnv(*av_fetch(av, i, 1), ptr2[i]); |
| 1197 |
} |
| 1198 |
ST(0) = newRV_inc((SV*)av); |
| 1199 |
XSRETURN(1); |
| 1200 |
} |
| 1201 |
|
| 1202 |
XS(ffi_pl_record_accessor_double) |
| 1203 |
{ |
| 1204 |
ffi_pl_record_member *member; |
| 1205 |
SV *self; |
| 1206 |
char *ptr1; |
| 1207 |
double *ptr2; |
| 1208 |
|
| 1209 |
dVAR; dXSARGS; |
| 1210 |
|
| 1211 |
if(items == 0) |
| 1212 |
croak("This is a method, you must provide at least the object"); |
| 1213 |
|
| 1214 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 1215 |
|
| 1216 |
self = ST(0); |
| 1217 |
if(SvROK(self)) |
| 1218 |
self = SvRV(self); |
| 1219 |
|
| 1220 |
if(!SvOK(self)) |
| 1221 |
croak("Null record error"); |
| 1222 |
|
| 1223 |
ptr1 = (char*) SvPV_nolen(self); |
| 1224 |
ptr2 = (double*) &ptr1[member->offset]; |
| 1225 |
|
| 1226 |
if(items > 1) |
| 1227 |
{ |
| 1228 |
if(SvREADONLY(self)) |
| 1229 |
{ |
| 1230 |
croak("record is read-only"); |
| 1231 |
} |
| 1232 |
else |
| 1233 |
{ |
| 1234 |
*ptr2 = (double) SvNV(ST(1)); |
| 1235 |
} |
| 1236 |
} |
| 1237 |
|
| 1238 |
if(GIMME_V == G_VOID) |
| 1239 |
XSRETURN_EMPTY; |
| 1240 |
|
| 1241 |
XSRETURN_NV(*ptr2); |
| 1242 |
} |
| 1243 |
|
| 1244 |
XS(ffi_pl_record_accessor_double_array) |
| 1245 |
{ |
| 1246 |
ffi_pl_record_member *member; |
| 1247 |
SV *self; |
| 1248 |
SV *arg; |
| 1249 |
SV **item; |
| 1250 |
AV *av; |
| 1251 |
char *ptr1; |
| 1252 |
int i; |
| 1253 |
double *ptr2; |
| 1254 |
|
| 1255 |
dVAR; dXSARGS; |
| 1256 |
|
| 1257 |
if(items == 0) |
| 1258 |
croak("This is a method, you must provide at least the object"); |
| 1259 |
|
| 1260 |
member = (ffi_pl_record_member*) CvXSUBANY(cv).any_ptr; |
| 1261 |
|
| 1262 |
self = ST(0); |
| 1263 |
if(SvROK(self)) |
| 1264 |
self = SvRV(self); |
| 1265 |
|
| 1266 |
ptr1 = (char*) SvPV_nolen(self); |
| 1267 |
ptr2 = (double*) &ptr1[member->offset]; |
| 1268 |
|
| 1269 |
if(items > 1 && SvREADONLY(self)) |
| 1270 |
{ |
| 1271 |
croak("record is read-only"); |
| 1272 |
} |
| 1273 |
|
| 1274 |
if(items > 2) |
| 1275 |
{ |
| 1276 |
i = SvIV(ST(1)); |
| 1277 |
if(i >= 0 && i < member->count) |
| 1278 |
{ |
| 1279 |
arg = ST(2); |
| 1280 |
ptr2[i] = SvNV(arg); |
| 1281 |
} |
| 1282 |
else |
| 1283 |
{ |
| 1284 |
warn("illegal index %d", i); |
| 1285 |
} |
| 1286 |
} |
| 1287 |
else if(items > 1) |
| 1288 |
{ |
| 1289 |
arg = ST(1); |
| 1290 |
if(SvROK(arg) && SvTYPE(SvRV(arg)) == SVt_PVAV) |
| 1291 |
{ |
| 1292 |
av = (AV*) SvRV(arg); |
| 1293 |
for(i=0; i < member->count; i++) |
| 1294 |
{ |
| 1295 |
item = av_fetch(av, i, 0); |
| 1296 |
if(item != NULL && SvOK(*item)) |
| 1297 |
{ |
| 1298 |
ptr2[i] = SvNV(*item); |
| 1299 |
} |
| 1300 |
else |
| 1301 |
{ |
| 1302 |
ptr2[i] = 0.0; |
| 1303 |
} |
| 1304 |
} |
| 1305 |
} |
| 1306 |
else |
| 1307 |
{ |
| 1308 |
i = SvIV(ST(1)); |
| 1309 |
if(i >= 0 && i < member->count) |
| 1310 |
{ |
| 1311 |
XSRETURN_NV(ptr2[i]); |
| 1312 |
} |
| 1313 |
else |
| 1314 |
{ |
| 1315 |
warn("illegal index %d", i); |
| 1316 |
XSRETURN_EMPTY; |
| 1317 |
} |
| 1318 |
} |
| 1319 |
} |
| 1320 |
|
| 1321 |
if(GIMME_V == G_VOID) |
| 1322 |
XSRETURN_EMPTY; |
| 1323 |
|
| 1324 |
av = newAV(); |
| 1325 |
av_fill(av, member->count-1); |
| 1326 |
for(i=0; i < member->count; i++) |
| 1327 |
{ |
| 1328 |
sv_setnv(*av_fetch(av, i, 1), ptr2[i]); |
| 1329 |
} |
| 1330 |
ST(0) = newRV_inc((SV*)av); |
| 1331 |
XSRETURN(1); |
| 1332 |
} |
| 1333 |
|