Permalink
Browse files

move erlv8_object:copy_properties_to/2 to erlv8_utils:copy_properties/2;

add erlv8_utils:clone/1
  • Loading branch information...
1 parent c3fb137 commit 40ea9909dd2785c36658c01652fa00367bafb428 @gleber gleber committed Nov 20, 2012
Showing with 14 additions and 7 deletions.
  1. +0 −7 src/erlv8_object.erl
  2. +14 −0 src/erlv8_utils.erl
@@ -9,8 +9,6 @@
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]).
vm({Erlv8Obj, _Resource, VM}) when ?is_v8(Erlv8Obj) ->
@@ -19,11 +17,6 @@ vm({Erlv8Obj, _Resource, VM}) when ?is_v8(Erlv8Obj) ->
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}).
View
@@ -0,0 +1,14 @@
+-module(erlv8_utils).
+
+-export([clone/1,
+ copy_properties/2]).
+
+-include("erlv8.hrl").
+
+clone(Source) ->
+ erlv8_vm:taint(Source:vm(), ?V8Obj(Source:proplist())).
+
+copy_properties(Destination, Source) ->
+ lists:foreach(fun({K, V}) ->
+ Destination:set_value(K, V)
+ end, Source:proplist()).

0 comments on commit 40ea990

Please sign in to comment.