On Wed, Oct 1, 2008 at 6:35 AM, Marshall Greenblatt <[EMAIL PROTECTED]>wrote:
> Hi Mike, > > On Wed, Oct 1, 2008 at 4:02 AM, Mike Belshe <[EMAIL PROTECTED]> wrote: > >> You should be able to use v8::Array for this; (see v8.h). >> Create your array: >> >> v8::Local<v8::Array> array = v8::Array::New(); >> for (int index = 0; index < myStdStrings.length(); ++index) >> array->Set(v8::Integer::New(index), >> v8::String::New(myStdStrings[index])); >> >> Now, I think you can wrap it: >> >> NPObject* myObj = NPN_CreateScriptObject(0, array, domwindow); >> >> >> Or am I misunderstanding? >> >> Mike >> > > Thanks, that's exactly what I'm looking for :-) Now I just need to put it > somewhere appropriate for access from webkit/glue, which brings me back to > my CreateSimpleArrayObject() idea. > > It appears that the appropriate place to add the CreateSimpleArrayObject() > methods is in the JSBridge class in webkit/port/bridge. JSBridge is then > extended by V8Bridge and KJSBridge. Your above example provides the > implementation for V8Bridge. Do you know what the equivalent code for KJS > would look like? > Generally, I don't think you should touch the bridge (btw - the bridge is going away as we reconcile differences w/ webkit- it will be the scriptController, I believe). I don't have source in front of me; but there is a file like "np_v8_util" or np_v8_object" where there are some conversion utilities for converting v8 types to NPObjects. This routine (v8array to NPObject) probably belongs in there (for v8). I'm fairly clueless about the JSC code. (we used to refer to JavaScriptCore as KJS; but we now refer to it as JSC since that is the proper name) I'd assume that you'd create the NPObject direct from the CppBoundClass by calling this function. The last problem is making your newly created object reachable from your JS code; and for that, I think there is a BindToXXXX call (I believe it is on the bridge), which allows you to hang a custom property off the window object. While you described what you are trying to do (make arrays from C++ accessible to JS), I need more context to understand the best way to hook into the system. Are you augmenting an existing CppBoundObject? Or creating something new? Mike > > > Regards, > Marshall > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Chromium-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/chromium-dev?hl=en -~----------~----~----~----~------~----~------~--~---
