What is the best way to extract float variables from a Javascript
function call.
The javascript would look something like this:
=========
------------------
var point = new Point(2.5, 7.1, 4.8);
------------------
=========

The C++ currently look something like this:

=========
------------------
v8::Handle<v8::Value> jsi_Point_construct(const v8::Arguments& args)
{
        v8::HandleScope handleScope;

        if (!args.IsConstructCall()) {
                return v8::ThrowException(v8::String::New("Point: Cannot call
constructor as function."));
        }

        if (args.Length() != 3) {
                return v8::ThrowException(v8::String::New("Point: Constructor 
takes
3 arguments."));
        }


        float x = static_cast<float>(args[0]->Int32Value());
        float y = static_cast<float>(args[1]->Int32Value());
        float z = static_cast<float>(args[2]->Int32Value());

        Point3D* point = new Point3D(x, y, z);

        // make a persistant handle for the instance and
        // make it weak so we get a callback on destruction
        v8::Persistent<v8::Object> self = v8::Persistent<v8::Object>::New
(args.Holder());
        self.MakeWeak(point, jsi_Point_destruct);

        self->SetInternalField(0, v8::External::New(point));

        return self;
}
------------------
=========

Thanks for any help
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to