| 5553 | |
| 5554 | const char *getName() HXCPP_OVERRIDE { return "ArrayAccessI"; } |
| 5555 | CppiaExpr *link(CppiaModule &inModule) HXCPP_OVERRIDE |
| 5556 | { |
| 5557 | if (object) |
| 5558 | object = object->link(inModule); |
| 5559 | |
| 5560 | |
| 5561 | index = index->link(inModule); |
| 5562 | |
| 5563 | TypeData *type = inModule.types[classId]; |
| 5564 | // TODO - not always cppiaClass |
| 5565 | if (type->cppiaClass) |
| 5566 | throw "ArrayAccess interface can't be implemented in cppia"; |
| 5567 | |
| 5568 | __get = type->haxeBase->findFunction("__get"); |
| 5569 | if (!__get.execute) |
| 5570 | { |
| 5571 | CPPIALOG("Class %s missing __get\n", type->name.out_str()); |
| 5572 | throw "Bad array access - __get"; |
| 5573 | } |
| 5574 | __set = type->haxeBase->findFunction("__set"); |
| 5575 | if (!__set.execute) |
| 5576 | { |
| 5577 | CPPIALOG("Class %s missing __set\n", type->name.out_str()); |
| 5578 | throw "Bad array access - __set"; |
| 5579 | } |
| 5580 | |
| 5581 | if (__get.signature[1]!='i' || __set.signature[1]!='i') |
| 5582 | throw "__get/__set should take an int"; |
| 5583 | |
| 5584 | if (__get.signature[0]!=__set.signature[2]) |
| 5585 | throw "Mismatch __get/__set array access"; |
| 5586 | |
| 5587 | switch(__get.signature[0]) |
| 5588 | { |
| 5589 | case sigBool: |
| 5590 | case sigInt: |
| 5591 | accessType = etInt; break; |
| 5592 | case sigFloat: accessType = etFloat; break; |
| 5593 | case sigString: accessType = etString; break; |
| 5594 | case sigObject: accessType = etObject; break; |
| 5595 | default: throw "Bad signature on __get"; |
| 5596 | } |
| 5597 | |
| 5598 | if (value) |
| 5599 | value = value->link(inModule); |
| 5600 | |
| 5601 | DBGLOG("Created ARRAYI wrapper %s %d %s / %s\n", type->name.out_str(), accessType, __get.signature, __set.signature); |
| 5602 | |
| 5603 | return this; |
| 5604 | } |
| 5605 | |
| 5606 | template<typename T> |
| 5607 | void setResult(CppiaCtx *ctx,T &outValue) |
nothing calls this directly
no test coverage detected