This repository was archived by the owner on Dec 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,16 +25,16 @@ namespace rr {
2525
2626 VALUE Array::Length (VALUE self) {
2727 Array array (self);
28- Locker lock (array. getIsolate () );
28+ Locker lock (array);
2929
3030 return Uint32_t (array->Length ());
3131 }
3232
33- VALUE Array::CloneElementAt (VALUE self, VALUE index) {
33+ VALUE Array::CloneElementAt (VALUE self, VALUE context, VALUE index) {
3434 Array array (self);
35- Locker lock (array. getIsolate () );
35+ Locker lock (array);
3636
37- return Object (array.getIsolate (), array->CloneElementAt (Uint32_t (index)));
37+ return Object::Maybe (array.getIsolate (), array->CloneElementAt (Context (context), Uint32_t (index)));
3838 }
3939
4040}
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ namespace rr {
99
1010 static VALUE New (int argc, VALUE argv[], VALUE self);
1111 static VALUE Length (VALUE self);
12- static VALUE CloneElementAt (VALUE self, VALUE index);
12+ static VALUE CloneElementAt (VALUE self, VALUE context, VALUE index);
1313
1414 inline Array (v8::Isolate* isolate, v8::Handle<v8::Array> array) : Ref<v8::Array>(isolate, array) {}
1515 inline Array (VALUE value) : Ref<v8::Array>(value) {}
Original file line number Diff line number Diff line change 1717
1818 it 'can be initialized with a length' do
1919 a = V8 ::C ::Array ::New ( @isolate , 5 )
20-
2120 expect ( a . Length ) . to eq 5
2221 end
22+
23+ it 'can clone its elements' do
24+ o = V8 ::C ::Object ::New ( @isolate )
25+ key = V8 ::C ::String ::NewFromUtf8 ( @isolate , "key" )
26+ o . Set ( @ctx , key , key )
27+ a = V8 ::C ::Array ::New ( @isolate )
28+
29+ a . Set ( @ctx , 0 , o )
30+
31+ object = a . CloneElementAt ( @ctx , 0 )
32+ expect ( object ) . to be_successful
33+ expect ( object . FromJust ( ) . Get ( @ctx , key ) ) . to be_successful
34+ expect ( object . FromJust ( ) . Get ( @ctx , key ) . FromJust ( ) . Utf8Value ( ) ) . to eql "key"
35+ end
2336end
Original file line number Diff line number Diff line change 654654
655655# end
656656
657- describe "Calling JavaScript Code From Within Ruby" , :compat => '0.1.0' do
657+ describe "Calling JavaScript Code From Within Ruby" do
658658
659659 before ( :each ) do
660660 @cxt = V8 ::Context . new
You can’t perform that action at this time.
0 commit comments