| 546 | } |
| 547 | |
| 548 | bool CppiaClassInfo::setField(hx::Object *inThis, String inName, Dynamic inValue, hx::PropertyAccess inCallProp, Dynamic &outValue) |
| 549 | { |
| 550 | if (inCallProp==paccDynamic) |
| 551 | inCallProp = isNativeProperty(inName) ? paccAlways : paccNever; |
| 552 | |
| 553 | if (inCallProp) |
| 554 | { |
| 555 | //printf("Set field %s %s = %s\n", inThis->toString().out_str(), inName.out_str(), inValue->toString().out_str()); |
| 556 | ScriptCallable *setter = findMemberSetter(inName); |
| 557 | if (setter) |
| 558 | { |
| 559 | Array<Dynamic> args = Array_obj<Dynamic>::__new(1,1); |
| 560 | args[0] = inValue; |
| 561 | outValue.mPtr = runFunExprDynamic(CppiaCtx::getCurrent(),setter,inThis, args); |
| 562 | return true; |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | |
| 567 | // Look for dynamic function (variable) |
| 568 | for(int i=0;i<dynamicFunctions.size();i++) |
| 569 | { |
| 570 | if (cppia.strings[ dynamicFunctions[i]->nameId ]==inName) |
| 571 | { |
| 572 | CppiaVar *d = dynamicFunctions[i]; |
| 573 | outValue = d->setValue(inThis,inValue); |
| 574 | return true; |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | for(int i=0;i<memberVars.size();i++) |
| 579 | { |
| 580 | CppiaVar &var = *memberVars[i]; |
| 581 | if (var.name==inName) |
| 582 | { |
| 583 | outValue = var.setValue(inThis, inValue); |
| 584 | return true; |
| 585 | } |
| 586 | } |
| 587 | |
| 588 | hx::FieldMap *map = dynamicMapOffset ? (hx::FieldMap *)( (char *)inThis + dynamicMapOffset ) : |
| 589 | inThis->__GetFieldMap(); |
| 590 | if (map) |
| 591 | { |
| 592 | #ifdef HXCPP_GC_GENERATIONAL |
| 593 | FieldMapSet(inThis,map, inName, inValue); |
| 594 | #else |
| 595 | FieldMapSet(map, inName, inValue); |
| 596 | #endif |
| 597 | outValue = inValue; |
| 598 | return true; |
| 599 | } |
| 600 | |
| 601 | // Fall though to haxe base |
| 602 | //printf("Set field not found (%s) %s map=%p o=%d\n", inThis->toString().out_str(),inName.out_str(), map, dynamicMapOffset); |
| 603 | |
| 604 | return false; |
| 605 | } |
no test coverage detected