I'm writing a library for the MDM Inferno app so that it can use Neko
apps as functionality in AIR applications. I've already done quite a bit
of it, but I would like to be able to convert a Neko object to an MDM
Inferno object and to do that requires knowing the objects field names.
Lee
Justin Collins wrote:
I knew it was too easy. I'm still not clear on what you want, though.
Are modifying the VM, or writing a C library?
-Justin
Lee McColl Sylvester wrote:
Hey Justin,
That's awesome and I thank you for your quick reply. However, what I
need is to be able to get the field names within the C binary, not
the neko code. Do you know how I might do that? What I was hoping for
was an undocumented method called something like "value*
val_object_fields( obj )" or somesuch (which I know doesn't exist
because I've trawled the C sources many times, but I live in hope).
Please don't think I'm ungrateful, though :-) I am, really.
Best,
Lee
Justin Collins wrote:
Lee McColl Sylvester wrote:
Hey list,
I need to perform a conversion from a Neko object to a different vm
object instance, but to do so requires knowing what fields an
object contains. Is it possible to retrieve an array of field names
that I can iterate over to perform the conversion?
Thanks,
Lee
If the hashed names are alright, you can use $objfields().
Otherwise, it just happens that I have such code sitting right here
to return an array of strings:
get_field_names = function(object) {
//$objfields returns an array of integers, which are the hashed
names of the fields
var field_list = $objfields(object)
//Number of fields in the array
var num_fields = $asize(field_list)
//Empty array to populate with field names
var field_names = $amake(num_fields)
//Index variable
var i = 0
//Loop over the fields
while(i < num_fields) {
//Convert integer field to string and store in array
field_names[i] = $field(field_list[i])
i = i + 1
}
return field_names
}
-Justin
--
Neko : One VM to run them all
(http://nekovm.org)