You're welcome. On Fri, Mar 12, 2010 at 1:24 PM, Seiji Sam Lee <[email protected]>wrote:
> Yes, it works!!!! > > > > *De:* [email protected] [mailto:[email protected]] *En > nombre de *Matthias Ernst > *Enviado el:* jueves, 11 de marzo de 2010 21:24 > > *Para:* [email protected] > *Asunto:* Re: [v8-users] How to clone a Value > > > > On Thu, Mar 11, 2010 at 7:47 PM, Seiji Sam Lee <[email protected]> > wrote: > > I really want to store 'Value's in a hash table, to conserve this > objects > > among context execution, this is my INTERCEPTORS code: > > > > Follow setter, getter and deleter ... they hang the program :-( > > > > (NOTES: arguments: 'prop' is the name of the property, 'value' is > obviously > > its value; apr_hash_* work fine!!) > > > > Summing Up: I store (1) a pointer to a Persistent<Value>, retrieve this > > pointer casting as Persistent<Value> > > This is along what I would try: > > > > > > > JSETTER(_session_data) > > { > > HSCOPE; > > DEFINE_PC(info); > > String::Utf8Value _key(prop); > > char*key=apr_pstrdup(pc->ppool,*_key); > > Persistent<Value> v(*value); > > > Persistent<Value> v = Persistent::New(value); > > apr_hash_set(pc->_objs,key,strlen(key)+1,&*v); (1) > > return HSCLOSE(v); > > } > > > > JGETTER(_session_data) > > { > > HSCOPE; > > DEFINE_PC(info); > > String::Utf8Value key(prop); > > > Persistent<Value> > > v(*(Persistent<Value>*)apr_hash_get(pc->_objs,*key,strlen(*key)+1)); (2) > > return HSCLOSE(v); > > > Value* v = (Value*)apr_hash_get(pc->_objs,*key,strlen(*key)+1); > > > return Persistent<Value>(v); > > } > > > > JDELETER(_session_data) > > { > > HSCOPE; > > DEFINE_PC(info); > > String::Utf8Value key(prop); > > Persistent<Value> > > v(*(Persistent<Value>*)apr_hash_get(pc->_objs,*key,strlen(*key)+1)); > > v.Dispose(); > > v.Clear(); > > return HSCLOSE(Boolean::New(true)); > > } > > > > Any idea? > > > > -----Mensaje original----- > > De: [email protected] [mailto:[email protected]] En > nombre > > de Matthias Ernst > > Enviado el: jueves, 11 de marzo de 2010 19:15 > > Para: [email protected] > > Asunto: Re: [v8-users] How to clone a Value > > > > On Thu, Mar 11, 2010 at 4:46 PM, Seiji Sam Lee <[email protected]> > > wrote: > >> Well, it must be simple: > >> > >> > >> > >> I need to clone a Value (Handle<Value> value, for example) I need a copy > > of > >> 'value' which I can store in a table hash and use latter, and ok dispose > > it. > >> > >> > >> > >> I was looking for a Clone method, but only Object objects have it. Any > > idea? > >> > > > > Are you sure you want a clone of the value? Or do you just want a copy > > of the reference that survives the local scope? > > Persistent<Value>::New(handle_of_value) would give you that. > > > > If you actually want to clone the value, that only makes sense on > > Object. So you need to do something like this: > > Handle<Value> clone = Persistent<Value>::New(value->IsObject() ? > > Handle<Object>::Cast(value)->Clone() : value); > > > > Don't forget to Clear() and Dispose() the persistent handles. > > > >> > >> > >> -- > >> v8-users mailing list > >> [email protected] > >> http://groups.google.com/group/v8-users > > > > -- > > v8-users mailing list > > [email protected] > > http://groups.google.com/group/v8-users > > > > -- > > v8-users mailing list > > [email protected] > > http://groups.google.com/group/v8-users > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
