MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / ArrayAccessI

Class ArrayAccessI

src/hx/cppia/Cppia.cpp:5527–5764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5525
5526
5527struct ArrayAccessI : public CppiaDynamicExpr
5528{
5529 CppiaExpr *object;
5530 CppiaExpr *index;
5531 CppiaExpr *value;
5532
5533 int classId;
5534 ScriptFunction __get;
5535 ScriptFunction __set;
5536 ExprType accessType;
5537
5538 AssignOp assign;
5539 CrementOp crement;
5540
5541 ArrayAccessI(CppiaExpr *inSrc, int inClassId, CppiaExpr *inObj, CppiaExpr *inI)
5542 : CppiaDynamicExpr(inSrc)
5543 {
5544 object = inObj;
5545 index = inI;
5546 value = 0;
5547 assign = aoNone;
5548 crement = coNone;
5549 classId = inClassId;
5550 __get = 0;
5551 __set = 0;
5552 }
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])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected