Skip to content

Semi automatic porting of existing code

Benjamin Byholm edited this page Jan 16, 2015 · 2 revisions

The regular expressions need to be evaluated in the order provided and some of them (the scope.Close() thing) may produce false positives and are better done interactively. The observant reader notices that some of the expressions contain explicit parameter names, like the NAN_METHOD substitution. This is intentional, as NAN assumes standard argument names, and safe renaming of parameters may require contextual knowledge.

(v8\:\:)?Handle<(v8\:\:)?Value>\s*(\S+)\s*\(\s*const\s+(v8\:\:)?Arguments\s*&\s*args\s*\)
NAN_METHOD(\3)

(v8\:\:)?Handle<(v8\:\:)?Value>\s*(\S+)\s*\(\s*(v8\:\:)?Local<(v8\:\:)?String>\s*property\s*,\s*const\s*(v8\:\:)?AccessorInfo\s*&\s*info\s*\)
NAN_GETTER(\3)

void\s*(\S+)\s*\(\s*(v8\:\:)?Local<(v8\:\:)?String>\s*property\s*,\s*(v8\:\:)?Local<(v8\:\:)?Value>\s*value\s*,\s*const\s*(v8\:\:)?AccessorInfo\s*&\s*info\s*\)
NAN_SETTER(\1)

(v8\:\:)?HandleScope\s+scope
NanScope()

(v8\:\:)?String\:\:NewSymbol
NanNew

(v8\:\:)?Null\(\)
NanNull()

(v8\:\:)?Undefined\(\)
NanUndefined()

(v8\:\:)?True\(\)
NanTrue()

(v8\:\:)?False\(\)
NanFalse()

return\s+(v8\:\:)?ThrowException\s*\(\s*(v8\:\:)?Exception::Error\s*\(\s*(v8\:\:)?String::New\s*\((.*)\)\)\)
return NanThrowError(\4)

return\s+(v8\:\:)?ThrowException\s*\(\s*(v8\:\:)?Exception::TypeError\s*\(\s*(v8\:\:)?String::New\s*\((.*)\)\)\)
return NanThrowTypeError(\4)

return\s+(v8\:\:)?ThrowException\s*\(\s*(v8\:\:)?Exception::RangeError\s*\(\s*(v8\:\:)?String::New\s*\((.*)\)\)\)
return NanThrowRangeError(\4)

return\s+scope.Close\((v8\:\:)?ThrowException\((v8\:\:)?String::New\((.*)\)\)\)
return NanThrowError(\3)

return scope.Close
NanReturnValue

(\S+)\.Dispose\(\)
NanDisposePersistent(\1)

(\S+)\s*=\s*(v8\:\:)?Persistent<(v8\:\:)?(\S+)>::New\((.+)\)
NanAssignPersistent(\1, \5)

(v8\:\:)?Local\s*<\s*(\S*)>\s*\:\:\s*New\s*\(
NanNew<\2>(

(v8\:\:)?(\S+)\:\:\s*New\s*\(
NanNew<\2>(
Clone this wiki locally