I accidentally sent that before I was finished ... 6) JS functions called from C will be able to convert structs in the heap to objects and vice versa. It will not only be for debugging.
I've already got the code half written. I hope others will help add features. On Wed, Mar 5, 2014 at 9:42 AM, Mark Hahn <[email protected]> wrote: > > I'd try handwriting a function that takes in a pointer to a structure, > and prints its contents out to console. > > That is exactly what I started doing yesterday. Today I got a much better > idea. I'm going to make it a javascript function to convert between data > structs in the heap and javascript objects. Then you can have the > inspector show the structs as objects and get the best of all worlds. > > I'm going to make it an open source project on github ( > https://github.com/mark-hahn/emStructObj) so everyone can help. It > should be ready to look at in a few hours, For now it will just be docs > and some incomplete code. > > Some features ... > > 1) Create js objects with keys matching the struct member names. > > 2) Supports simple variables as well. > > 3) The definition will be in two parts. simple type defs and struct defs. > > > a) Simple defs: A hash with type names (short, long, LONG, color, etc) > as keys and a def spec as the value. The def will look like 'size, > display, array length'. > i) The size has to be one of: i8, i16, i32, i64, float, or double. > ii) Display can be hex, dec, str (ascii string), strw (16-bit > unicode str), or one of the struct names. If a struct name then it is a > pointer to that struct def and an object is nested in the object. > iii) The array length creates an array of these types assuming the > vars/structs are contiguous in memory. > > b) Struct defs look like they do in C/C++. It won't do a real parse, > it will just assume one line per member with type and name followed by > semicolon. Usually you will be able to copy a struct definition directly > from a c/c++ header. > > 4) All defs will be in a separate js file included before the emStructObj > code. > > 5) The emStructObj code will work in any js environment like node and the > browser. > > > > > > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
