code-dot-org/code-dot-org — pull request #386 by cpirich (2014-11-11 00:07:12+00:00)
Title: Interpreter marshaling

We now pass event parameters properly marshaled from the native world (Event object) into the interpreter world. This allows the student to write code that responds to more specific events (e.g. "keyup", check e.keyCode).

Rather than continue to pile on some one-off marshaling code, I decided to implement a general purpose codegen.marshalNativeToInterpreter() function. It is used for return values when calling into native and within codegen.makeNativeMemberFunction(). It recurses when it encounters Arrays and Objects. You can pass it an optional maxDepth to limit the recursion, which currently defaults to 4 (sufficient for the event scenarios to date). The Event objects are incredibly deep. If we need to marshal extremely complex objects, it may require interpreter changes to allow JIT marshaling.