MCPcopy Create free account
hub / github.com/Singular/Singular / pyobject_OpM

Function pyobject_OpM

Singular/dyn_modules/pyobject/pyobject.cc:602–646  ·  view source on GitHub ↗

blackbox support - n-ary operations

Source from the content-addressed store, hash-verified

600
601/// blackbox support - n-ary operations
602BOOLEAN 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
649void pyobject_destroy(blackbox *, void* ptr)

Callers

nothing calls this directly

Calls 7

getBlackboxStuffFunction · 0.85
WerrorSFunction · 0.85
newstruct_OpMFunction · 0.85
assign_toMethod · 0.80
TypMethod · 0.45
DataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected