Changeset b2aa08 in git for Singular/pyobject.cc
- Timestamp:
- Aug 1, 2012, 11:07:23 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ad2543eab51733612ba7d118afc77edca719600e')
- Children:
- 1161a6145a6ca3b9034865b05528815c65f55cfb
- Parents:
- 632c3a619d605d6b049c3f7f82a323ea8113e34b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/pyobject.cc
r632c3a rb2aa08 16 16 #include <kernel/mod2.h> 17 17 #include <misc/auxiliary.h> 18 #include "newstruct.h" 18 19 19 20 #include <omalloc/omalloc.h> … … 107 108 typedef PyObject* ptr_type; 108 109 struct sequence_tag{}; 110 struct null_tag {}; 109 111 110 112 PythonObject(): m_ptr(Py_None) { } 113 PythonObject(null_tag): m_ptr(NULL) { } 111 114 PythonObject(ptr_type ptr): m_ptr(ptr) {if (!ptr) handle_exception();} 112 115 … … 128 131 return *this; 129 132 130 Werror("unary operation '%s` not implemented for 'pyobject`", iiTwoOps(op)); 131 return self(); 133 return self(null_tag()); 132 134 } 133 135 … … 148 150 case '.': case COLONCOLON: case ATTRIB_CMD: return attr(arg); 149 151 } 150 Werror("binary operation '%d` not implemented for 'pyobject`", iiTwoOps(op)); 151 152 return self(); 152 return self(null_tag()); 153 153 } 154 154 … … 160 160 case ATTRIB_CMD: PyObject_SetAttr(*this, arg1, arg2); return self(); 161 161 } 162 163 162 Werror("ternary operation %s not implemented for 'pyobject`", iiTwoOps(op)); 164 return self( );163 return self(null_tag()); 165 164 } 166 165 … … 185 184 BOOLEAN assign_to(leftv result) 186 185 { 187 return (m_ptr == Py_None? none_to(result): python_to(result));186 return (m_ptr? (m_ptr == Py_None? none_to(result): python_to(result)): TRUE); 188 187 } 189 188 … … 515 514 res->rtyp = STRING_CMD; 516 515 return FALSE; 517 518 case LIST_CMD: 516 } 517 518 if (!PythonCastStatic<>(head)(op).assign_to(res)) 519 519 return FALSE; 520 520 521 } 522 523 if (op > MAX_TOK) // custom types 524 { 525 BOOLEAN newstruct_Op1(int, leftv, leftv); 526 if (! newstruct_Op1(op, res, head) ) return FALSE; 527 } 528 529 return PythonCastStatic<>(head)(op).assign_to(res); 521 BOOLEAN newstruct_Op1(int, leftv, leftv); // forward declaration 522 return newstruct_Op1(op, res, head); 530 523 } 531 524 … … 547 540 return lhs.attr(get_attrib_name(arg2)).assign_to(res); 548 541 } 542 549 543 PythonCastDynamic rhs(arg2); 550 return lhs(op, rhs).assign_to(res); 544 if (!lhs(op, rhs).assign_to(res)) 545 return FALSE; 546 547 BOOLEAN newstruct_Op2(int, leftv, leftv, leftv); // forward declaration 548 return newstruct_Op2(op, res, arg1, arg2); 549 551 550 } 552 551 … … 579 578 580 579 typedef PythonCastStatic<PythonObject::sequence_tag> seq_type; 581 return PythonCastStatic<>(args)(op, seq_type(args->next)).assign_to(res); 580 if (! PythonCastStatic<>(args)(op, seq_type(args->next)).assign_to(res)) 581 return FALSE; 582 583 BOOLEAN newstruct_OpM(int, leftv, leftv); // forward declaration 584 return newstruct_OpM(op, res, args); 582 585 } 583 586 … … 652 655 b->blackbox_Op3 = pyobject_Op3; 653 656 b->blackbox_OpM = pyobject_OpM; 657 b->data = omAlloc0(newstruct_desc_size()); 654 658 655 659 PythonInterpreter::init(setBlackboxStuff(b,"pyobject"));
Note: See TracChangeset
for help on using the changeset viewer.