Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add ?is_vm/1 macro; add Object:copy_properties_to/2; add Array:unpush/1

  • Loading branch information...
commit 618e4d1527791f4fa756807a441f249c8c4578e4 1 parent daa0bec
Gleb Peregud gleber authored
1  include/erlv8.hrl
View
@@ -16,3 +16,4 @@
vm}). %% or proplist()
+-define(is_v8(X), (is_record(X, erlv8_object) orelse is_record(X, erlv8_fun) orelse is_record(X, erlv8_array))).
6 src/erlv8_array.erl
View
@@ -6,7 +6,7 @@
-compile({no_auto_import,[length/1]}).
--export([list/1, object/1, length/1, push/2, unshift/2, delete/2,
+-export([list/1, object/1, length/1, push/2, unpush/1, unshift/2, delete/2,
new/1, new/2]).
@@ -29,6 +29,10 @@ push(Val, Self) ->
M = Self:object(),
M:set_value(length(Self),Val).
+unpush(Self) ->
+ M = Self:object(),
+ M:delete(M:length()-1).
+
unshift(Val, Self) ->
M = Self:object(),
L = length(Self),
7 src/erlv8_object.erl
View
@@ -7,11 +7,18 @@
set_prototype/2, get_prototype/1, delete/2, set_accessor/3, set_accessor/4, set_accessor/5, set_accessor/6,
equals/2, strict_equals/2, call/2, call/3,
+ copy_properties_to/2,
+
new/1, new/2]).
proplist({_Erlv8Obj, Resource, VM}) ->
erlv8_vm:enqueue_tick(VM,{proplist, Resource}).
+copy_properties_to(Other, Self) ->
+ lists:foreach(fun({K, V}) ->
+ Other:set_value(K, V)
+ end, Self:proplist()).
+
set_value(Key, Value, {_Erlv8Obj, Resource, VM}) ->
erlv8_vm:enqueue_tick(VM, {set, Resource, Key, Value}).
4 src/erlv8_vm.erl
View
@@ -110,9 +110,7 @@ next_tick(Server, Tick, Timeout) ->
next_tick(Server, Tick, Timeout, Ref) when is_reference(Ref) ->
gen_server2:call(Server,{next_tick, Tick, Ref}, Timeout).
-taint(Server, {Tag, _R, _Vm} = Value) when Tag == erlv8_object;
- Tag == erlv8_fun;
- Tag == erlv8_array ->
+taint(Server, Value) when ?is_v8(Value) ->
enqueue_tick(Server, {taint, Value});
taint(Server, {Error, _} = Value) when Error == error;
Please sign in to comment.
Something went wrong with that request. Please try again.