@@ -17,34 +17,33 @@ using namespace v8;
17
17
18
18
*/
19
19
20
- Handle <Value> moveMouse ( const Arguments& args )
20
+ NAN_METHOD (moveMouse )
21
21
{
22
- HandleScope scope ;
22
+ NanScope () ;
23
23
if (args.Length () < 2 )
24
24
{
25
- ThrowException (Exception::TypeError (String::New (" Wrong number of arguments" )));
26
- return scope.Close (Undefined ());
25
+ return NanThrowError (" Invalid number of arguments" );
27
26
}
28
27
size_t x = args[0 ]->Int32Value ();
29
28
size_t y = args[1 ]->Int32Value ();
30
29
31
30
MMPoint point;
32
31
point = MMPointMake (x, y);
33
32
moveMouse (point);
34
- return scope. Close ( String::New (" 1" ));
33
+ NanReturnValue ( NanNew (" 1" ));
35
34
}
36
35
37
- Handle <Value> getMousePos ( const Arguments& args )
36
+ NAN_METHOD (getMousePos )
38
37
{
39
- HandleScope scope ;
38
+ NanScope () ;
40
39
41
40
MMPoint pos = getMousePos ();
42
41
43
42
// Return object with .x and .y.
44
- Local<Object> obj = Object::New ();
45
- obj->Set (String::NewSymbol (" x" ), Number::New (pos.x ));
46
- obj->Set (String::NewSymbol (" y" ), Number::New (pos.y ));
47
- return scope. Close (obj);
43
+ Local<Object> obj = NanNew< Object> ();
44
+ obj->Set (NanNew< String> (" x" ), NanNew< Number> (pos.x ));
45
+ obj->Set (NanNew< String> (" y" ), NanNew< Number> (pos.y ));
46
+ NanReturnValue (obj);
48
47
}
49
48
50
49
NAN_METHOD (mouseClick)
@@ -81,31 +80,28 @@ char *get(v8::Local<v8::Value> value, const char *fallback = "")
81
80
return str;
82
81
}
83
82
84
- Handle <Value> keyTap ( const Arguments& args )
83
+ NAN_METHOD (keyTap )
85
84
{
86
- HandleScope scope ;
85
+ NanScope () ;
87
86
88
87
MMKeyFlags flags = MOD_NONE;
88
+
89
+ const char c = (*v8::String::Utf8Value (args[0 ]->ToString ()))[0 ];
89
90
90
- char c = get (args[0 ])[0 ];
91
-
92
- if (strlen (&c)==1 )
93
- {
94
- tapKey (c, flags);
95
- }
91
+ tapKey (c, flags);
96
92
97
- return scope. Close ( String::New (" 1" ));
93
+ NanReturnValue ( NanNew (" 1" ));
98
94
}
99
95
100
- Handle <Value> typeString ( const Arguments& args )
96
+ NAN_METHOD (typeString )
101
97
{
102
- HandleScope scope ;
98
+ NanScope () ;
103
99
104
- char *str = get (args[0 ]);
100
+ char *str = get (args[0 ]-> ToString () );
105
101
106
102
typeString (str);
107
103
108
- return scope. Close ( String::New (" 1" ));
104
+ NanReturnValue ( NanNew (" 1" ));
109
105
}
110
106
111
107
void init (Handle <Object> target)
0 commit comments