[prev in list] [next in list] [prev in thread] [next in thread] 

List:       webkit-dev
Subject:    [webkit-dev] javascriptcore: explicitly call default getProperties
From:       michael () powerset ! com (Michael Bieniosek)
Date:       2008-02-26 0:31:53
Message-ID: C3E89DF9.28FA7%michael () powerset ! com
[Download RAW message or body]

Hi,

I have a situation where I want to do lazy-loading of a javascript object's
properties.  I'm using the C API, in particular the getProperty callback.

I want to write code that looks like:

JSValueRef GetProperty(JSContextRef ctx, JSObjectRef obj, JSStringRef prop,
JSValueRef* exception)
{
  if (!JSValueHasProperty(ctx, obj, prop)) {
    JSValueRef lazy_loaded = lazy_load(...);
    JSObjectSetProperty(ctx, obj, prop, lazy_loaded, ...)
    return lazy_loaded;
  } else {
    return JSObjectGetProperty(ctx, obj, prop, exception);
  }
}

That is, I want use obj as a cache for my lazy_load function.  This code
doesn't work though, because the calls to JSObjectHasProperty and
JSObjectGetProperty recursively call GetProperty.

Is there a way to make this work?

Thanks,
Michael


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic