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

Function pyobject_Op1

Singular/dyn_modules/pyobject/pyobject.cc:530–558  ·  view source on GitHub ↗

blackbox support - unary operations

Source from the content-addressed store, hash-verified

528
529/// blackbox support - unary operations
530BOOLEAN pyobject_Op1(int op, leftv res, leftv head)
531{
532 switch(op)
533 {
534 case INT_CMD: // built-in return types first
535 {
536 long value = PyInt_AsLong(PythonCastStatic<>(head));
537 if( (value == -1) && PyErr_Occurred() )
538 {
539 WerrorS("'pyobject` cannot be converted to integer");
540 PyErr_Clear();
541 return TRUE;
542 }
543 res->data = (void*) value;
544 res->rtyp = INT_CMD;
545 return FALSE;
546 }
547 case TYPEOF_CMD:
548 res->data = (void*) omStrDup("pyobject");
549 res->rtyp = STRING_CMD;
550 return FALSE;
551 }
552
553 if (!PythonCastStatic<>(head)(op).assign_to(res))
554 return FALSE;
555
556 BOOLEAN newstruct_Op1(int, leftv, leftv); // forward declaration
557 return newstruct_Op1(op, res, head);
558}
559
560
561/// blackbox support - binary operations

Callers

nothing calls this directly

Calls 3

WerrorSFunction · 0.85
newstruct_Op1Function · 0.85
assign_toMethod · 0.80

Tested by

no test coverage detected