I have this code:

int main() {

    HandleScope handle_scope;

    Persistent<Context> context = Context::New();

    Context::Scope scope(context);

    Script::Compile(
        
String::New(chi::System::fileToString("../../../wb/content/script/v8/globals.js").c_str()),
        String::New("globals.js")
    )->Run();

    return 0;
}

And globals.js looks like this:

(function(){
  Object.defineProperty(Object.prototype, "extend", {
    enumerable: false,
    value: function(from) {
      var props = Object.getOwnPropertyNames(from);
      var dest = this;
      
      props.forEach(function(name) {
        if (name in dest) {
            var destination = Object.getOwnPropertyDescriptor(from, name);
            Object.defineProperty(dest, name, destination);
        }
      });
      return this;
    }
  });
})();

When I run it, I get:

globals.js:22: Uncaught TypeError: Object function Object() { [native code] 
} has no method 'defineProperty'

So, not only is the line number oss which really hurts, the more important 
problem is Object doesn't seem to be available. Am I missing something? Any 
help is much appreciated.

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to