Ok people...I solved my first problem....

Handle<Value> Point_SetX(const Arguments& args)
{

        bool first = true;
        if(args.Length()==1){
                Local<Object> self = args.Holder();
                Local<External> external = Local<External>::Cast(self-
>GetInternalField(0));
                Point* p = static_cast<Point*>(external->Value());
                p->setX(args[0]->Int32Value());
        }
        return Undefined();
}

Well...there are open questions...is it possible to get documentation
about V8? and....Is it possible to separate the Point class and class
template into seperated files...Point.cpp and PointTemplaite.cpp ??

Cheers,
Miguel L.


On Oct 14, 8:39 am, alemao <[EMAIL PROTECTED]> wrote:
> Hi everybody,
>
> I reuse the Point-class example (which I downloaded from this user-
> group) and modified a little bit...I moved the public variable into
> private variables and created get-setter function, from which I can
> modified the X or Y value and can access afterwards to the correspond
> values.
> What I don't know is how to do that....
>
> I put you a peace of code here:
>
> class Point {
>         private:
>                 int x, y;
>         public:
>                 Point(int px = 0, int py = 0) : x(px), y(py) {}
>         int getX(){
>                 return x;
>         }
>         void setX(int valueX){
>                 x=valueX;
>         }};
>
> ...
> Handle<Value> Point_GetX(const Arguments& args);
> Handle<Value> Point_SetX(const Arguments& args);
> ...
> Handle<Value> Point_GetX(const Arguments& args)
> {
>         Local<Object> self = args.Holder();
>         Local<External> external = 
> Local<External>::Cast(self->GetInternalField(0));
>
>         Point* p = static_cast<Point*>(external->Value());
>         return Integer::New(p->getX());
>
> }
>
> Handle<Value> Point_SetX(const Arguments& args)
> {
>         Local<Object> self = args.Holder();
>         Local<External> external = 
> Local<External>::Cast(self->GetInternalField(0));
>
>         Point* p = static_cast<Point*>(external->Value());
>         Local<Value> param = args.Data();
>         p->setX(1);
>         return Integer::New(args.Length());
>
> }
>
> The GetX function works well, but the SetX function...I don't know how
> to get the value from the args variable...is this correct or
> completely wrong?
>
> Can somebody tell me where can I have an API or better documentation
> about V8...I already create with doxygen code docs...but the code is
> poorly documented :S
>
> And the last question...is it possible to have in one file the class
> definition of Point...like Point.cpp...and in another his correspond
> class template...like PointTemplait.cpp...
>
> Cheers,
> Miguel L.
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to