blackbox support - n-ary operations
| 600 | |
| 601 | /// blackbox support - n-ary operations |
| 602 | BOOLEAN pyobject_OpM(int op, leftv res, leftv args) |
| 603 | { |
| 604 | switch(op) // built-in return types first |
| 605 | { |
| 606 | case STRING_CMD: |
| 607 | { |
| 608 | blackbox* a = getBlackboxStuff(args->Typ()); |
| 609 | res->data = (void *)a->blackbox_String(a, args->Data()); |
| 610 | res->rtyp = STRING_CMD; |
| 611 | return FALSE; |
| 612 | } |
| 613 | |
| 614 | case INTVEC_CMD: |
| 615 | PythonObject obj = PythonCastStatic<>(args->Data()); |
| 616 | unsigned long len = obj.size(); |
| 617 | |
| 618 | intvec* vec = new intvec(len); |
| 619 | for(unsigned long idx = 0; idx != len; ++idx) |
| 620 | { |
| 621 | long value = PyInt_AsLong(obj[idx]); |
| 622 | (*vec)[idx] = static_cast<int>(value); |
| 623 | |
| 624 | if ((value == -1) && PyErr_Occurred()) |
| 625 | { |
| 626 | value = 0; |
| 627 | PyErr_Clear(); |
| 628 | } |
| 629 | if (value != long((*vec)[idx])) |
| 630 | { |
| 631 | delete vec; |
| 632 | WerrorS("'pyobject` cannot be converted to intvec"); |
| 633 | return TRUE; |
| 634 | } |
| 635 | } |
| 636 | res->data = (void *)vec; |
| 637 | res->rtyp = op; |
| 638 | return FALSE; |
| 639 | } |
| 640 | typedef PythonCastStatic<PythonObject::sequence_tag> seq_type; |
| 641 | if (! PythonCastStatic<>(args)(op, seq_type(args->next)).assign_to(res)) |
| 642 | return FALSE; |
| 643 | |
| 644 | BOOLEAN newstruct_OpM(int, leftv, leftv); // forward declaration |
| 645 | return newstruct_OpM(op, res, args); |
| 646 | } |
| 647 | |
| 648 | /// blackbox support - destruction |
| 649 | void pyobject_destroy(blackbox *, void* ptr) |
nothing calls this directly
no test coverage detected