103 configurable: true, enumerable: false, writable: true, |
103 configurable: true, enumerable: false, writable: true, |
104 value: function(func, syncobj) { |
104 value: function(func, syncobj) { |
105 if (arguments.length < 1 || arguments.length > 2 ) { |
105 if (arguments.length < 1 || arguments.length > 2 ) { |
106 throw "sync(function [,object]) parameter count mismatch"; |
106 throw "sync(function [,object]) parameter count mismatch"; |
107 } |
107 } |
108 return Packages.jdk.nashorn.api.scripting.ScriptUtils.makeSynchronizedFunction(func, syncobj); |
108 return Java.synchronized(func, syncobj); |
109 } |
109 } |
110 }); |
110 }); |
111 |
111 |
112 // Object.prototype.__defineGetter__ |
112 // Object.prototype.__defineGetter__ |
113 Object.defineProperty(Object.prototype, "__defineGetter__", { |
113 Object.defineProperty(Object.prototype, "__defineGetter__", { |
158 // Object.prototype.toSource |
158 // Object.prototype.toSource |
159 Object.defineProperty(Object.prototype, "toSource", { |
159 Object.defineProperty(Object.prototype, "toSource", { |
160 configurable: true, enumerable: false, writable: true, |
160 configurable: true, enumerable: false, writable: true, |
161 value: function(state) { |
161 value: function(state) { |
162 if (! state) { |
162 if (! state) { |
163 state = java.util.Collections.newSetFromMap(new java.util.IdentityHashMap()); |
163 state = java.util.Collections.newSetFromMap(new java.util.HashMap()); |
164 } |
164 } |
165 if (state.contains(this)) { |
165 if (state.contains(this)) { |
166 return "{}"; |
166 return "{}"; |
167 } |
167 } |
168 state.add(this); |
168 state.add(this); |