| \n | //gravity_value_r\t\t\tinames;\t\t\t // ivar names | \n
and I see this function to set values, but the key argument doesn't appear to be used for anything.
\n[Edit] this function is for expanding the ivar array and getting back it's count.
\n
\n gravity/src/shared/gravity_value.c\n
\n\n Line 211\n in\n f9e95a4\n
\n| \n | int16_t gravity_class_add_ivar (gravity_class_t *c, const char *identifier) { | \n
Hello @STREGAsGate, can you please describe me what are you trying to do?
","upvoteCount":1,"url":"https://github.com/marcobambini/gravity/discussions/398#discussioncomment-4440513"}}}-
|
Hey, I'm writing a Swift package for Gravity and I'm having trouble figuring out how to get ivar values by key from an Instance. I see this commented out [Edit] this was for a debug feature, the ivar names are stored in htable. gravity/src/shared/gravity_value.h Line 382 in a135732 and I see this function to set values, but the key argument doesn't appear to be used for anything. gravity/src/shared/gravity_value.c Line 211 in f9e95a4 Is it possible to retrieve an ivar value by it's key, or only by index? |
Beta Was this translation helpful? Give feedback.
-
|
To get an existing instance value:
[Edit] the closure is for getter and setters which will need to be handled separately in addition to the stored retrieval above. |
Beta Was this translation helpful? Give feedback.
-
|
This seems to be the basic approach to assign a new stored ivar to a class. let index = gravity_class_add_ivar(gravityClass, name)
let function = gravity_function_new_special(gravity.vm, nil, UInt16(index), nil, nil)
let closure = gravity_closure_new(gravity.vm, function)
gravity_class_bind(gravityClass, name, gravity_value_from_object(closure))I'm still having an issue where the closure.f pointer gets corrupted or nulled at some point though. |
Beta Was this translation helpful? Give feedback.
-
|
Hello @STREGAsGate, can you please describe me what are you trying to do? |
Beta Was this translation helpful? Give feedback.
-
|
Hello @STREGAsGate, good to know that you fixed the issue. Please take a look at the Gravity <-> ObjC bridge, I think it contains a lot of valuable code to you: |
Beta Was this translation helpful? Give feedback.
Hello @STREGAsGate, can you please describe me what are you trying to do?