Skip to content

Commit

Permalink
Converted typeString to use nan. Closes #1.
Browse files Browse the repository at this point in the history
  • Loading branch information
octalmage committed Jan 30, 2015
1 parent d44b1a2 commit ea62efa
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/robotjs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,6 @@ NAN_METHOD(mouseClick)
|___/
*/

char *get(v8::Local<v8::Value> value, const char *fallback = "")
{
if (value->IsString())
{
v8::String::AsciiValue string(value);
char *str = (char *) malloc(string.length() + 1);
strcpy(str, *string);
return str;
}
char *str = (char *) malloc(strlen(fallback) + 1);
strcpy(str, fallback);
return str;
}

NAN_METHOD (keyTap)
{
NanScope();
Expand All @@ -96,8 +82,11 @@ NAN_METHOD (keyTap)
NAN_METHOD (typeString)
{
NanScope();

char *str;
NanUtf8String string(args[0]);

char *str = get(args[0]->ToString());
str= *string;

typeString(str);

Expand Down

0 comments on commit ea62efa

Please sign in to comment.