From bae2093d448baf74d49892908b77a89900b2bc77 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Mon, 2 Sep 2013 12:54:18 -0400 Subject: [PATCH 1/9] New installer. - Converted to Promises. - Providing support for Windows. - Normalize paths correctly based on platform. --- binding.gyp | 2 +- install.js | 44 ++++------- package.json | 9 ++- test-installer.js | 181 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 204 insertions(+), 32 deletions(-) create mode 100644 test-installer.js diff --git a/binding.gyp b/binding.gyp index 17d1dc5f3..87e5c5238 100644 --- a/binding.gyp +++ b/binding.gyp @@ -46,7 +46,7 @@ ], 'libraries': [ - '-L= 0.8" }, "dependencies": { - "async": ">= 0.1.21", - "request": "2.9.x", + "request": "~2.25.0", + "node-gyp": "~0.10.9", + "tar": "~0.1.18", + "which": "~1.0.5", + "q": "~0.9.6", "node-gyp": "~0.8.2", - "tar": "0.1.17", "fs-extra": "0.6.0", "nan": "0.8.0" }, diff --git a/test-installer.js b/test-installer.js new file mode 100644 index 000000000..2b2cfdeee --- /dev/null +++ b/test-installer.js @@ -0,0 +1,181 @@ +// Core Node.js modules. +var fs = require('fs'); +var path = require('path'); +var zlib = require('zlib'); +var exec = require('child_process').exec; + +// Third-party modules. +var Q = require('q'); +var request = require('request'); +var tar = require('tar'); +var which = require('which'); +var rimraf = require('rimraf'); + +// This will take in an object and find any matching keys in the environment +// to use as overrides. +// +// ENV variables: +// +// PKG: Location of `package.json` sans `.json`. +// LIBGIT2: Location of libgit2 source. +// BUILD: Location of nodegit build directory. +function envOverride(obj) { + // Look through all keys. + return Object.keys(obj).reduce(function(obj, key) { + var normalize = key.toUpperCase(); + + // Check for process environment existence. + if (normalize in process.env) { + obj[key] = process.env[normalize]; + } + + return obj; + }, obj); +} + +// Convert to the correct system path. +function systemPath(parts) { + return parts.join(path.sep); +} + +// Will be used near the end to configure `node-gyp`. +var python, cmake; + +// Common reusable paths that can be overwritten by environment variables. +var paths = envOverride({ + pkg: __dirname + '/package', + libgit2: __dirname + '/vendor/libgit2/', + build: __dirname + '/vendor/libgit2/build/', +}); + +// Load the package.json. +var pkg = require(paths.pkg); + +// Ensure all dependencies are available. +var dependencies = Q.allSettled([ + // This will prioritize `python2` over `python`, because we always want to + // work with Python 2.* if it's available. + Q.nfcall(which, 'python2'), + Q.nfcall(which, 'python'), + + // Check for any version of CMake. + Q.nfcall(which, 'cmake'), +]) + +// Determine if all the dependency requirements are met. +.then(function(results) { + console.info('[nodegit] Determining dependencies.'); + + // Assign to reusable variables. + python = results[0].value || results[1].value; + cmake = results[2].value; + + // Missing Python. + if (!python) { + throw new Error('Python is required to build libgit2.'); + } + + // Missing CMake. + if (!cmake) { + throw new Error('CMake is required to build libgit2.'); + } + + // Now lets check the Python version to ensure it's < 3. + return Q.nfcall(exec, python + ' --version').then(function(version) { + if (version[1].indexOf('Python 3') === 0) { + throw new Error('Incorrect version of Python, gyp requires < 3.'); + } + }); +}) + +// Display a warning message about missing dependencies. +.fail(function(message) { + console.info('[nodegit] Failed to build nodegit.'); + console.info(message); + + throw new Error(message); +}) + +// Successfully found all dependencies. First step is to clean the vendor +// directory. +.then(function() { + console.info('[nodegit] Removing vendor/libgit2.'); + + return Q.ninvoke(rimraf, null, paths.libgit2); +}) + +// Now fetch the libgit2 source from GitHub. +.then(function() { + console.info('[nodegit] Fetching vendor/libgit2.'); + + var url = 'https://github.com/libgit2/libgit2/tarball/'+ pkg.libgit2; + + var extract = tar.Extract({ + path: paths.libgit2, + strip: true + }); + + // First extract from Zlib and then extract from Tar. + var expand = request.get(url).pipe(zlib.createUnzip()).pipe(extract); + + return Q.ninvoke(expand, 'on', 'end'); +}) + +// Fetch completed successfully. +.then(function() { + console.info('[nodegit] Creating vendor/libgit2/build.'); + + return Q.ninvoke(fs, 'mkdir', paths.build); +}) + +// Configure libgit2. +.then(function() { + console.info('[nodegit] Configuring libgit2.'); + + return Q.nfcall(exec, 'cmake -DTHREADSAFE=1 -DBUILD_CLAR=0 ..', { + cwd: paths.build + }); +}).fail(function(err) { + console.error(err); +}) + +// Build libgit2. +.then(function() { + console.info('[nodegit] Building libgit2.'); + + return Q.nfcall(exec, 'cmake --build .', { + cwd: paths.build + }); +}) + +.then(function() { + console.info('[nodegit] Configuring native node module.'); + + return Q.nfcall(exec, systemPath([ + '.', 'node_modules', '.bin', 'node-gyp configure --python ' + python + ]), { + cwd: '.' + }); +}) + +.then(function() { + console.info('[nodegit] Building native node module.'); + + return Q.nfcall(exec, systemPath([ + '.', 'node_modules', '.bin', 'node-gyp build ' + python + ]), { + cwd: '.' + }); +}) + +// Display a warning message about failing to build native node module. +.fail(function(message) { + console.info('[nodegit] Failed to build nodegit.'); + console.info(message); + + throw new Error(message); +}) + +.then(function() { + console.info('[nodegit] Completed installation successfully.'); +}); From 5e679b4b328e781c14d7107e5c0e01e586d90559 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Sat, 22 Mar 2014 20:39:03 -0400 Subject: [PATCH 2/9] Moved the test installer to main install. --- install.js | 265 ++++++++++++++++++++++++++++------------------ test-installer.js | 181 ------------------------------- 2 files changed, 163 insertions(+), 283 deletions(-) delete mode 100644 test-installer.js diff --git a/install.js b/install.js index 9573ce7c9..2b2cfdeee 100644 --- a/install.js +++ b/install.js @@ -2,119 +2,180 @@ var fs = require('fs'); var path = require('path'); var zlib = require('zlib'); +var exec = require('child_process').exec; // Third-party modules. var Q = require('q'); var request = require('request'); var tar = require('tar'); var which = require('which'); +var rimraf = require('rimraf'); -// Build options. -var options = { - // Normalize the libgit2 build directory. - libgit2build: path.join(__dirname, 'vendor/libgit2/build') -}; +// This will take in an object and find any matching keys in the environment +// to use as overrides. +// +// ENV variables: +// +// PKG: Location of `package.json` sans `.json`. +// LIBGIT2: Location of libgit2 source. +// BUILD: Location of nodegit build directory. +function envOverride(obj) { + // Look through all keys. + return Object.keys(obj).reduce(function(obj, key) { + var normalize = key.toUpperCase(); -function shpassthru() { - passthru.apply(null, ['/bin/sh', '-c'].concat(Array.prototype.slice.call(arguments))); + // Check for process environment existence. + if (normalize in process.env) { + obj[key] = process.env[normalize]; + } + + return obj; + }, obj); } -function envpassthru() { - passthru.apply(null, ['/usr/bin/env'].concat(Array.prototype.slice.call(arguments))); +// Convert to the correct system path. +function systemPath(parts) { + return parts.join(path.sep); } -var updateSubmodules = function(mainCallback) { - console.log('[nodegit] Downloading libgit2 dependency.'); - async.series([26 - function(callback) { - envpassthru('git', 'submodule', 'init', callback); - }, function(callback) { - envpassthru('git', 'submodule', 'update', callback); - } - ], function(error) { - if (error) process.exit(error); - mainCallback(); - }); -}; - -var checkoutDependencies = function(mainCallback) { - console.log('[nodegit] Downloading libgit2 dependency.'); - var commit = 'e953c1606d0d7aea680c9b19db0b955b34ae63c2'; - - var url = 'https://github.com/libgit2/libgit2/tarball/'+ commit; - var path = __dirname + '/vendor/libgit2/'; - request({ - url: url - }).pipe(zlib.createUnzip()).pipe(tar.Extract({ - path: path, - strip: true - })).on('end', function() { - mainCallback(); - }); -}; - -Q.ninvoke(which, "python2"). - -async.series([ - function checkPython2Exists(callback) { - exec('which python2', - function (error) { - if (!error) { - pythonExecutable = 'python2'; - callback(); - return; - } - // python2 is not available, check for python - exec('which python', function(error) { - if (error) { - throw new Error('Python is required to build libgit2'); - } - callback(); - }); - }); - - }, - function prepareLibgit2Repository(callback) { - // Check for presence of .git folder - fs.exists(__dirname + '/.git', function(exists) { - if (exists) { - updateSubmodules(callback); - } else { - checkoutDependencies(callback); - } - }); - }, - function deleteExistingLibgit2BuildFolder(callback) { - // fs.exists(libgit2BuildDirectory, function(exists) { - // if (exists) { - // fs.remove(libgit2BuildDirectory, callback); - // } else { - callback(); - // } - // }); - }, - function createLibgit2BuildDirectory(callback) { - console.log('[nodegit] Building libgit2 dependency.'); - fs.mkdirs(libgit2BuildDirectory, callback); - }, - function configureLibgit2(callback) { - envpassthru('cmake', '-DTHREADSAFE=1', '-DBUILD_CLAR=0', '..', { - cwd: libgit2BuildDirectory - }, callback); - }, - function buildLibgit2(callback) { - envpassthru('cmake', '--build', '.', { - cwd: libgit2BuildDirectory - }, callback); - }, - function configureNodegit(callback) { - console.log('[nodegit] Building native module.'); - // shpassthru('node-gyp configure --python python2 --debug', callback); - shpassthru('node-gyp configure --python ' + pythonExecutable, callback); - }, - function buildNodegit(callback) { - shpassthru('node-gyp build', callback); +// Will be used near the end to configure `node-gyp`. +var python, cmake; + +// Common reusable paths that can be overwritten by environment variables. +var paths = envOverride({ + pkg: __dirname + '/package', + libgit2: __dirname + '/vendor/libgit2/', + build: __dirname + '/vendor/libgit2/build/', +}); + +// Load the package.json. +var pkg = require(paths.pkg); + +// Ensure all dependencies are available. +var dependencies = Q.allSettled([ + // This will prioritize `python2` over `python`, because we always want to + // work with Python 2.* if it's available. + Q.nfcall(which, 'python2'), + Q.nfcall(which, 'python'), + + // Check for any version of CMake. + Q.nfcall(which, 'cmake'), +]) + +// Determine if all the dependency requirements are met. +.then(function(results) { + console.info('[nodegit] Determining dependencies.'); + + // Assign to reusable variables. + python = results[0].value || results[1].value; + cmake = results[2].value; + + // Missing Python. + if (!python) { + throw new Error('Python is required to build libgit2.'); + } + + // Missing CMake. + if (!cmake) { + throw new Error('CMake is required to build libgit2.'); + } + + // Now lets check the Python version to ensure it's < 3. + return Q.nfcall(exec, python + ' --version').then(function(version) { + if (version[1].indexOf('Python 3') === 0) { + throw new Error('Incorrect version of Python, gyp requires < 3.'); } -], function handleError(error) { - if(error) process.exit(error); + }); +}) + +// Display a warning message about missing dependencies. +.fail(function(message) { + console.info('[nodegit] Failed to build nodegit.'); + console.info(message); + + throw new Error(message); +}) + +// Successfully found all dependencies. First step is to clean the vendor +// directory. +.then(function() { + console.info('[nodegit] Removing vendor/libgit2.'); + + return Q.ninvoke(rimraf, null, paths.libgit2); +}) + +// Now fetch the libgit2 source from GitHub. +.then(function() { + console.info('[nodegit] Fetching vendor/libgit2.'); + + var url = 'https://github.com/libgit2/libgit2/tarball/'+ pkg.libgit2; + + var extract = tar.Extract({ + path: paths.libgit2, + strip: true + }); + + // First extract from Zlib and then extract from Tar. + var expand = request.get(url).pipe(zlib.createUnzip()).pipe(extract); + + return Q.ninvoke(expand, 'on', 'end'); +}) + +// Fetch completed successfully. +.then(function() { + console.info('[nodegit] Creating vendor/libgit2/build.'); + + return Q.ninvoke(fs, 'mkdir', paths.build); +}) + +// Configure libgit2. +.then(function() { + console.info('[nodegit] Configuring libgit2.'); + + return Q.nfcall(exec, 'cmake -DTHREADSAFE=1 -DBUILD_CLAR=0 ..', { + cwd: paths.build + }); +}).fail(function(err) { + console.error(err); +}) + +// Build libgit2. +.then(function() { + console.info('[nodegit] Building libgit2.'); + + return Q.nfcall(exec, 'cmake --build .', { + cwd: paths.build + }); +}) + +.then(function() { + console.info('[nodegit] Configuring native node module.'); + + return Q.nfcall(exec, systemPath([ + '.', 'node_modules', '.bin', 'node-gyp configure --python ' + python + ]), { + cwd: '.' + }); +}) + +.then(function() { + console.info('[nodegit] Building native node module.'); + + return Q.nfcall(exec, systemPath([ + '.', 'node_modules', '.bin', 'node-gyp build ' + python + ]), { + cwd: '.' + }); +}) + +// Display a warning message about failing to build native node module. +.fail(function(message) { + console.info('[nodegit] Failed to build nodegit.'); + console.info(message); + + throw new Error(message); +}) + +.then(function() { + console.info('[nodegit] Completed installation successfully.'); }); diff --git a/test-installer.js b/test-installer.js deleted file mode 100644 index 2b2cfdeee..000000000 --- a/test-installer.js +++ /dev/null @@ -1,181 +0,0 @@ -// Core Node.js modules. -var fs = require('fs'); -var path = require('path'); -var zlib = require('zlib'); -var exec = require('child_process').exec; - -// Third-party modules. -var Q = require('q'); -var request = require('request'); -var tar = require('tar'); -var which = require('which'); -var rimraf = require('rimraf'); - -// This will take in an object and find any matching keys in the environment -// to use as overrides. -// -// ENV variables: -// -// PKG: Location of `package.json` sans `.json`. -// LIBGIT2: Location of libgit2 source. -// BUILD: Location of nodegit build directory. -function envOverride(obj) { - // Look through all keys. - return Object.keys(obj).reduce(function(obj, key) { - var normalize = key.toUpperCase(); - - // Check for process environment existence. - if (normalize in process.env) { - obj[key] = process.env[normalize]; - } - - return obj; - }, obj); -} - -// Convert to the correct system path. -function systemPath(parts) { - return parts.join(path.sep); -} - -// Will be used near the end to configure `node-gyp`. -var python, cmake; - -// Common reusable paths that can be overwritten by environment variables. -var paths = envOverride({ - pkg: __dirname + '/package', - libgit2: __dirname + '/vendor/libgit2/', - build: __dirname + '/vendor/libgit2/build/', -}); - -// Load the package.json. -var pkg = require(paths.pkg); - -// Ensure all dependencies are available. -var dependencies = Q.allSettled([ - // This will prioritize `python2` over `python`, because we always want to - // work with Python 2.* if it's available. - Q.nfcall(which, 'python2'), - Q.nfcall(which, 'python'), - - // Check for any version of CMake. - Q.nfcall(which, 'cmake'), -]) - -// Determine if all the dependency requirements are met. -.then(function(results) { - console.info('[nodegit] Determining dependencies.'); - - // Assign to reusable variables. - python = results[0].value || results[1].value; - cmake = results[2].value; - - // Missing Python. - if (!python) { - throw new Error('Python is required to build libgit2.'); - } - - // Missing CMake. - if (!cmake) { - throw new Error('CMake is required to build libgit2.'); - } - - // Now lets check the Python version to ensure it's < 3. - return Q.nfcall(exec, python + ' --version').then(function(version) { - if (version[1].indexOf('Python 3') === 0) { - throw new Error('Incorrect version of Python, gyp requires < 3.'); - } - }); -}) - -// Display a warning message about missing dependencies. -.fail(function(message) { - console.info('[nodegit] Failed to build nodegit.'); - console.info(message); - - throw new Error(message); -}) - -// Successfully found all dependencies. First step is to clean the vendor -// directory. -.then(function() { - console.info('[nodegit] Removing vendor/libgit2.'); - - return Q.ninvoke(rimraf, null, paths.libgit2); -}) - -// Now fetch the libgit2 source from GitHub. -.then(function() { - console.info('[nodegit] Fetching vendor/libgit2.'); - - var url = 'https://github.com/libgit2/libgit2/tarball/'+ pkg.libgit2; - - var extract = tar.Extract({ - path: paths.libgit2, - strip: true - }); - - // First extract from Zlib and then extract from Tar. - var expand = request.get(url).pipe(zlib.createUnzip()).pipe(extract); - - return Q.ninvoke(expand, 'on', 'end'); -}) - -// Fetch completed successfully. -.then(function() { - console.info('[nodegit] Creating vendor/libgit2/build.'); - - return Q.ninvoke(fs, 'mkdir', paths.build); -}) - -// Configure libgit2. -.then(function() { - console.info('[nodegit] Configuring libgit2.'); - - return Q.nfcall(exec, 'cmake -DTHREADSAFE=1 -DBUILD_CLAR=0 ..', { - cwd: paths.build - }); -}).fail(function(err) { - console.error(err); -}) - -// Build libgit2. -.then(function() { - console.info('[nodegit] Building libgit2.'); - - return Q.nfcall(exec, 'cmake --build .', { - cwd: paths.build - }); -}) - -.then(function() { - console.info('[nodegit] Configuring native node module.'); - - return Q.nfcall(exec, systemPath([ - '.', 'node_modules', '.bin', 'node-gyp configure --python ' + python - ]), { - cwd: '.' - }); -}) - -.then(function() { - console.info('[nodegit] Building native node module.'); - - return Q.nfcall(exec, systemPath([ - '.', 'node_modules', '.bin', 'node-gyp build ' + python - ]), { - cwd: '.' - }); -}) - -// Display a warning message about failing to build native node module. -.fail(function(message) { - console.info('[nodegit] Failed to build nodegit.'); - console.info(message); - - throw new Error(message); -}) - -.then(function() { - console.info('[nodegit] Completed installation successfully.'); -}); From d90236385d5e5ce7b6e790235238e6231b742fd2 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Sun, 23 Mar 2014 14:42:01 -0400 Subject: [PATCH 3/9] Added async to devDependencies so tests can run. --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b6911e33..f95b59ccc 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,8 @@ "nodeunit": "~0.8.6", "rimraf": "~2.2.6", "ejs": "~1.0.0", - "ncp": "~0.5.0" + "ncp": "~0.5.0", + "async": "~0.2.10" }, "scripts": { "lint": "jshint src", From ee646e33bb892735cb68785f0331859a23d32ccd Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Sun, 23 Mar 2014 14:50:09 -0400 Subject: [PATCH 4/9] Remove python from build command. --- install.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.js b/install.js index 2b2cfdeee..1d4deaeb0 100644 --- a/install.js +++ b/install.js @@ -162,7 +162,7 @@ var dependencies = Q.allSettled([ console.info('[nodegit] Building native node module.'); return Q.nfcall(exec, systemPath([ - '.', 'node_modules', '.bin', 'node-gyp build ' + python + '.', 'node_modules', '.bin', 'node-gyp build' ]), { cwd: '.' }); From 35be88fdd25e245a5121f0fba990f2350bca9fa8 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Sun, 23 Mar 2014 15:02:32 -0400 Subject: [PATCH 5/9] Revert changing the libgit2 library path. --- binding.gyp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding.gyp b/binding.gyp index 87e5c5238..8a6d71977 100644 --- a/binding.gyp +++ b/binding.gyp @@ -46,7 +46,7 @@ ], 'libraries': [ - '-Lvendor\\libgit2\\build', + '-L Date: Tue, 29 Apr 2014 21:42:28 -0400 Subject: [PATCH 6/9] Updated the license date and binding to latest. I took the latest binding and made it work with the existing to resolve the build failure. --- LICENSE | 2 +- binding.gyp | 168 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 107 insertions(+), 63 deletions(-) diff --git a/LICENSE b/LICENSE index 80bc57cb1..8fe4c2f4c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2013 Tim Branyen +Copyright (c) 2014 Tim Branyen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/binding.gyp b/binding.gyp index 8a6d71977..1d2026b3f 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,70 +1,114 @@ { - 'targets': [ - { - 'target_name': 'nodegit', - 'sources': [ - 'src/base.cc', - 'src/blob.cc', - 'src/commit.cc', - 'src/oid.cc', - 'src/reference.cc', - 'src/object.cc', - 'src/repo.cc', - 'src/index.cc', - 'src/index_entry.cc', - 'src/index_time.cc', - 'src/tag.cc', - 'src/revwalk.cc', - 'src/signature.cc', - 'src/time.cc', - 'src/tree.cc', - 'src/tree_builder.cc', - 'src/tree_entry.cc', - 'src/diff_find_options.cc', - 'src/diff_options.cc', - 'src/diff_list.cc', - 'src/patch.cc', - 'src/delta.cc', - 'src/diff_file.cc', - 'src/diff_range.cc', - 'src/threads.cc', - 'src/wrapper.cc', - 'src/refdb.cc', - 'src/odb_object.cc', - 'src/odb.cc', - 'src/submodule.cc', - 'src/remote.cc', - 'src/clone_options.cc', - 'src/functions/copy.cc', + "targets": [ + { + "target_name": "nodegit", - ], + "sources": [ + "src/base.cc", + "src/blob.cc", + "src/commit.cc", + "src/oid.cc", + "src/reference.cc", + "src/object.cc", + "src/repo.cc", + "src/index.cc", + "src/index_entry.cc", + "src/index_time.cc", + "src/tag.cc", + "src/revwalk.cc", + "src/signature.cc", + "src/time.cc", + "src/tree.cc", + "src/tree_builder.cc", + "src/tree_entry.cc", + "src/diff_find_options.cc", + "src/diff_options.cc", + "src/diff_list.cc", + "src/patch.cc", + "src/delta.cc", + "src/diff_file.cc", + "src/diff_range.cc", + "src/threads.cc", + "src/wrapper.cc", + "src/refdb.cc", + "src/odb_object.cc", + "src/odb.cc", + "src/submodule.cc", + "src/remote.cc", + "src/clone_options.cc", + "src/functions/copy.cc", + ], - 'include_dirs': [ - 'vendor/libv8-convert', - 'vendor/libgit2/include', - " Date: Tue, 29 Apr 2014 21:43:46 -0400 Subject: [PATCH 7/9] Unrelated commit: Updated the git_profanity_check app. --- example/apps/git_profanity_check.js | 68 ++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/example/apps/git_profanity_check.js b/example/apps/git_profanity_check.js index 618eb7a66..7f0674849 100644 --- a/example/apps/git_profanity_check.js +++ b/example/apps/git_profanity_check.js @@ -1,40 +1,66 @@ #!/usr/bin/env node +// vim: ft=javascript -// Copyright 2011, Tim Branyen @tbranyen +// Copyright 2011-2014, Tim Branyen @tbranyen // Dual licensed under the MIT and GPL licenses. -// Script to detect cursewords in commit messages and provide the -// offending commit sha's. -// vim: ft=javascript +// Script to detect cursewords in commit messages and provide the offending +// commit sha's. +// +// Usage: +// +// node git_profanity_check some/repo/.git +// var git = require('../../'); -var curses = ['add', 'swears', 'here'], - path = '../../.git', - branchName = 'master', - reCurse = new RegExp('\\b(?:' + curses.join('|') + ')\\b', 'gi'); - +var curses = ['put', 'curse', 'words', 'here']; +var path = './.git'; +var branch = 'master'; +var reCurse = new RegExp('\\b(?:' + curses.join('|') + ')\\b', 'gi'); +// Default path is `.git`. if (process.argv.length < 3) { - console.log('No git path passed as argument, defaulting to ./.git'); -} else { + console.log('No path passed as argument, defaulting to .git.'); +} +// Otherwise defaults. +else { path = process.argv[2]; + // Set repo branch if (process.argv.length < 4) { - console.log('No repo branchName passed as argument, defaulting to master'); - } else { - branchName = process.argv[3]; + console.log('No branch passed as argument, defaulting to master.'); + } + else { + branch = process.argv[3]; } } -git.Repo.open(path, function(error, repo) { - if (error) throw error; +// Open repository. +git.Repo.open(path, function(err, repo) { + if (err) { + throw new Error(err); + } - repo.getBranch(branchName, function(error, branch) { - if (error) throw error; + // Open branch, default to master. + repo.getBranch(branch, function(err, branch) { + if (err) { + throw new Error(err); + } + // Iterate history var history = branch.history(); + + // Iterate over every commit message and test for words. history.on('commit', function(commit) { - if (reCurse.test(commit.message())) - console.log('Curse detected in commit', commit.sha(), 'message', commit.message()); - }).start(); + var message = commit.message(); + + if (reCurse.test(message)) { + console.log('Curse detected in commit', commit.sha()); + console.log('=> ', message); + return; + } + }); + + // Start history iteration. + history.start(); }); }); From c093d1efa12bf4d6e02fd36e801052ad9a8bd119 Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 30 Apr 2014 00:44:33 -0400 Subject: [PATCH 8/9] Finally, Windows support! This has taken me hours to figure out, but in order to get Windows working a few issues had to be resolved: - Casting. I've added an additional argument parameter in the libgit2 JSON API to allow for special cast provisioning in the case where direct casting isn't possible. - Update libgit2 build flags to not use STDCALL when compiling in Windows. - Updated the binding.gyp file to have the correct configuratoin necessary for cross platform compiling. --- .gitignore | 3 +- binding.gyp | 64 +- build/codegen/templates/convertFromV8.cc.ejs | 4 +- build/codegen/v0.18.0.json | 6 +- include/blob.h | 14 +- include/branch.h | 31 +- include/clone_options.h | 7 +- include/commit.h | 31 +- include/delta.h | 16 +- include/diff_file.h | 16 +- include/diff_find_options.h | 7 +- include/diff_list.h | 20 +- include/diff_options.h | 7 +- include/diff_range.h | 14 +- include/index.h | 41 +- include/index_entry.h | 34 +- include/index_time.h | 11 +- include/object.h | 12 +- include/odb.h | 28 +- include/odb_object.h | 17 +- include/oid.h | 14 +- include/patch.h | 21 +- include/refdb.h | 7 +- include/reference.h | 39 +- include/remote.h | 41 +- include/repo.h | 64 +- include/revwalk.h | 28 +- include/signature.h | 26 +- include/submodule.h | 35 +- include/tag.h | 23 +- include/threads.h | 12 +- include/time.h | 15 +- include/tree.h | 26 +- include/tree_builder.h | 21 +- include/tree_entry.h | 16 +- install.js | 10 +- src/blob.cc | 56 +- src/branch.cc | 19 +- src/clone_options.cc | 28 +- src/commit.cc | 109 +- src/delta.cc | 59 +- src/diff_file.cc | 59 +- src/diff_find_options.cc | 29 +- src/diff_list.cc | 83 +- src/diff_options.cc | 28 +- src/diff_range.cc | 53 +- src/index.cc | 366 +++--- src/index_entry.cc | 101 +- src/index_time.cc | 41 +- src/object.cc | 76 +- src/odb.cc | 238 ++-- src/odb_object.cc | 52 +- src/oid.cc | 46 +- src/patch.cc | 102 +- src/refdb.cc | 28 +- src/reference.cc | 287 +++-- src/remote.cc | 262 +++-- src/repo.cc | 1058 +++++++++--------- src/revwalk.cc | 344 +++--- src/signature.cc | 84 +- src/submodule.cc | 289 +++-- src/tag.cc | 98 +- src/threads.cc | 28 +- src/time.cc | 43 +- src/tree.cc | 284 +++-- src/tree_builder.cc | 124 +- src/tree_entry.cc | 86 +- vendor/libgit2 | 1 - 68 files changed, 2598 insertions(+), 2744 deletions(-) delete mode 160000 vendor/libgit2 diff --git a/.gitignore b/.gitignore index e6818ce11..ca418ca39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /build/* !/build/codegen/ +/node_modules/ +/vendor/libgit2/ /doc/* !/doc/Theme.css -/node_modules /test/.reposCache diff --git a/binding.gyp b/binding.gyp index 1d2026b3f..6233c2826 100644 --- a/binding.gyp +++ b/binding.gyp @@ -54,60 +54,26 @@ ], "conditions": [ - ['OS=="win"', { - "link_settings": { + [ + "OS=='win'", { "libraries": [ - "-lgit2.lib", + "-l../vendor/libgit2/build/Debug/git2.lib" + ], + }, { # 'OS!="win"' + "libraries": [ + "-L from_<%- arg.name %> = Buffer::Data(args[<%- jsArg %>]->ToObject()); <% } else if (isV8Value(arg.cppClassName)) { -%> - from_<%- arg.name %> = (<%- arg.cType %>) args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value(); + from_<%- arg.name %> = (<%- arg.cType %>) <%- arg.additionalCast %> <%- arg.cast %> args[<%- jsArg %>]->To<%- arg.cppClassName %>()->Value(); <% } else { -%> from_<%- arg.name %> = ObjectWrap::Unwrap<<%- arg.cppClassName %>>(args[<%- jsArg %>]->ToObject())->GetValue(); <% } -%> @@ -29,4 +29,4 @@ from_<%- arg.name %> = 0; } <% } -%> -<% } -%> \ No newline at end of file +<% } -%> diff --git a/build/codegen/v0.18.0.json b/build/codegen/v0.18.0.json index 58127837d..1671d2a81 100644 --- a/build/codegen/v0.18.0.json +++ b/build/codegen/v0.18.0.json @@ -10380,7 +10380,8 @@ "cType": "git_direction", "cppClassName": "Number", "jsClassName": "Number", - "comment": "GIT_DIRECTION_FETCH if you want to fetch or GIT_DIRECTION_PUSH if you want to push" + "comment": "GIT_DIRECTION_FETCH if you want to fetch or GIT_DIRECTION_PUSH if you want to push", + "additionalCast": "(int)" } ], "isAsync": true, @@ -17283,7 +17284,8 @@ "cType": "git_filemode_t", "cppClassName": "Number", "jsClassName": "Number", - "comment": "Folder attributes of the entry. This parameter must be valued with one of the following entries: 0040000, 0100644, 0100755, 0120000 or 0160000." + "comment": "Folder attributes of the entry. This parameter must be valued with one of the following entries: 0040000, 0100644, 0100755, 0120000 or 0160000.", + "additionalCast": "(int)" } ], "isAsync": false, diff --git a/include/blob.h b/include/blob.h index 94f3537bd..561338354 100755 --- a/include/blob.h +++ b/include/blob.h @@ -8,7 +8,6 @@ #include #include #include -#include "nan.h" #include "git2.h" @@ -18,7 +17,7 @@ using namespace v8; class GitBlob : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_blob *GetValue(); @@ -29,12 +28,13 @@ class GitBlob : public ObjectWrap { GitBlob(git_blob *raw); ~GitBlob(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(Oid); - static NAN_METHOD(Content); - static NAN_METHOD(Size); - static NAN_METHOD(IsBinary); + + static Handle Oid(const Arguments& args); + static Handle Content(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle IsBinary(const Arguments& args); git_blob *raw; }; diff --git a/include/branch.h b/include/branch.h index 67b4eb373..bfbf9bcdb 100644 --- a/include/branch.h +++ b/include/branch.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class Branch : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_branch *GetValue(); @@ -30,19 +28,20 @@ class Branch : public ObjectWrap { Branch(git_branch *raw); ~Branch(); - static NAN_METHOD(New); - - static NAN_METHOD(Create); - static NAN_METHOD(Delete); - static NAN_METHOD(Foreach); - static NAN_METHOD(Move); - static NAN_METHOD(Lookup); - static NAN_METHOD(Name); - static NAN_METHOD(Upstream); - static NAN_METHOD(SetUpstream); - static NAN_METHOD(UpstreamName); - static NAN_METHOD(IsHead); - static NAN_METHOD(RemoteName); + static Handle New(const Arguments& args); + + + static Handle Create(const Arguments& args); + static Handle Delete(const Arguments& args); + static Handle Foreach(const Arguments& args); + static Handle Move(const Arguments& args); + static Handle Lookup(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Upstream(const Arguments& args); + static Handle SetUpstream(const Arguments& args); + static Handle UpstreamName(const Arguments& args); + static Handle IsHead(const Arguments& args); + static Handle RemoteName(const Arguments& args); git_branch *raw; }; diff --git a/include/clone_options.h b/include/clone_options.h index 42db7e0c8..14da5daad 100644 --- a/include/clone_options.h +++ b/include/clone_options.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitCloneOptions : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_clone_options *GetValue(); @@ -30,7 +28,8 @@ class GitCloneOptions : public ObjectWrap { GitCloneOptions(git_clone_options *raw); ~GitCloneOptions(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + git_clone_options *raw; }; diff --git a/include/commit.h b/include/commit.h index a02ed9f77..6f69f5889 100755 --- a/include/commit.h +++ b/include/commit.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitCommit : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_commit *GetValue(); @@ -30,19 +28,20 @@ class GitCommit : public ObjectWrap { GitCommit(git_commit *raw); ~GitCommit(); - static NAN_METHOD(New); - - static NAN_METHOD(Oid); - static NAN_METHOD(MessageEncoding); - static NAN_METHOD(Message); - static NAN_METHOD(Time); - static NAN_METHOD(Offset); - static NAN_METHOD(Committer); - static NAN_METHOD(Author); - static NAN_METHOD(TreeId); - static NAN_METHOD(ParentCount); - static NAN_METHOD(ParentId); - static NAN_METHOD(NthGenAncestor); + static Handle New(const Arguments& args); + + + static Handle Oid(const Arguments& args); + static Handle MessageEncoding(const Arguments& args); + static Handle Message(const Arguments& args); + static Handle Time(const Arguments& args); + static Handle Offset(const Arguments& args); + static Handle Committer(const Arguments& args); + static Handle Author(const Arguments& args); + static Handle TreeId(const Arguments& args); + static Handle ParentCount(const Arguments& args); + static Handle ParentId(const Arguments& args); + static Handle NthGenAncestor(const Arguments& args); git_commit *raw; }; diff --git a/include/delta.h b/include/delta.h index d46511b9c..e06f6283c 100644 --- a/include/delta.h +++ b/include/delta.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitDelta : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_diff_delta *GetValue(); @@ -30,13 +28,13 @@ class GitDelta : public ObjectWrap { GitDelta(git_diff_delta *raw); ~GitDelta(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(OldFile); - static NAN_METHOD(NewFile); - static NAN_METHOD(Status); - static NAN_METHOD(Similarity); - static NAN_METHOD(Flags); + static Handle OldFile(const Arguments& args); + static Handle NewFile(const Arguments& args); + static Handle Status(const Arguments& args); + static Handle Similarity(const Arguments& args); + static Handle Flags(const Arguments& args); git_diff_delta *raw; }; diff --git a/include/diff_file.h b/include/diff_file.h index adb50ab42..f7f8210d0 100644 --- a/include/diff_file.h +++ b/include/diff_file.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitDiffFile : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_diff_file *GetValue(); @@ -30,13 +28,13 @@ class GitDiffFile : public ObjectWrap { GitDiffFile(git_diff_file *raw); ~GitDiffFile(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(Oid); - static NAN_METHOD(Path); - static NAN_METHOD(Size); - static NAN_METHOD(Flags); - static NAN_METHOD(Mode); + static Handle Oid(const Arguments& args); + static Handle Path(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Flags(const Arguments& args); + static Handle Mode(const Arguments& args); git_diff_file *raw; }; diff --git a/include/diff_find_options.h b/include/diff_find_options.h index d76efe975..3500d1b23 100644 --- a/include/diff_find_options.h +++ b/include/diff_find_options.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitDiffFindOptions : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_diff_find_options *GetValue(); @@ -30,7 +28,8 @@ class GitDiffFindOptions : public ObjectWrap { GitDiffFindOptions(git_diff_find_options *raw); ~GitDiffFindOptions(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + git_diff_find_options *raw; }; diff --git a/include/diff_list.h b/include/diff_list.h index 04c604766..185a00e56 100644 --- a/include/diff_list.h +++ b/include/diff_list.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitDiffList : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_diff_list *GetValue(); @@ -29,15 +27,15 @@ class GitDiffList : public ObjectWrap { private: GitDiffList(git_diff_list *raw); ~GitDiffList(); - - static NAN_METHOD(New); - - static NAN_METHOD(Merge); - static NAN_METHOD(FindSimilar); - static NAN_METHOD(Size); - static NAN_METHOD(NumDeltasOfType); - static NAN_METHOD(Patch); + static Handle New(const Arguments& args); + + + static Handle Merge(const Arguments& args); + static Handle FindSimilar(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle NumDeltasOfType(const Arguments& args); + static Handle Patch(const Arguments& args); git_diff_list *raw; }; diff --git a/include/diff_options.h b/include/diff_options.h index 292269763..6dd93a0b8 100644 --- a/include/diff_options.h +++ b/include/diff_options.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitDiffOptions : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_diff_options *GetValue(); @@ -30,7 +28,8 @@ class GitDiffOptions : public ObjectWrap { GitDiffOptions(git_diff_options *raw); ~GitDiffOptions(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + git_diff_options *raw; }; diff --git a/include/diff_range.h b/include/diff_range.h index 7df5b8042..bb44337b4 100644 --- a/include/diff_range.h +++ b/include/diff_range.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitDiffRange : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_diff_range *GetValue(); @@ -30,12 +28,12 @@ class GitDiffRange : public ObjectWrap { GitDiffRange(git_diff_range *raw); ~GitDiffRange(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(OldStart); - static NAN_METHOD(OldLines); - static NAN_METHOD(NewStart); - static NAN_METHOD(NewLines); + static Handle OldStart(const Arguments& args); + static Handle OldLines(const Arguments& args); + static Handle NewStart(const Arguments& args); + static Handle NewLines(const Arguments& args); git_diff_range *raw; }; diff --git a/include/index.h b/include/index.h index 4edafefec..e634d7ea0 100755 --- a/include/index.h +++ b/include/index.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitIndex : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_index *GetValue(); @@ -30,9 +28,10 @@ class GitIndex : public ObjectWrap { GitIndex(git_index *raw); ~GitIndex(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + - static NAN_METHOD(Open); + static Handle Open(const Arguments& args); static void OpenWork(uv_work_t* req); static void OpenAfterWork(uv_work_t* req); @@ -45,7 +44,7 @@ class GitIndex : public ObjectWrap { const char * index_path; Persistent callback; }; - static NAN_METHOD(Read); + static Handle Read(const Arguments& args); static void ReadWork(uv_work_t* req); static void ReadAfterWork(uv_work_t* req); @@ -57,7 +56,7 @@ class GitIndex : public ObjectWrap { git_index * index; Persistent callback; }; - static NAN_METHOD(Write); + static Handle Write(const Arguments& args); static void WriteWork(uv_work_t* req); static void WriteAfterWork(uv_work_t* req); @@ -69,7 +68,7 @@ class GitIndex : public ObjectWrap { git_index * index; Persistent callback; }; - static NAN_METHOD(ReadTree); + static Handle ReadTree(const Arguments& args); static void ReadTreeWork(uv_work_t* req); static void ReadTreeAfterWork(uv_work_t* req); @@ -83,7 +82,7 @@ class GitIndex : public ObjectWrap { const git_tree * tree; Persistent callback; }; - static NAN_METHOD(WriteTree); + static Handle WriteTree(const Arguments& args); static void WriteTreeWork(uv_work_t* req); static void WriteTreeAfterWork(uv_work_t* req); @@ -96,12 +95,12 @@ class GitIndex : public ObjectWrap { git_index * index; Persistent callback; }; - static NAN_METHOD(Size); - static NAN_METHOD(Clear); - static NAN_METHOD(Entry); - static NAN_METHOD(Remove); - static NAN_METHOD(RemoveDirectory); - static NAN_METHOD(AddBypath); + static Handle Size(const Arguments& args); + static Handle Clear(const Arguments& args); + static Handle Entry(const Arguments& args); + static Handle Remove(const Arguments& args); + static Handle RemoveDirectory(const Arguments& args); + static Handle AddBypath(const Arguments& args); static void AddBypathWork(uv_work_t* req); static void AddBypathAfterWork(uv_work_t* req); @@ -115,12 +114,12 @@ class GitIndex : public ObjectWrap { const char * path; Persistent callback; }; - static NAN_METHOD(RemoveBypath); - static NAN_METHOD(Find); - static NAN_METHOD(ConflictRemove); - static NAN_METHOD(ConflictCleanup); - static NAN_METHOD(HasConflicts); - static NAN_METHOD(IndexToWorkdir); + static Handle RemoveBypath(const Arguments& args); + static Handle Find(const Arguments& args); + static Handle ConflictRemove(const Arguments& args); + static Handle ConflictCleanup(const Arguments& args); + static Handle HasConflicts(const Arguments& args); + static Handle IndexToWorkdir(const Arguments& args); static void IndexToWorkdirWork(uv_work_t* req); static void IndexToWorkdirAfterWork(uv_work_t* req); diff --git a/include/index_entry.h b/include/index_entry.h index 8e3ea5072..7bf5fc6a8 100644 --- a/include/index_entry.h +++ b/include/index_entry.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitIndexEntry : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_index_entry *GetValue(); @@ -30,21 +28,21 @@ class GitIndexEntry : public ObjectWrap { GitIndexEntry(git_index_entry *raw); ~GitIndexEntry(); - static NAN_METHOD(New); - - static NAN_METHOD(Ctime); - static NAN_METHOD(Mtime); - static NAN_METHOD(Dev); - static NAN_METHOD(Ino); - static NAN_METHOD(Mode); - static NAN_METHOD(Uid); - static NAN_METHOD(gid); - static NAN_METHOD(FileSize); - static NAN_METHOD(Oid); - static NAN_METHOD(Flags); - static NAN_METHOD(FlagsExtended); - static NAN_METHOD(Path); - + static Handle New(const Arguments& args); + + static Handle Ctime(const Arguments& args); + static Handle Mtime(const Arguments& args); + static Handle Dev(const Arguments& args); + static Handle Ino(const Arguments& args); + static Handle Mode(const Arguments& args); + static Handle Uid(const Arguments& args); + static Handle gid(const Arguments& args); + static Handle FileSize(const Arguments& args); + static Handle Oid(const Arguments& args); + static Handle Flags(const Arguments& args); + static Handle FlagsExtended(const Arguments& args); + static Handle Path(const Arguments& args); + git_index_entry *raw; }; diff --git a/include/index_time.h b/include/index_time.h index ad8dc49a5..765ce6cc7 100644 --- a/include/index_time.h +++ b/include/index_time.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitIndexTime : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_index_time *GetValue(); @@ -30,10 +28,11 @@ class GitIndexTime : public ObjectWrap { GitIndexTime(git_index_time *raw); ~GitIndexTime(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + + static Handle Seconds(const Arguments& args); + static Handle Nanoseconds(const Arguments& args); - static NAN_METHOD(Seconds); - static NAN_METHOD(Nanoseconds); git_index_time *raw; }; diff --git a/include/object.h b/include/object.h index e4188ed83..6ab9d3537 100644 --- a/include/object.h +++ b/include/object.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitObject : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_object *GetValue(); @@ -30,12 +28,12 @@ class GitObject : public ObjectWrap { GitObject(git_object *raw); ~GitObject(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(Oid); - static NAN_METHOD(Type); - static NAN_METHOD(Peel); + static Handle Oid(const Arguments& args); + static Handle Type(const Arguments& args); + static Handle Peel(const Arguments& args); static void PeelWork(uv_work_t* req); static void PeelAfterWork(uv_work_t* req); diff --git a/include/odb.h b/include/odb.h index 5dbde3946..6ed9913d9 100644 --- a/include/odb.h +++ b/include/odb.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitOdb : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_odb *GetValue(); @@ -30,13 +28,13 @@ class GitOdb : public ObjectWrap { GitOdb(git_odb *raw); ~GitOdb(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(Create); - static NAN_METHOD(Open); - static NAN_METHOD(AddDiskAlternate); - static NAN_METHOD(Read); + static Handle Create(const Arguments& args); + static Handle Open(const Arguments& args); + static Handle AddDiskAlternate(const Arguments& args); + static Handle Read(const Arguments& args); static void ReadWork(uv_work_t* req); static void ReadAfterWork(uv_work_t* req); @@ -51,11 +49,11 @@ class GitOdb : public ObjectWrap { const git_oid * id; Persistent callback; }; - static NAN_METHOD(ReadPrefix); - static NAN_METHOD(ReadHeader); - static NAN_METHOD(Exists); - static NAN_METHOD(Refresh); - static NAN_METHOD(Write); + static Handle ReadPrefix(const Arguments& args); + static Handle ReadHeader(const Arguments& args); + static Handle Exists(const Arguments& args); + static Handle Refresh(const Arguments& args); + static Handle Write(const Arguments& args); static void WriteWork(uv_work_t* req); static void WriteAfterWork(uv_work_t* req); @@ -74,8 +72,8 @@ class GitOdb : public ObjectWrap { git_otype type; Persistent callback; }; - static NAN_METHOD(Hash); - static NAN_METHOD(Hashfile); + static Handle Hash(const Arguments& args); + static Handle Hashfile(const Arguments& args); git_odb *raw; }; diff --git a/include/odb_object.h b/include/odb_object.h index 54325a1fe..7938dfa49 100644 --- a/include/odb_object.h +++ b/include/odb_object.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitOdbObject : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_odb_object *GetValue(); @@ -30,12 +28,13 @@ class GitOdbObject : public ObjectWrap { GitOdbObject(git_odb_object *raw); ~GitOdbObject(); - static NAN_METHOD(New); - - static NAN_METHOD(Data); - static NAN_METHOD(Size); - static NAN_METHOD(Type); - static NAN_METHOD(Oid); + static Handle New(const Arguments& args); + + + static Handle Data(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Type(const Arguments& args); + static Handle Oid(const Arguments& args); git_odb_object *raw; }; diff --git a/include/oid.h b/include/oid.h index 789b560ea..2ce3a9e5c 100755 --- a/include/oid.h +++ b/include/oid.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitOid : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_oid *GetValue(); @@ -30,11 +28,11 @@ class GitOid : public ObjectWrap { GitOid(git_oid *raw); ~GitOid(); - static NAN_METHOD(New); - - static NAN_METHOD(FromString); - static NAN_METHOD(Sha); - + static Handle New(const Arguments& args); + + + static Handle FromString(const Arguments& args); + static Handle Sha(const Arguments& args); git_oid *raw; }; diff --git a/include/patch.h b/include/patch.h index e5f445b41..7a4d408ff 100644 --- a/include/patch.h +++ b/include/patch.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitPatch : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_diff_patch *GetValue(); @@ -30,15 +28,16 @@ class GitPatch : public ObjectWrap { GitPatch(git_diff_patch *raw); ~GitPatch(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + - static NAN_METHOD(Delta); - static NAN_METHOD(Size); - static NAN_METHOD(Stats); - static NAN_METHOD(Hunk); - static NAN_METHOD(Lines); - static NAN_METHOD(Line); - static NAN_METHOD(ToString); + static Handle Delta(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Stats(const Arguments& args); + static Handle Hunk(const Arguments& args); + static Handle Lines(const Arguments& args); + static Handle Line(const Arguments& args); + static Handle ToString(const Arguments& args); git_diff_patch *raw; }; diff --git a/include/refdb.h b/include/refdb.h index c5914e84f..51355028f 100644 --- a/include/refdb.h +++ b/include/refdb.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitRefDb : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_refdb *GetValue(); @@ -30,7 +28,8 @@ class GitRefDb : public ObjectWrap { GitRefDb(git_refdb *raw); ~GitRefDb(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + git_refdb *raw; }; diff --git a/include/reference.h b/include/reference.h index 7aef82a2c..ae7d18ad4 100644 --- a/include/reference.h +++ b/include/reference.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitReference : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_reference *GetValue(); @@ -30,10 +28,10 @@ class GitReference : public ObjectWrap { GitReference(git_reference *raw); ~GitReference(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(OidForName); + static Handle OidForName(const Arguments& args); static void OidForNameWork(uv_work_t* req); static void OidForNameAfterWork(uv_work_t* req); @@ -48,12 +46,11 @@ class GitReference : public ObjectWrap { const char * name; Persistent callback; }; - static NAN_METHOD(Target); - static NAN_METHOD(SymbolicTarget); - static NAN_METHOD(Type); - static NAN_METHOD(Name); - static NAN_METHOD(Resolve); - + static Handle Target(const Arguments& args); + static Handle SymbolicTarget(const Arguments& args); + static Handle Type(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Resolve(const Arguments& args); static void ResolveWork(uv_work_t* req); static void ResolveAfterWork(uv_work_t* req); @@ -66,11 +63,9 @@ class GitReference : public ObjectWrap { const git_reference * ref; Persistent callback; }; - - static NAN_METHOD(SetSymbolicTarget); - static NAN_METHOD(setTarget); - static NAN_METHOD(Rename); - + static Handle SetSymbolicTarget(const Arguments& args); + static Handle setTarget(const Arguments& args); + static Handle Rename(const Arguments& args); static void RenameWork(uv_work_t* req); static void RenameAfterWork(uv_work_t* req); @@ -87,8 +82,7 @@ class GitReference : public ObjectWrap { int force; Persistent callback; }; - static NAN_METHOD(Delete); - + static Handle Delete(const Arguments& args); static void DeleteWork(uv_work_t* req); static void DeleteAfterWork(uv_work_t* req); @@ -100,11 +94,10 @@ class GitReference : public ObjectWrap { git_reference * ref; Persistent callback; }; - static NAN_METHOD(IsBranch); - static NAN_METHOD(IsRemote); - static NAN_METHOD(Peel); - static NAN_METHOD(IsValidName); - + static Handle IsBranch(const Arguments& args); + static Handle IsRemote(const Arguments& args); + static Handle Peel(const Arguments& args); + static Handle IsValidName(const Arguments& args); git_reference *raw; }; diff --git a/include/remote.h b/include/remote.h index bf782f620..81fd1ac68 100644 --- a/include/remote.h +++ b/include/remote.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitRemote : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_remote *GetValue(); @@ -30,14 +28,15 @@ class GitRemote : public ObjectWrap { GitRemote(git_remote *raw); ~GitRemote(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + - static NAN_METHOD(Name); - static NAN_METHOD(Url); - static NAN_METHOD(PushUrl); - static NAN_METHOD(SetUrl); - static NAN_METHOD(SetPushUrl); - static NAN_METHOD(Connect); + static Handle Name(const Arguments& args); + static Handle Url(const Arguments& args); + static Handle PushUrl(const Arguments& args); + static Handle SetUrl(const Arguments& args); + static Handle SetPushUrl(const Arguments& args); + static Handle Connect(const Arguments& args); static void ConnectWork(uv_work_t* req); static void ConnectAfterWork(uv_work_t* req); @@ -51,7 +50,7 @@ class GitRemote : public ObjectWrap { git_direction direction; Persistent callback; }; - static NAN_METHOD(Download); + static Handle Download(const Arguments& args); static void DownloadWork(uv_work_t* req); static void DownloadAfterWork(uv_work_t* req); @@ -67,9 +66,9 @@ class GitRemote : public ObjectWrap { void * payload; Persistent callback; }; - static NAN_METHOD(Connected); - static NAN_METHOD(Stop); - static NAN_METHOD(Disconnect); + static Handle Connected(const Arguments& args); + static Handle Stop(const Arguments& args); + static Handle Disconnect(const Arguments& args); static void DisconnectWork(uv_work_t* req); static void DisconnectAfterWork(uv_work_t* req); @@ -81,13 +80,13 @@ class GitRemote : public ObjectWrap { git_remote * remote; Persistent callback; }; - static NAN_METHOD(UpdateTips); - static NAN_METHOD(ValidUrl); - static NAN_METHOD(SupportedUrl); - static NAN_METHOD(CheckCert); - static NAN_METHOD(UpdateFetchhead); - static NAN_METHOD(SetUpdateFetchhead); - static NAN_METHOD(IsValidName); + static Handle UpdateTips(const Arguments& args); + static Handle ValidUrl(const Arguments& args); + static Handle SupportedUrl(const Arguments& args); + static Handle CheckCert(const Arguments& args); + static Handle UpdateFetchhead(const Arguments& args); + static Handle SetUpdateFetchhead(const Arguments& args); + static Handle IsValidName(const Arguments& args); git_remote *raw; }; diff --git a/include/repo.h b/include/repo.h index a5ad14adf..8f10f3427 100755 --- a/include/repo.h +++ b/include/repo.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitRepo : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_repository *GetValue(); @@ -30,10 +28,10 @@ class GitRepo : public ObjectWrap { GitRepo(git_repository *raw); ~GitRepo(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(Open); + static Handle Open(const Arguments& args); static void OpenWork(uv_work_t* req); static void OpenAfterWork(uv_work_t* req); @@ -46,7 +44,7 @@ class GitRepo : public ObjectWrap { const char * path; Persistent callback; }; - static NAN_METHOD(Init); + static Handle Init(const Arguments& args); static void InitWork(uv_work_t* req); static void InitAfterWork(uv_work_t* req); @@ -61,10 +59,10 @@ class GitRepo : public ObjectWrap { unsigned is_bare; Persistent callback; }; - static NAN_METHOD(Path); - static NAN_METHOD(Workdir); - static NAN_METHOD(Odb); - static NAN_METHOD(openIndex); + static Handle Path(const Arguments& args); + static Handle Workdir(const Arguments& args); + static Handle Odb(const Arguments& args); + static Handle openIndex(const Arguments& args); static void openIndexWork(uv_work_t* req); static void openIndexAfterWork(uv_work_t* req); @@ -77,7 +75,7 @@ class GitRepo : public ObjectWrap { git_repository * repo; Persistent callback; }; - static NAN_METHOD(GetBlob); + static Handle GetBlob(const Arguments& args); static void GetBlobWork(uv_work_t* req); static void GetBlobAfterWork(uv_work_t* req); @@ -92,7 +90,7 @@ class GitRepo : public ObjectWrap { const git_oid * id; Persistent callback; }; - static NAN_METHOD(GetCommit); + static Handle GetCommit(const Arguments& args); static void GetCommitWork(uv_work_t* req); static void GetCommitAfterWork(uv_work_t* req); @@ -107,7 +105,7 @@ class GitRepo : public ObjectWrap { const git_oid * id; Persistent callback; }; - static NAN_METHOD(CreateCommit); + static Handle CreateCommit(const Arguments& args); static void CreateCommitWork(uv_work_t* req); static void CreateCommitAfterWork(uv_work_t* req); @@ -136,7 +134,7 @@ class GitRepo : public ObjectWrap { const git_commit ** parents; Persistent callback; }; - static NAN_METHOD(GetObject); + static Handle GetObject(const Arguments& args); static void GetObjectWork(uv_work_t* req); static void GetObjectAfterWork(uv_work_t* req); @@ -153,7 +151,7 @@ class GitRepo : public ObjectWrap { git_otype type; Persistent callback; }; - static NAN_METHOD(GetReference); + static Handle GetReference(const Arguments& args); static void GetReferenceWork(uv_work_t* req); static void GetReferenceAfterWork(uv_work_t* req); @@ -168,9 +166,9 @@ class GitRepo : public ObjectWrap { const char * name; Persistent callback; }; - static NAN_METHOD(CreateSymbolicReference); - static NAN_METHOD(CreateReference); - static NAN_METHOD(AddRemote); + static Handle CreateSymbolicReference(const Arguments& args); + static Handle CreateReference(const Arguments& args); + static Handle AddRemote(const Arguments& args); static void AddRemoteWork(uv_work_t* req); static void AddRemoteAfterWork(uv_work_t* req); @@ -187,10 +185,10 @@ class GitRepo : public ObjectWrap { const char * url; Persistent callback; }; - static NAN_METHOD(CreateRevWalk); - static NAN_METHOD(GetSubmodule); - static NAN_METHOD(AddSubmodule); - static NAN_METHOD(GetTag); + static Handle CreateRevWalk(const Arguments& args); + static Handle GetSubmodule(const Arguments& args); + static Handle AddSubmodule(const Arguments& args); + static Handle GetTag(const Arguments& args); static void GetTagWork(uv_work_t* req); static void GetTagAfterWork(uv_work_t* req); @@ -205,7 +203,7 @@ class GitRepo : public ObjectWrap { const git_oid * id; Persistent callback; }; - static NAN_METHOD(CreateTag); + static Handle CreateTag(const Arguments& args); static void CreateTagWork(uv_work_t* req); static void CreateTagAfterWork(uv_work_t* req); @@ -228,7 +226,7 @@ class GitRepo : public ObjectWrap { int force; Persistent callback; }; - static NAN_METHOD(CreateLightweightTag); + static Handle CreateLightweightTag(const Arguments& args); static void CreateLightweightTagWork(uv_work_t* req); static void CreateLightweightTagAfterWork(uv_work_t* req); @@ -247,7 +245,7 @@ class GitRepo : public ObjectWrap { int force; Persistent callback; }; - static NAN_METHOD(GetTree); + static Handle GetTree(const Arguments& args); static void GetTreeWork(uv_work_t* req); static void GetTreeAfterWork(uv_work_t* req); @@ -262,7 +260,7 @@ class GitRepo : public ObjectWrap { const git_oid * id; Persistent callback; }; - static NAN_METHOD(ReloadSubmodules); + static Handle ReloadSubmodules(const Arguments& args); static void ReloadSubmodulesWork(uv_work_t* req); static void ReloadSubmodulesAfterWork(uv_work_t* req); @@ -274,7 +272,7 @@ class GitRepo : public ObjectWrap { git_repository * repo; Persistent callback; }; - static NAN_METHOD(Delete); + static Handle Delete(const Arguments& args); static void DeleteWork(uv_work_t* req); static void DeleteAfterWork(uv_work_t* req); @@ -288,7 +286,7 @@ class GitRepo : public ObjectWrap { const char * tag_name; Persistent callback; }; - static NAN_METHOD(GetReferences); + static Handle GetReferences(const Arguments& args); static void GetReferencesWork(uv_work_t* req); static void GetReferencesAfterWork(uv_work_t* req); @@ -303,7 +301,7 @@ class GitRepo : public ObjectWrap { unsigned int list_flags; Persistent callback; }; - static NAN_METHOD(CreateBlobFromBuffer); + static Handle CreateBlobFromBuffer(const Arguments& args); static void CreateBlobFromBufferWork(uv_work_t* req); static void CreateBlobFromBufferAfterWork(uv_work_t* req); @@ -320,7 +318,7 @@ class GitRepo : public ObjectWrap { size_t len; Persistent callback; }; - static NAN_METHOD(CreateBlobFromFile); + static Handle CreateBlobFromFile(const Arguments& args); static void CreateBlobFromFileWork(uv_work_t* req); static void CreateBlobFromFileAfterWork(uv_work_t* req); @@ -335,7 +333,7 @@ class GitRepo : public ObjectWrap { const char * path; Persistent callback; }; - static NAN_METHOD(GetRemotes); + static Handle GetRemotes(const Arguments& args); static void GetRemotesWork(uv_work_t* req); static void GetRemotesAfterWork(uv_work_t* req); @@ -348,7 +346,7 @@ class GitRepo : public ObjectWrap { git_repository * repo; Persistent callback; }; - static NAN_METHOD(Clone); + static Handle Clone(const Arguments& args); static void CloneWork(uv_work_t* req); static void CloneAfterWork(uv_work_t* req); @@ -365,7 +363,7 @@ class GitRepo : public ObjectWrap { const git_clone_options * options; Persistent callback; }; - static NAN_METHOD(GetRemote); + static Handle GetRemote(const Arguments& args); git_repository *raw; }; diff --git a/include/revwalk.h b/include/revwalk.h index d6e6e6712..c2096cc61 100755 --- a/include/revwalk.h +++ b/include/revwalk.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitRevWalk : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_revwalk *GetValue(); @@ -30,11 +28,11 @@ class GitRevWalk : public ObjectWrap { GitRevWalk(git_revwalk *raw); ~GitRevWalk(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(Reset); - static NAN_METHOD(Push); + static Handle Reset(const Arguments& args); + static Handle Push(const Arguments& args); static void PushWork(uv_work_t* req); static void PushAfterWork(uv_work_t* req); @@ -48,7 +46,7 @@ class GitRevWalk : public ObjectWrap { const git_oid * id; Persistent callback; }; - static NAN_METHOD(PushGlob); + static Handle PushGlob(const Arguments& args); static void PushGlobWork(uv_work_t* req); static void PushGlobAfterWork(uv_work_t* req); @@ -62,7 +60,7 @@ class GitRevWalk : public ObjectWrap { const char * glob; Persistent callback; }; - static NAN_METHOD(PushHead); + static Handle PushHead(const Arguments& args); static void PushHeadWork(uv_work_t* req); static void PushHeadAfterWork(uv_work_t* req); @@ -74,7 +72,7 @@ class GitRevWalk : public ObjectWrap { git_revwalk * walk; Persistent callback; }; - static NAN_METHOD(Hide); + static Handle Hide(const Arguments& args); static void HideWork(uv_work_t* req); static void HideAfterWork(uv_work_t* req); @@ -88,7 +86,7 @@ class GitRevWalk : public ObjectWrap { const git_oid * commit_id; Persistent callback; }; - static NAN_METHOD(HideGlob); + static Handle HideGlob(const Arguments& args); static void HideGlobWork(uv_work_t* req); static void HideGlobAfterWork(uv_work_t* req); @@ -102,7 +100,7 @@ class GitRevWalk : public ObjectWrap { const char * glob; Persistent callback; }; - static NAN_METHOD(HideHead); + static Handle HideHead(const Arguments& args); static void HideHeadWork(uv_work_t* req); static void HideHeadAfterWork(uv_work_t* req); @@ -114,7 +112,7 @@ class GitRevWalk : public ObjectWrap { git_revwalk * walk; Persistent callback; }; - static NAN_METHOD(PushRef); + static Handle PushRef(const Arguments& args); static void PushRefWork(uv_work_t* req); static void PushRefAfterWork(uv_work_t* req); @@ -128,7 +126,7 @@ class GitRevWalk : public ObjectWrap { const char * refname; Persistent callback; }; - static NAN_METHOD(HideRef); + static Handle HideRef(const Arguments& args); static void HideRefWork(uv_work_t* req); static void HideRefAfterWork(uv_work_t* req); @@ -142,7 +140,7 @@ class GitRevWalk : public ObjectWrap { const char * refname; Persistent callback; }; - static NAN_METHOD(Next); + static Handle Next(const Arguments& args); static void NextWork(uv_work_t* req); static void NextAfterWork(uv_work_t* req); @@ -155,7 +153,7 @@ class GitRevWalk : public ObjectWrap { git_revwalk * walk; Persistent callback; }; - static NAN_METHOD(Sorting); + static Handle Sorting(const Arguments& args); git_revwalk *raw; }; diff --git a/include/signature.h b/include/signature.h index 65ca2b139..14d542c82 100755 --- a/include/signature.h +++ b/include/signature.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitSignature : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_signature *GetValue(); @@ -30,24 +28,14 @@ class GitSignature : public ObjectWrap { GitSignature(git_signature *raw); ~GitSignature(); - static NAN_METHOD(New); - - static NAN_METHOD(Name); - static NAN_METHOD(Email); - static NAN_METHOD(Time); - - static NAN_METHOD(Create); - static NAN_METHOD(Now); - - - // static Handle New(const Arguments& args); + static Handle New(const Arguments& args); - // static Handle Name(const Arguments& args); - // static Handle Email(const Arguments& args); - // static Handle Time(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Email(const Arguments& args); + static Handle Time(const Arguments& args); - // static Handle Create(const Arguments& args); - // static Handle Now(const Arguments& args); + static Handle Create(const Arguments& args); + static Handle Now(const Arguments& args); git_signature *raw; }; diff --git a/include/submodule.h b/include/submodule.h index 2895210b0..f80d8ee3d 100644 --- a/include/submodule.h +++ b/include/submodule.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitSubmodule : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_submodule *GetValue(); @@ -30,9 +28,10 @@ class GitSubmodule : public ObjectWrap { GitSubmodule(git_submodule *raw); ~GitSubmodule(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + - static NAN_METHOD(AddFinalize); + static Handle AddFinalize(const Arguments& args); static void AddFinalizeWork(uv_work_t* req); static void AddFinalizeAfterWork(uv_work_t* req); @@ -44,7 +43,7 @@ class GitSubmodule : public ObjectWrap { git_submodule * submodule; Persistent callback; }; - static NAN_METHOD(AddToIndex); + static Handle AddToIndex(const Arguments& args); static void AddToIndexWork(uv_work_t* req); static void AddToIndexAfterWork(uv_work_t* req); @@ -58,7 +57,7 @@ class GitSubmodule : public ObjectWrap { int write_index; Persistent callback; }; - static NAN_METHOD(Save); + static Handle Save(const Arguments& args); static void SaveWork(uv_work_t* req); static void SaveAfterWork(uv_work_t* req); @@ -70,13 +69,13 @@ class GitSubmodule : public ObjectWrap { git_submodule * submodule; Persistent callback; }; - static NAN_METHOD(Name); - static NAN_METHOD(Path); - static NAN_METHOD(Url); - static NAN_METHOD(SetUrl); - static NAN_METHOD(IndexId); - static NAN_METHOD(HeadId); - static NAN_METHOD(Init); + static Handle Name(const Arguments& args); + static Handle Path(const Arguments& args); + static Handle Url(const Arguments& args); + static Handle SetUrl(const Arguments& args); + static Handle IndexId(const Arguments& args); + static Handle HeadId(const Arguments& args); + static Handle Init(const Arguments& args); static void InitWork(uv_work_t* req); static void InitAfterWork(uv_work_t* req); @@ -90,7 +89,7 @@ class GitSubmodule : public ObjectWrap { int overwrite; Persistent callback; }; - static NAN_METHOD(Sync); + static Handle Sync(const Arguments& args); static void SyncWork(uv_work_t* req); static void SyncAfterWork(uv_work_t* req); @@ -102,7 +101,7 @@ class GitSubmodule : public ObjectWrap { git_submodule * submodule; Persistent callback; }; - static NAN_METHOD(Open); + static Handle Open(const Arguments& args); static void OpenWork(uv_work_t* req); static void OpenAfterWork(uv_work_t* req); @@ -115,7 +114,7 @@ class GitSubmodule : public ObjectWrap { git_submodule * submodule; Persistent callback; }; - static NAN_METHOD(Reload); + static Handle Reload(const Arguments& args); static void ReloadWork(uv_work_t* req); static void ReloadAfterWork(uv_work_t* req); @@ -127,7 +126,7 @@ class GitSubmodule : public ObjectWrap { git_submodule * submodule; Persistent callback; }; - static NAN_METHOD(Status); + static Handle Status(const Arguments& args); static void StatusWork(uv_work_t* req); static void StatusAfterWork(uv_work_t* req); diff --git a/include/tag.h b/include/tag.h index eb1703fb4..f89ded8b1 100755 --- a/include/tag.h +++ b/include/tag.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitTag : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_tag *GetValue(); @@ -30,10 +28,11 @@ class GitTag : public ObjectWrap { GitTag(git_tag *raw); ~GitTag(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + - static NAN_METHOD(Oid); - static NAN_METHOD(GetTarget); + static Handle Oid(const Arguments& args); + static Handle GetTarget(const Arguments& args); static void GetTargetWork(uv_work_t* req); static void GetTargetAfterWork(uv_work_t* req); @@ -46,12 +45,12 @@ class GitTag : public ObjectWrap { const git_tag * tag; Persistent callback; }; - static NAN_METHOD(TargetId); - static NAN_METHOD(TargetType); - static NAN_METHOD(Name); - static NAN_METHOD(Tagger); - static NAN_METHOD(Message); - static NAN_METHOD(Peel); + static Handle TargetId(const Arguments& args); + static Handle TargetType(const Arguments& args); + static Handle Name(const Arguments& args); + static Handle Tagger(const Arguments& args); + static Handle Message(const Arguments& args); + static Handle Peel(const Arguments& args); git_tag *raw; }; diff --git a/include/threads.h b/include/threads.h index 4145ef0f7..7a67b0295 100755 --- a/include/threads.h +++ b/include/threads.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,15 +17,17 @@ using namespace v8; class GitThreads : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); private: - static NAN_METHOD(New); - static NAN_METHOD(Init); - static NAN_METHOD(Shutdown); + static Handle New(const Arguments& args); + + + static Handle Init(const Arguments& args); + static Handle Shutdown(const Arguments& args); }; #endif diff --git a/include/time.h b/include/time.h index 9d0dce8fd..b742a88b0 100644 --- a/include/time.h +++ b/include/time.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitTime : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_time *GetValue(); @@ -30,15 +28,10 @@ class GitTime : public ObjectWrap { GitTime(git_time *raw); ~GitTime(); - static NAN_METHOD(New); - - static NAN_METHOD(Time); - static NAN_METHOD(Offset); - - // static Handle New(const Arguments& args); + static Handle New(const Arguments& args); - // static Handle Time(const Arguments& args); - // static Handle Offset(const Arguments& args); + static Handle Time(const Arguments& args); + static Handle Offset(const Arguments& args); git_time *raw; }; diff --git a/include/tree.h b/include/tree.h index b77169fa5..5462a82b1 100755 --- a/include/tree.h +++ b/include/tree.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitTree : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_tree *GetValue(); @@ -30,15 +28,15 @@ class GitTree : public ObjectWrap { GitTree(git_tree *raw); ~GitTree(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(Oid); - static NAN_METHOD(Size); - static NAN_METHOD(EntryByName); - static NAN_METHOD(EntryByIndex); - static NAN_METHOD(EntryByOid); - static NAN_METHOD(GetEntry); + static Handle Oid(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle EntryByName(const Arguments& args); + static Handle EntryByIndex(const Arguments& args); + static Handle EntryByOid(const Arguments& args); + static Handle GetEntry(const Arguments& args); static void GetEntryWork(uv_work_t* req); static void GetEntryAfterWork(uv_work_t* req); @@ -53,8 +51,8 @@ class GitTree : public ObjectWrap { const char * path; Persistent callback; }; - static NAN_METHOD(Builder); - static NAN_METHOD(DiffTree); + static Handle Builder(const Arguments& args); + static Handle DiffTree(const Arguments& args); static void DiffTreeWork(uv_work_t* req); static void DiffTreeAfterWork(uv_work_t* req); @@ -73,7 +71,7 @@ class GitTree : public ObjectWrap { const git_diff_options * opts; Persistent callback; }; - static NAN_METHOD(DiffIndex); + static Handle DiffIndex(const Arguments& args); static void DiffIndexWork(uv_work_t* req); static void DiffIndexAfterWork(uv_work_t* req); @@ -92,7 +90,7 @@ class GitTree : public ObjectWrap { const git_diff_options * opts; Persistent callback; }; - static NAN_METHOD(DiffWorkDir); + static Handle DiffWorkDir(const Arguments& args); static void DiffWorkDirWork(uv_work_t* req); static void DiffWorkDirAfterWork(uv_work_t* req); diff --git a/include/tree_builder.h b/include/tree_builder.h index f840deeee..93d08a69f 100644 --- a/include/tree_builder.h +++ b/include/tree_builder.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitTreeBuilder : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_treebuilder *GetValue(); @@ -30,15 +28,16 @@ class GitTreeBuilder : public ObjectWrap { GitTreeBuilder(git_treebuilder *raw); ~GitTreeBuilder(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); + - static NAN_METHOD(Create); - static NAN_METHOD(Clear); - static NAN_METHOD(Size); - static NAN_METHOD(Get); - static NAN_METHOD(Insert); - static NAN_METHOD(GitTreebuilderRemove); - static NAN_METHOD(Write); + static Handle Create(const Arguments& args); + static Handle Clear(const Arguments& args); + static Handle Size(const Arguments& args); + static Handle Get(const Arguments& args); + static Handle Insert(const Arguments& args); + static Handle GitTreebuilderRemove(const Arguments& args); + static Handle Write(const Arguments& args); static void WriteWork(uv_work_t* req); static void WriteAfterWork(uv_work_t* req); diff --git a/include/tree_entry.h b/include/tree_entry.h index 0db8e56bc..7c78ec1e9 100755 --- a/include/tree_entry.h +++ b/include/tree_entry.h @@ -9,8 +9,6 @@ #include #include -#include "nan.h" - #include "git2.h" using namespace node; @@ -19,7 +17,7 @@ using namespace v8; class GitTreeEntry : public ObjectWrap { public: - static Persistent constructor_template; + static Persistent constructor_template; static void Initialize (Handle target); git_tree_entry *GetValue(); @@ -30,14 +28,14 @@ class GitTreeEntry : public ObjectWrap { GitTreeEntry(git_tree_entry *raw); ~GitTreeEntry(); - static NAN_METHOD(New); + static Handle New(const Arguments& args); - static NAN_METHOD(Name); - static NAN_METHOD(Oid); - static NAN_METHOD(Type); - static NAN_METHOD(filemode); - static NAN_METHOD(GetObject); + static Handle Name(const Arguments& args); + static Handle Oid(const Arguments& args); + static Handle Type(const Arguments& args); + static Handle filemode(const Arguments& args); + static Handle GetObject(const Arguments& args); static void GetObjectWork(uv_work_t* req); static void GetObjectAfterWork(uv_work_t* req); diff --git a/install.js b/install.js index 1d4deaeb0..2e7df21e8 100644 --- a/install.js +++ b/install.js @@ -132,7 +132,14 @@ var dependencies = Q.allSettled([ .then(function() { console.info('[nodegit] Configuring libgit2.'); - return Q.nfcall(exec, 'cmake -DTHREADSAFE=1 -DBUILD_CLAR=0 ..', { + var flags = '-DTHREADSAFE=1 -DBUILD_CLAR=0'; + + // Windows flags. + if (process.platform.indexOf("win") > -1) { + flags = '-DSTDCALL=OFF -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo'; + } + + return Q.nfcall(exec, 'cmake .. ' + flags, { cwd: paths.build }); }).fail(function(err) { @@ -148,6 +155,7 @@ var dependencies = Q.allSettled([ }); }) +// Configure the Node native module. .then(function() { console.info('[nodegit] Configuring native node module.'); diff --git a/src/blob.cc b/src/blob.cc index 25f82bafd..bc6068608 100755 --- a/src/blob.cc +++ b/src/blob.cc @@ -27,42 +27,40 @@ GitBlob::~GitBlob() { } void GitBlob::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Blob")); + tpl->SetClassName(String::NewSymbol("Blob")); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "content", Content); NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); NODE_SET_PROTOTYPE_METHOD(tpl, "isBinary", IsBinary); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Blob"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Blob"), constructor_template); } -NAN_METHOD(GitBlob::New) { - NanScope(); +Handle GitBlob::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_blob is required.")); + return ThrowException(Exception::Error(String::New("git_blob is required."))); } - GitBlob* object = new GitBlob((git_blob *) External::Cast(*args[0])->Value()); + GitBlob* object = new GitBlob((git_blob *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitBlob::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitBlob::constructor_template->NewInstance(1, argv)); } git_blob *GitBlob::GetValue() { @@ -73,8 +71,9 @@ git_blob *GitBlob::GetValue() { /** * @return {Oid} result */ -NAN_METHOD(GitBlob::Oid) { - NanScope(); +Handle GitBlob::Oid(const Arguments& args) { + HandleScope scope; + const git_oid * result = git_blob_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -89,14 +88,15 @@ NAN_METHOD(GitBlob::Oid) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Wrapper} result */ -NAN_METHOD(GitBlob::Content) { - NanScope(); +Handle GitBlob::Content(const Arguments& args) { + HandleScope scope; + const void * result = git_blob_rawcontent( ObjectWrap::Unwrap(args.This())->GetValue() @@ -108,14 +108,15 @@ NAN_METHOD(GitBlob::Content) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitBlob::Size) { - NanScope(); +Handle GitBlob::Size(const Arguments& args) { + HandleScope scope; + git_off_t result = git_blob_rawsize( ObjectWrap::Unwrap(args.This())->GetValue() @@ -123,14 +124,15 @@ NAN_METHOD(GitBlob::Size) { Handle to; to = Number::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Boolean} result */ -NAN_METHOD(GitBlob::IsBinary) { - NanScope(); +Handle GitBlob::IsBinary(const Arguments& args) { + HandleScope scope; + int result = git_blob_is_binary( ObjectWrap::Unwrap(args.This())->GetValue() @@ -138,7 +140,7 @@ NAN_METHOD(GitBlob::IsBinary) { Handle to; to = Boolean::New(result); - NanReturnValue(to); + return scope.Close(to); } -Persistent GitBlob::constructor_template; +Persistent GitBlob::constructor_template; diff --git a/src/branch.cc b/src/branch.cc index 13f8e0fb8..043afe60a 100644 --- a/src/branch.cc +++ b/src/branch.cc @@ -23,12 +23,12 @@ Branch::~Branch() { } void Branch::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Branch")); + tpl->SetClassName(String::NewSymbol("Branch")); NODE_SET_METHOD(tpl, "create", Create); NODE_SET_METHOD(tpl, "delete", Delete); @@ -42,8 +42,9 @@ void Branch::Initialize(Handle target) { NODE_SET_METHOD(tpl, "isHead", IsHead); NODE_SET_METHOD(tpl, "remoteName", RemoteName); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Branch"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Branch"), constructor_template); } Handle Branch::New(const Arguments& args) { @@ -101,7 +102,7 @@ Handle Branch::Create(const Arguments& args) { const git_commit * from_target; from_target = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); int from_force; - from_force = (int) args[3]->ToInt32()->Value(); + from_force = (int) args[3]->ToInt32()->Value(); int result = git_branch_create( &out @@ -178,7 +179,7 @@ Handle Branch::Foreach(const Arguments& args) { git_repository * from_repo; from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); unsigned int from_list_flags; - from_list_flags = (unsigned int) args[1]->ToUint32()->Value(); + from_list_flags = (unsigned int) args[1]->ToUint32()->Value(); git_branch_foreach_cb from_branch_cb; from_branch_cb = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); void * from_payload; @@ -226,7 +227,7 @@ Handle Branch::Move(const Arguments& args) { String::Utf8Value new_branch_name(args[1]->ToString()); from_new_branch_name = strdup(*new_branch_name); int from_force; - from_force = (int) args[2]->ToInt32()->Value(); + from_force = (int) args[2]->ToInt32()->Value(); int result = git_branch_move( &out @@ -429,7 +430,7 @@ Handle Branch::UpstreamName(const Arguments& args) { String::Utf8Value tracking_branch_name_out(args[0]->ToString()); from_tracking_branch_name_out = strdup(*tracking_branch_name_out); size_t from_buffer_size; - from_buffer_size = (size_t) args[1]->ToUint32()->Value(); + from_buffer_size = (size_t) args[1]->ToUint32()->Value(); git_repository * from_repo; from_repo = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); const char * from_canonical_branch_name; @@ -506,7 +507,7 @@ Handle Branch::RemoteName(const Arguments& args) { String::Utf8Value remote_name_out(args[0]->ToString()); from_remote_name_out = strdup(*remote_name_out); size_t from_buffer_size; - from_buffer_size = (size_t) args[1]->ToUint32()->Value(); + from_buffer_size = (size_t) args[1]->ToUint32()->Value(); git_repository * from_repo; from_repo = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); const char * from_canonical_branch_name; diff --git a/src/clone_options.cc b/src/clone_options.cc index b01c980a4..3f4b058c5 100644 --- a/src/clone_options.cc +++ b/src/clone_options.cc @@ -23,38 +23,36 @@ GitCloneOptions::~GitCloneOptions() { } void GitCloneOptions::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("CloneOptions")); + tpl->SetClassName(String::NewSymbol("CloneOptions")); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("CloneOptions"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("CloneOptions"), constructor_template); } -NAN_METHOD(GitCloneOptions::New) { - NanScope(); +Handle GitCloneOptions::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_clone_options is required.")); + return ThrowException(Exception::Error(String::New("git_clone_options is required."))); } - GitCloneOptions* object = new GitCloneOptions((git_clone_options *) External::Cast(*args[0])->Value()); + GitCloneOptions* object = new GitCloneOptions((git_clone_options *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitCloneOptions::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitCloneOptions::constructor_template->NewInstance(1, argv)); } git_clone_options *GitCloneOptions::GetValue() { @@ -62,4 +60,4 @@ git_clone_options *GitCloneOptions::GetValue() { } -Persistent GitCloneOptions::constructor_template; +Persistent GitCloneOptions::constructor_template; diff --git a/src/commit.cc b/src/commit.cc index 4f66a43fa..29a1a7877 100755 --- a/src/commit.cc +++ b/src/commit.cc @@ -27,12 +27,12 @@ GitCommit::~GitCommit() { } void GitCommit::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Commit")); + tpl->SetClassName(String::NewSymbol("Commit")); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "messageEncoding", MessageEncoding); @@ -46,30 +46,28 @@ void GitCommit::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "parentId", ParentId); NODE_SET_PROTOTYPE_METHOD(tpl, "nthGenAncestor", NthGenAncestor); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Commit"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Commit"), constructor_template); } -NAN_METHOD(GitCommit::New) { - NanScope(); +Handle GitCommit::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_commit is required.")); + return ThrowException(Exception::Error(String::New("git_commit is required."))); } - GitCommit* object = new GitCommit((git_commit *) External::Cast(*args[0])->Value()); + GitCommit* object = new GitCommit((git_commit *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitCommit::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitCommit::constructor_template->NewInstance(1, argv)); } git_commit *GitCommit::GetValue() { @@ -80,8 +78,8 @@ git_commit *GitCommit::GetValue() { /** * @return {Oid} result */ -NAN_METHOD(GitCommit::Oid) { - NanScope(); +Handle GitCommit::Oid(const Arguments& args) { + HandleScope scope; const git_oid * result = git_commit_id( @@ -97,14 +95,14 @@ NAN_METHOD(GitCommit::Oid) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitCommit::MessageEncoding) { - NanScope(); +Handle GitCommit::MessageEncoding(const Arguments& args) { + HandleScope scope; const char * result = git_commit_message_encoding( @@ -113,14 +111,14 @@ NAN_METHOD(GitCommit::MessageEncoding) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitCommit::Message) { - NanScope(); +Handle GitCommit::Message(const Arguments& args) { + HandleScope scope; const char * result = git_commit_message( @@ -129,14 +127,14 @@ NAN_METHOD(GitCommit::Message) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitCommit::Time) { - NanScope(); +Handle GitCommit::Time(const Arguments& args) { + HandleScope scope; git_time_t result = git_commit_time( @@ -145,14 +143,15 @@ NAN_METHOD(GitCommit::Time) { Handle to; to = Number::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitCommit::Offset) { - NanScope(); +Handle GitCommit::Offset(const Arguments& args) { + HandleScope scope; + int result = git_commit_time_offset( ObjectWrap::Unwrap(args.This())->GetValue() @@ -160,14 +159,14 @@ NAN_METHOD(GitCommit::Offset) { Handle to; to = Integer::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Signature} result */ -NAN_METHOD(GitCommit::Committer) { - NanScope(); +Handle GitCommit::Committer(const Arguments& args) { + HandleScope scope; const git_signature * result = git_commit_committer( @@ -183,14 +182,14 @@ NAN_METHOD(GitCommit::Committer) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Signature} result */ -NAN_METHOD(GitCommit::Author) { - NanScope(); +Handle GitCommit::Author(const Arguments& args) { + HandleScope scope; const git_signature * result = git_commit_author( @@ -206,14 +205,14 @@ NAN_METHOD(GitCommit::Author) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Oid} result */ -NAN_METHOD(GitCommit::TreeId) { - NanScope(); +Handle GitCommit::TreeId(const Arguments& args) { + HandleScope scope; const git_oid * result = git_commit_tree_id( @@ -229,14 +228,14 @@ NAN_METHOD(GitCommit::TreeId) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitCommit::ParentCount) { - NanScope(); +Handle GitCommit::ParentCount(const Arguments& args) { + HandleScope scope; unsigned int result = git_commit_parentcount( @@ -245,21 +244,21 @@ NAN_METHOD(GitCommit::ParentCount) { Handle to; to = Uint32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @param {Number} n * @return {Oid} result */ -NAN_METHOD(GitCommit::ParentId) { - NanScope(); +Handle GitCommit::ParentId(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError(String::New("Number n is required.")); + return ThrowException(Exception::Error(String::New("Number n is required."))); } unsigned int from_n; - from_n = (unsigned int) args[0]->ToUint32()->Value(); + from_n = (unsigned int) args[0]->ToUint32()->Value(); const git_oid * result = git_commit_parent_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -275,22 +274,22 @@ NAN_METHOD(GitCommit::ParentId) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {Number} n * @return {Commit} ancestor */ -NAN_METHOD(GitCommit::NthGenAncestor) { - NanScope(); +Handle GitCommit::NthGenAncestor(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError(String::New("Number n is required.")); + return ThrowException(Exception::Error(String::New("Number n is required."))); } git_commit * ancestor = 0; unsigned int from_n; - from_n = (unsigned int) args[0]->ToUint32()->Value(); + from_n = (unsigned int) args[0]->ToUint32()->Value(); int result = git_commit_nth_gen_ancestor( &ancestor @@ -299,19 +298,19 @@ NAN_METHOD(GitCommit::NthGenAncestor) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } Handle to; if (ancestor != NULL) { - to = GitCommit::New(ancestor); + to = GitCommit::New((void *)ancestor); } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -Persistent GitCommit::constructor_template; +Persistent GitCommit::constructor_template; diff --git a/src/delta.cc b/src/delta.cc index 1cb4e9d68..7b45d35f9 100644 --- a/src/delta.cc +++ b/src/delta.cc @@ -24,12 +24,13 @@ GitDelta::~GitDelta() { } void GitDelta::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Delta")); + tpl->SetClassName(String::NewSymbol("Delta")); + NODE_SET_PROTOTYPE_METHOD(tpl, "oldFile", OldFile); NODE_SET_PROTOTYPE_METHOD(tpl, "newFile", NewFile); @@ -37,38 +38,36 @@ void GitDelta::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "similarity", Similarity); NODE_SET_PROTOTYPE_METHOD(tpl, "flags", Flags); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Delta"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Delta"), constructor_template); } -NAN_METHOD(GitDelta::New) { - NanScope(); +Handle GitDelta::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_diff_delta is required.")); + return ThrowException(Exception::Error(String::New("git_diff_delta is required."))); } - GitDelta* object = new GitDelta((git_diff_delta *) External::Cast(*args[0])->Value()); + GitDelta* object = new GitDelta((git_diff_delta *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitDelta::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitDelta::constructor_template->NewInstance(1, argv)); } git_diff_delta *GitDelta::GetValue() { return this->raw; } -NAN_METHOD(GitDelta::OldFile) { - NanScope(); + +Handle GitDelta::OldFile(const Arguments& args) { + HandleScope scope; Handle to; git_diff_file *old_file = @@ -82,11 +81,11 @@ NAN_METHOD(GitDelta::OldFile) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDelta::NewFile) { - NanScope(); +Handle GitDelta::NewFile(const Arguments& args) { + HandleScope scope; Handle to; git_diff_file *new_file = @@ -100,40 +99,40 @@ NAN_METHOD(GitDelta::NewFile) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDelta::Status) { - NanScope(); +Handle GitDelta::Status(const Arguments& args) { + HandleScope scope; Handle to; git_delta_t status = ObjectWrap::Unwrap(args.This())->GetValue()->status; to = Integer::New(status); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDelta::Similarity) { - NanScope(); +Handle GitDelta::Similarity(const Arguments& args) { + HandleScope scope; Handle to; uint32_t similarity = ObjectWrap::Unwrap(args.This())->GetValue()->similarity; to = Integer::New(similarity); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDelta::Flags) { - NanScope(); +Handle GitDelta::Flags(const Arguments& args) { + HandleScope scope; Handle to; uint32_t flags = ObjectWrap::Unwrap(args.This())->GetValue()->flags; to = Integer::New(flags); - NanReturnValue(to); + return scope.Close(to); } -Persistent GitDelta::constructor_template; +Persistent GitDelta::constructor_template; diff --git a/src/diff_file.cc b/src/diff_file.cc index 6877b632d..c96d4c8be 100644 --- a/src/diff_file.cc +++ b/src/diff_file.cc @@ -24,12 +24,13 @@ GitDiffFile::~GitDiffFile() { } void GitDiffFile::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("DiffFile")); + tpl->SetClassName(String::NewSymbol("DiffFile")); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); @@ -37,38 +38,36 @@ void GitDiffFile::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "flags", Flags); NODE_SET_PROTOTYPE_METHOD(tpl, "mode", Mode); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("DiffFile"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffFile"), constructor_template); } -NAN_METHOD(GitDiffFile::New) { - NanScope(); +Handle GitDiffFile::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_diff_file is required.")); + return ThrowException(Exception::Error(String::New("git_diff_file is required."))); } - GitDiffFile* object = new GitDiffFile((git_diff_file *) External::Cast(*args[0])->Value()); + GitDiffFile* object = new GitDiffFile((git_diff_file *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitDiffFile::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitDiffFile::constructor_template->NewInstance(1, argv)); } git_diff_file *GitDiffFile::GetValue() { return this->raw; } -NAN_METHOD(GitDiffFile::Oid) { - NanScope(); + +Handle GitDiffFile::Oid(const Arguments& args) { + HandleScope scope; Handle to; git_oid *oid = @@ -82,51 +81,51 @@ NAN_METHOD(GitDiffFile::Oid) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDiffFile::Path) { - NanScope(); +Handle GitDiffFile::Path(const Arguments& args) { + HandleScope scope; Handle to; const char * path = ObjectWrap::Unwrap(args.This())->GetValue()->path; to = String::New(path); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDiffFile::Size) { - NanScope(); +Handle GitDiffFile::Size(const Arguments& args) { + HandleScope scope; Handle to; git_off_t size = ObjectWrap::Unwrap(args.This())->GetValue()->size; to = Integer::New(size); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDiffFile::Flags) { - NanScope(); +Handle GitDiffFile::Flags(const Arguments& args) { + HandleScope scope; Handle to; uint32_t flags = ObjectWrap::Unwrap(args.This())->GetValue()->flags; to = Integer::New(flags); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDiffFile::Mode) { - NanScope(); +Handle GitDiffFile::Mode(const Arguments& args) { + HandleScope scope; Handle to; uint16_t mode = ObjectWrap::Unwrap(args.This())->GetValue()->mode; to = Integer::New(mode); - NanReturnValue(to); + return scope.Close(to); } -Persistent GitDiffFile::constructor_template; +Persistent GitDiffFile::constructor_template; diff --git a/src/diff_find_options.cc b/src/diff_find_options.cc index c08151a6e..f6fd85756 100644 --- a/src/diff_find_options.cc +++ b/src/diff_find_options.cc @@ -23,39 +23,36 @@ GitDiffFindOptions::~GitDiffFindOptions() { } void GitDiffFindOptions::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("DiffFindOptions")); + tpl->SetClassName(String::NewSymbol("DiffFindOptions")); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("DiffFindOptions"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffFindOptions"), constructor_template); } -NAN_METHOD(GitDiffFindOptions::New) { - NanScope(); +Handle GitDiffFindOptions::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_diff_find_options is required.")); + return ThrowException(Exception::Error(String::New("git_diff_find_options is required."))); } - GitDiffFindOptions* object = new GitDiffFindOptions((git_diff_find_options *) External::Cast(*args[0])->Value()); + GitDiffFindOptions* object = new GitDiffFindOptions((git_diff_find_options *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } - Handle GitDiffFindOptions::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitDiffFindOptions::constructor_template->NewInstance(1, argv)); } git_diff_find_options *GitDiffFindOptions::GetValue() { @@ -63,4 +60,4 @@ git_diff_find_options *GitDiffFindOptions::GetValue() { } -Persistent GitDiffFindOptions::constructor_template; +Persistent GitDiffFindOptions::constructor_template; diff --git a/src/diff_list.cc b/src/diff_list.cc index d6239d813..fbd7e1398 100755 --- a/src/diff_list.cc +++ b/src/diff_list.cc @@ -30,12 +30,12 @@ GitDiffList::~GitDiffList() { } void GitDiffList::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("DiffList")); + tpl->SetClassName(String::NewSymbol("DiffList")); NODE_SET_PROTOTYPE_METHOD(tpl, "merge", Merge); NODE_SET_PROTOTYPE_METHOD(tpl, "findSimilar", FindSimilar); @@ -44,30 +44,27 @@ void GitDiffList::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "patch", Patch); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("DiffList"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffList"), constructor_template); } -NAN_METHOD(GitDiffList::New) { - NanScope(); +Handle GitDiffList::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_diff_list is required.")); + return ThrowException(Exception::Error(String::New("git_diff_list is required."))); } - GitDiffList* object = new GitDiffList((git_diff_list *) External::Cast(*args[0])->Value()); + GitDiffList* object = new GitDiffList((git_diff_list *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitDiffList::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitDiffList::constructor_template->NewInstance(1, argv)); } git_diff_list *GitDiffList::GetValue() { @@ -78,10 +75,10 @@ git_diff_list *GitDiffList::GetValue() { /** * @param {DiffList} from */ -NAN_METHOD(GitDiffList::Merge) { - NanScope(); +Handle GitDiffList::Merge(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("DiffList from is required.")); + return ThrowException(Exception::Error(String::New("DiffList from is required."))); } const git_diff_list * from_from; @@ -93,22 +90,22 @@ NAN_METHOD(GitDiffList::Merge) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @param {DiffFindOptions} options */ -NAN_METHOD(GitDiffList::FindSimilar) { - NanScope(); +Handle GitDiffList::FindSimilar(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("DiffFindOptions options is required.")); + return ThrowException(Exception::Error(String::New("DiffFindOptions options is required."))); } git_diff_find_options * from_options; @@ -120,20 +117,20 @@ NAN_METHOD(GitDiffList::FindSimilar) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @return {Number} result */ -NAN_METHOD(GitDiffList::Size) { - NanScope(); +Handle GitDiffList::Size(const Arguments& args) { + HandleScope scope; size_t result = git_diff_num_deltas( @@ -142,7 +139,7 @@ NAN_METHOD(GitDiffList::Size) { Handle to; to = Uint32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** @@ -150,19 +147,19 @@ NAN_METHOD(GitDiffList::Size) { * @param {Number} type * @return {Number} result */ -NAN_METHOD(GitDiffList::NumDeltasOfType) { - NanScope(); +Handle GitDiffList::NumDeltasOfType(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("DiffList diff is required.")); + return ThrowException(Exception::Error(String::New("DiffList diff is required."))); } if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError(String::New("Number type is required.")); + return ThrowException(Exception::Error(String::New("Number type is required."))); } git_diff_list * from_diff; from_diff = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); git_delta_t from_type; - from_type = (git_delta_t) args[1]->ToInt32()->Value(); + from_type = (git_delta_t) args[1]->ToInt32()->Value(); size_t result = git_diff_num_deltas_of_type( from_diff @@ -171,7 +168,7 @@ NAN_METHOD(GitDiffList::NumDeltasOfType) { Handle to; to = Uint32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** @@ -179,16 +176,16 @@ NAN_METHOD(GitDiffList::NumDeltasOfType) { * @return {Patch} patch_out * @return {Delta} delta_out */ -NAN_METHOD(GitDiffList::Patch) { - NanScope(); +Handle GitDiffList::Patch(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError(String::New("Number idx is required.")); + return ThrowException(Exception::Error(String::New("Number idx is required."))); } git_diff_patch * patch_out = 0; const git_diff_delta * delta_out = 0; size_t from_idx; - from_idx = (size_t) args[0]->ToUint32()->Value(); + from_idx = (size_t) args[0]->ToUint32()->Value(); int result = git_diff_get_patch( &patch_out @@ -198,9 +195,9 @@ NAN_METHOD(GitDiffList::Patch) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -223,7 +220,7 @@ NAN_METHOD(GitDiffList::Patch) { } toReturn->Set(String::NewSymbol("delta"), to); - NanReturnValue(toReturn); + return scope.Close(toReturn); } -Persistent GitDiffList::constructor_template; +Persistent GitDiffList::constructor_template; diff --git a/src/diff_options.cc b/src/diff_options.cc index 24407f98f..dad3fd108 100644 --- a/src/diff_options.cc +++ b/src/diff_options.cc @@ -23,38 +23,36 @@ GitDiffOptions::~GitDiffOptions() { } void GitDiffOptions::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("DiffOptions")); + tpl->SetClassName(String::NewSymbol("DiffOptions")); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("DiffOptions"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffOptions"), constructor_template); } -NAN_METHOD(GitDiffOptions::New) { - NanScope(); +Handle GitDiffOptions::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_diff_options is required.")); + return ThrowException(Exception::Error(String::New("git_diff_options is required."))); } - GitDiffOptions* object = new GitDiffOptions((git_diff_options *) External::Cast(*args[0])->Value()); + GitDiffOptions* object = new GitDiffOptions((git_diff_options *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitDiffOptions::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitDiffOptions::constructor_template->NewInstance(1, argv)); } git_diff_options *GitDiffOptions::GetValue() { @@ -62,4 +60,4 @@ git_diff_options *GitDiffOptions::GetValue() { } -Persistent GitDiffOptions::constructor_template; +Persistent GitDiffOptions::constructor_template; diff --git a/src/diff_range.cc b/src/diff_range.cc index e91cefef1..cacbd49b5 100644 --- a/src/diff_range.cc +++ b/src/diff_range.cc @@ -23,90 +23,89 @@ GitDiffRange::~GitDiffRange() { } void GitDiffRange::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("DiffRange")); + tpl->SetClassName(String::NewSymbol("DiffRange")); + NODE_SET_PROTOTYPE_METHOD(tpl, "oldStart", OldStart); NODE_SET_PROTOTYPE_METHOD(tpl, "oldLines", OldLines); NODE_SET_PROTOTYPE_METHOD(tpl, "newStart", NewStart); NODE_SET_PROTOTYPE_METHOD(tpl, "newLines", NewLines); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("DiffRange"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("DiffRange"), constructor_template); } -NAN_METHOD(GitDiffRange::New) { - NanScope(); +Handle GitDiffRange::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_diff_range is required.")); + return ThrowException(Exception::Error(String::New("git_diff_range is required."))); } - GitDiffRange* object = new GitDiffRange((git_diff_range *) External::Cast(*args[0])->Value()); + GitDiffRange* object = new GitDiffRange((git_diff_range *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitDiffRange::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitDiffRange::constructor_template->NewInstance(1, argv)); } git_diff_range *GitDiffRange::GetValue() { return this->raw; } -NAN_METHOD(GitDiffRange::OldStart) { - NanScope(); + +Handle GitDiffRange::OldStart(const Arguments& args) { + HandleScope scope; Handle to; int old_start = ObjectWrap::Unwrap(args.This())->GetValue()->old_start; to = Integer::New(old_start); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDiffRange::OldLines) { - NanScope(); +Handle GitDiffRange::OldLines(const Arguments& args) { + HandleScope scope; Handle to; int old_lines = ObjectWrap::Unwrap(args.This())->GetValue()->old_lines; to = Integer::New(old_lines); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDiffRange::NewStart) { - NanScope(); +Handle GitDiffRange::NewStart(const Arguments& args) { + HandleScope scope; Handle to; int new_start = ObjectWrap::Unwrap(args.This())->GetValue()->new_start; to = Integer::New(new_start); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitDiffRange::NewLines) { - NanScope(); +Handle GitDiffRange::NewLines(const Arguments& args) { + HandleScope scope; Handle to; int new_lines = ObjectWrap::Unwrap(args.This())->GetValue()->new_lines; to = Integer::New(new_lines); - NanReturnValue(to); + return scope.Close(to); } -Persistent GitDiffRange::constructor_template; +Persistent GitDiffRange::constructor_template; diff --git a/src/index.cc b/src/index.cc index 205afbc82..adeaf91be 100644 --- a/src/index.cc +++ b/src/index.cc @@ -29,12 +29,12 @@ GitIndex::~GitIndex() { } void GitIndex::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Index")); + tpl->SetClassName(String::NewSymbol("Index")); NODE_SET_METHOD(tpl, "open", Open); NODE_SET_PROTOTYPE_METHOD(tpl, "read", Read); @@ -54,30 +54,28 @@ void GitIndex::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "hasConflicts", HasConflicts); NODE_SET_METHOD(tpl, "indexToWorkdir", IndexToWorkdir); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Index"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Index"), constructor_template); } -NAN_METHOD(GitIndex::New) { - NanScope(); +Handle GitIndex::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_index is required.")); + return ThrowException(Exception::Error(String::New("git_index is required."))); } - GitIndex* object = new GitIndex((git_index *) External::Cast(*args[0])->Value()); + GitIndex* object = new GitIndex((git_index *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitIndex::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitIndex::constructor_template->NewInstance(1, argv)); } git_index *GitIndex::GetValue() { @@ -91,30 +89,30 @@ git_index *GitIndex::GetValue() { * @param {String} index_path * @param {Index} callback */ -NAN_METHOD(GitIndex::Open) { - NanScope(); +Handle GitIndex::Open(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String index_path is required.")); + return ThrowException(Exception::Error(String::New("String index_path is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } OpenBaton* baton = new OpenBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->index_pathReference, args[0]); - const char * from_index_path; - String::Utf8Value index_path(args[0]->ToString()); - from_index_path = strdup(*index_path); - baton->index_path = from_index_path; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->index_pathReference = Persistent::New(args[0]); + const char * from_index_path; + String::Utf8Value index_path(args[0]->ToString()); + from_index_path = strdup(*index_path); + baton->index_path = from_index_path; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitIndex::OpenWork(uv_work_t *req) { @@ -130,7 +128,7 @@ void GitIndex::OpenWork(uv_work_t *req) { } void GitIndex::OpenAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; OpenBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -143,21 +141,21 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -174,24 +172,24 @@ void GitIndex::OpenAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitIndex::Read) { - NanScope(); +Handle GitIndex::Read(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } ReadBaton* baton = new ReadBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->indexReference, args.This()); + baton->indexReference = Persistent::New(args.This()); baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, ReadWork, (uv_after_work_cb)ReadAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitIndex::ReadWork(uv_work_t *req) { @@ -206,28 +204,28 @@ void GitIndex::ReadWork(uv_work_t *req) { } void GitIndex::ReadAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; ReadBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -243,24 +241,24 @@ void GitIndex::ReadAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitIndex::Write) { - NanScope(); +Handle GitIndex::Write(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } WriteBaton* baton = new WriteBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->indexReference, args.This()); + baton->indexReference = Persistent::New(args.This()); baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, WriteWork, (uv_after_work_cb)WriteAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitIndex::WriteWork(uv_work_t *req) { @@ -275,28 +273,28 @@ void GitIndex::WriteWork(uv_work_t *req) { } void GitIndex::WriteAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; WriteBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -313,31 +311,31 @@ void GitIndex::WriteAfterWork(uv_work_t *req) { /** * @param {Tree} tree */ -NAN_METHOD(GitIndex::ReadTree) { - NanScope(); +Handle GitIndex::ReadTree(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Tree tree is required.")); + return ThrowException(Exception::Error(String::New("Tree tree is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } ReadTreeBaton* baton = new ReadTreeBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->indexReference, args.This()); + baton->indexReference = Persistent::New(args.This()); baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->treeReference, args[0]); - const git_tree * from_tree; - from_tree = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->tree = from_tree; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->treeReference = Persistent::New(args[0]); + const git_tree * from_tree; + from_tree = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->tree = from_tree; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, ReadTreeWork, (uv_after_work_cb)ReadTreeAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitIndex::ReadTreeWork(uv_work_t *req) { @@ -353,30 +351,30 @@ void GitIndex::ReadTreeWork(uv_work_t *req) { } void GitIndex::ReadTreeAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; ReadTreeBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -392,11 +390,11 @@ void GitIndex::ReadTreeAfterWork(uv_work_t *req) { /** * @param {Oid} callback */ -NAN_METHOD(GitIndex::WriteTree) { - NanScope(); +Handle GitIndex::WriteTree(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } WriteTreeBaton* baton = new WriteTreeBaton; @@ -404,13 +402,13 @@ NAN_METHOD(GitIndex::WriteTree) { baton->error = NULL; baton->request.data = baton; baton->out = (git_oid *)malloc(sizeof(git_oid )); - NanAssignPersistent(Value, baton->indexReference, args.This()); + baton->indexReference = Persistent::New(args.This()); baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, WriteTreeWork, (uv_after_work_cb)WriteTreeAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitIndex::WriteTreeWork(uv_work_t *req) { @@ -426,7 +424,7 @@ void GitIndex::WriteTreeWork(uv_work_t *req) { } void GitIndex::WriteTreeAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; WriteTreeBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -439,24 +437,24 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - free(baton->out); - } + free(baton->out); + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -469,8 +467,8 @@ void GitIndex::WriteTreeAfterWork(uv_work_t *req) { /** * @return {Number} result */ -NAN_METHOD(GitIndex::Size) { - NanScope(); +Handle GitIndex::Size(const Arguments& args) { + HandleScope scope; size_t result = git_index_entrycount( @@ -479,34 +477,34 @@ NAN_METHOD(GitIndex::Size) { Handle to; to = Uint32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** */ -NAN_METHOD(GitIndex::Clear) { - NanScope(); +Handle GitIndex::Clear(const Arguments& args) { + HandleScope scope; git_index_clear( ObjectWrap::Unwrap(args.This())->GetValue() ); - NanReturnUndefined(); + return Undefined(); } /** * @param {Number} n * @return {IndexEntry} result */ -NAN_METHOD(GitIndex::Entry) { - NanScope(); +Handle GitIndex::Entry(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError(String::New("Number n is required.")); + return ThrowException(Exception::Error(String::New("Number n is required."))); } size_t from_n; - from_n = (size_t) args[0]->ToUint32()->Value(); + from_n = (size_t) args[0]->ToUint32()->Value(); const git_index_entry * result = git_index_get_byindex( ObjectWrap::Unwrap(args.This())->GetValue() @@ -522,27 +520,27 @@ NAN_METHOD(GitIndex::Entry) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} path * @param {Number} stage */ -NAN_METHOD(GitIndex::Remove) { - NanScope(); +Handle GitIndex::Remove(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError(String::New("Number stage is required.")); + return ThrowException(Exception::Error(String::New("Number stage is required."))); } const char * from_path; String::Utf8Value path(args[0]->ToString()); from_path = strdup(*path); int from_stage; - from_stage = (int) args[1]->ToInt32()->Value(); + from_stage = (int) args[1]->ToInt32()->Value(); int result = git_index_remove( ObjectWrap::Unwrap(args.This())->GetValue() @@ -552,33 +550,33 @@ NAN_METHOD(GitIndex::Remove) { free((void *)from_path); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @param {String} dir * @param {Number} stage */ -NAN_METHOD(GitIndex::RemoveDirectory) { - NanScope(); +Handle GitIndex::RemoveDirectory(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String dir is required.")); + return ThrowException(Exception::Error(String::New("String dir is required."))); } if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError(String::New("Number stage is required.")); + return ThrowException(Exception::Error(String::New("Number stage is required."))); } const char * from_dir; String::Utf8Value dir(args[0]->ToString()); from_dir = strdup(*dir); int from_stage; - from_stage = (int) args[1]->ToInt32()->Value(); + from_stage = (int) args[1]->ToInt32()->Value(); int result = git_index_remove_directory( ObjectWrap::Unwrap(args.This())->GetValue() @@ -588,13 +586,13 @@ NAN_METHOD(GitIndex::RemoveDirectory) { free((void *)from_dir); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } #include "../include/functions/copy.h" @@ -602,32 +600,32 @@ NAN_METHOD(GitIndex::RemoveDirectory) { /** * @param {String} path */ -NAN_METHOD(GitIndex::AddBypath) { - NanScope(); +Handle GitIndex::AddBypath(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } AddBypathBaton* baton = new AddBypathBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->indexReference, args.This()); + baton->indexReference = Persistent::New(args.This()); baton->index = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->pathReference, args[0]); - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - baton->path = from_path; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->pathReference = Persistent::New(args[0]); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + baton->path = from_path; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, AddBypathWork, (uv_after_work_cb)AddBypathAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitIndex::AddBypathWork(uv_work_t *req) { @@ -643,28 +641,28 @@ void GitIndex::AddBypathWork(uv_work_t *req) { } void GitIndex::AddBypathAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; AddBypathBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -681,10 +679,10 @@ void GitIndex::AddBypathAfterWork(uv_work_t *req) { /** * @param {String} path */ -NAN_METHOD(GitIndex::RemoveBypath) { - NanScope(); +Handle GitIndex::RemoveBypath(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); + return ThrowException(Exception::Error(String::New("String path is required."))); } const char * from_path; @@ -698,23 +696,23 @@ NAN_METHOD(GitIndex::RemoveBypath) { free((void *)from_path); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @param {String} path * @return {Number} at_pos */ -NAN_METHOD(GitIndex::Find) { - NanScope(); +Handle GitIndex::Find(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); + return ThrowException(Exception::Error(String::New("String path is required."))); } size_t at_pos = 0; @@ -731,16 +729,16 @@ NAN_METHOD(GitIndex::Find) { Handle to; to = Uint32::New(at_pos); - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} path */ -NAN_METHOD(GitIndex::ConflictRemove) { - NanScope(); +Handle GitIndex::ConflictRemove(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); + return ThrowException(Exception::Error(String::New("String path is required."))); } const char * from_path; @@ -754,33 +752,33 @@ NAN_METHOD(GitIndex::ConflictRemove) { free((void *)from_path); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** */ -NAN_METHOD(GitIndex::ConflictCleanup) { - NanScope(); +Handle GitIndex::ConflictCleanup(const Arguments& args) { + HandleScope scope; git_index_conflict_cleanup( ObjectWrap::Unwrap(args.This())->GetValue() ); - NanReturnUndefined(); + return Undefined(); } /** * @return {Number} result */ -NAN_METHOD(GitIndex::HasConflicts) { - NanScope(); +Handle GitIndex::HasConflicts(const Arguments& args) { + HandleScope scope; int result = git_index_has_conflicts( @@ -789,7 +787,7 @@ NAN_METHOD(GitIndex::HasConflicts) { Handle to; to = Int32::New(result); - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -800,45 +798,45 @@ NAN_METHOD(GitIndex::HasConflicts) { * @param {DiffOptions} opts * @param {DiffList} callback */ -NAN_METHOD(GitIndex::IndexToWorkdir) { - NanScope(); +Handle GitIndex::IndexToWorkdir(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Repository repo is required.")); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } IndexToWorkdirBaton* baton = new IndexToWorkdirBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args[0]); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - NanAssignPersistent(Value, baton->indexReference, args[1]); - git_index * from_index; - if (args[1]->IsObject()) { - from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - } else { - from_index = 0; - } - baton->index = from_index; - NanAssignPersistent(Value, baton->optsReference, args[2]); - const git_diff_options * from_opts; - if (args[2]->IsObject()) { - from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - } else { - from_opts = 0; - } - baton->opts = from_opts; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[3])); + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->indexReference = Persistent::New(args[1]); + git_index * from_index; + if (args[1]->IsObject()) { + from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + } else { + from_index = 0; + } + baton->index = from_index; + baton->optsReference = Persistent::New(args[2]); + const git_diff_options * from_opts; + if (args[2]->IsObject()) { + from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + } else { + from_opts = 0; + } + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, IndexToWorkdirWork, (uv_after_work_cb)IndexToWorkdirAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitIndex::IndexToWorkdirWork(uv_work_t *req) { @@ -856,7 +854,7 @@ void GitIndex::IndexToWorkdirWork(uv_work_t *req) { } void GitIndex::IndexToWorkdirAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; IndexToWorkdirBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -869,21 +867,21 @@ void GitIndex::IndexToWorkdirAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -897,4 +895,4 @@ void GitIndex::IndexToWorkdirAfterWork(uv_work_t *req) { delete baton; } -Persistent GitIndex::constructor_template; +Persistent GitIndex::constructor_template; diff --git a/src/index_entry.cc b/src/index_entry.cc index 7ce9f583b..933ffafda 100644 --- a/src/index_entry.cc +++ b/src/index_entry.cc @@ -25,12 +25,13 @@ GitIndexEntry::~GitIndexEntry() { } void GitIndexEntry::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("IndexEntry")); + tpl->SetClassName(String::NewSymbol("IndexEntry")); + NODE_SET_PROTOTYPE_METHOD(tpl, "ctime", Ctime); NODE_SET_PROTOTYPE_METHOD(tpl, "mtime", Mtime); @@ -45,38 +46,36 @@ void GitIndexEntry::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "flags_extended", FlagsExtended); NODE_SET_PROTOTYPE_METHOD(tpl, "path", Path); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("IndexEntry"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("IndexEntry"), constructor_template); } -NAN_METHOD(GitIndexEntry::New) { - NanScope(); +Handle GitIndexEntry::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_index_entry is required.")); + return ThrowException(Exception::Error(String::New("git_index_entry is required."))); } - GitIndexEntry* object = new GitIndexEntry((git_index_entry *) External::Cast(*args[0])->Value()); + GitIndexEntry* object = new GitIndexEntry((git_index_entry *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitIndexEntry::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitIndexEntry::constructor_template->NewInstance(1, argv)); } git_index_entry *GitIndexEntry::GetValue() { return this->raw; } -NAN_METHOD(GitIndexEntry::Ctime) { - NanScope(); + +Handle GitIndexEntry::Ctime(const Arguments& args) { + HandleScope scope; Handle to; git_index_time *ctime = @@ -90,11 +89,11 @@ NAN_METHOD(GitIndexEntry::Ctime) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::Mtime) { - NanScope(); +Handle GitIndexEntry::Mtime(const Arguments& args) { + HandleScope scope; Handle to; git_index_time *mtime = @@ -108,77 +107,77 @@ NAN_METHOD(GitIndexEntry::Mtime) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::Dev) { - NanScope(); +Handle GitIndexEntry::Dev(const Arguments& args) { + HandleScope scope; Handle to; unsigned int dev = ObjectWrap::Unwrap(args.This())->GetValue()->dev; to = Uint32::New(dev); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::Ino) { - NanScope(); +Handle GitIndexEntry::Ino(const Arguments& args) { + HandleScope scope; Handle to; unsigned int ino = ObjectWrap::Unwrap(args.This())->GetValue()->ino; to = Uint32::New(ino); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::Mode) { - NanScope(); +Handle GitIndexEntry::Mode(const Arguments& args) { + HandleScope scope; Handle to; uint16_t mode = ObjectWrap::Unwrap(args.This())->GetValue()->mode; to = Integer::New(mode); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::Uid) { - NanScope(); +Handle GitIndexEntry::Uid(const Arguments& args) { + HandleScope scope; Handle to; unsigned int uid = ObjectWrap::Unwrap(args.This())->GetValue()->uid; to = Uint32::New(uid); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::gid) { - NanScope(); +Handle GitIndexEntry::gid(const Arguments& args) { + HandleScope scope; Handle to; unsigned int gid = ObjectWrap::Unwrap(args.This())->GetValue()->gid; to = Uint32::New(gid); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::FileSize) { - NanScope(); +Handle GitIndexEntry::FileSize(const Arguments& args) { + HandleScope scope; Handle to; unsigned int file_size = ObjectWrap::Unwrap(args.This())->GetValue()->file_size; to = Uint32::New(file_size); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::Oid) { - NanScope(); +Handle GitIndexEntry::Oid(const Arguments& args) { + HandleScope scope; Handle to; git_oid *oid = @@ -192,40 +191,40 @@ NAN_METHOD(GitIndexEntry::Oid) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::Flags) { - NanScope(); +Handle GitIndexEntry::Flags(const Arguments& args) { + HandleScope scope; Handle to; uint16_t flags = ObjectWrap::Unwrap(args.This())->GetValue()->flags; to = Integer::New(flags); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::FlagsExtended) { - NanScope(); +Handle GitIndexEntry::FlagsExtended(const Arguments& args) { + HandleScope scope; Handle to; uint16_t flags_extended = ObjectWrap::Unwrap(args.This())->GetValue()->flags_extended; to = Integer::New(flags_extended); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexEntry::Path) { - NanScope(); +Handle GitIndexEntry::Path(const Arguments& args) { + HandleScope scope; Handle to; char * path = ObjectWrap::Unwrap(args.This())->GetValue()->path; to = String::New(path); - NanReturnValue(to); + return scope.Close(to); } -Persistent GitIndexEntry::constructor_template; +Persistent GitIndexEntry::constructor_template; diff --git a/src/index_time.cc b/src/index_time.cc index d44ac3ede..5501bd61a 100644 --- a/src/index_time.cc +++ b/src/index_time.cc @@ -23,66 +23,65 @@ GitIndexTime::~GitIndexTime() { } void GitIndexTime::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("IndexTime")); + tpl->SetClassName(String::NewSymbol("IndexTime")); + NODE_SET_PROTOTYPE_METHOD(tpl, "seconds", Seconds); NODE_SET_PROTOTYPE_METHOD(tpl, "nanoseconds", Nanoseconds); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("IndexTime"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("IndexTime"), constructor_template); } -NAN_METHOD(GitIndexTime::New) { - NanScope(); +Handle GitIndexTime::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_index_time is required.")); + return ThrowException(Exception::Error(String::New("git_index_time is required."))); } - GitIndexTime* object = new GitIndexTime((git_index_time *) External::Cast(*args[0])->Value()); + GitIndexTime* object = new GitIndexTime((git_index_time *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitIndexTime::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitIndexTime::constructor_template->NewInstance(1, argv)); } git_index_time *GitIndexTime::GetValue() { return this->raw; } -NAN_METHOD(GitIndexTime::Seconds) { - NanScope(); + +Handle GitIndexTime::Seconds(const Arguments& args) { + HandleScope scope; Handle to; git_time_t seconds = ObjectWrap::Unwrap(args.This())->GetValue()->seconds; to = Uint32::New(seconds); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitIndexTime::Nanoseconds) { - NanScope(); +Handle GitIndexTime::Nanoseconds(const Arguments& args) { + HandleScope scope; Handle to; unsigned int nanoseconds = ObjectWrap::Unwrap(args.This())->GetValue()->nanoseconds; to = Uint32::New(nanoseconds); - NanReturnValue(to); + return scope.Close(to); } -Persistent GitIndexTime::constructor_template; +Persistent GitIndexTime::constructor_template; diff --git a/src/object.cc b/src/object.cc index d9991c310..be1895226 100644 --- a/src/object.cc +++ b/src/object.cc @@ -25,41 +25,39 @@ GitObject::~GitObject() { } void GitObject::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Object")); + tpl->SetClassName(String::NewSymbol("Object")); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Object"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Object"), constructor_template); } -NAN_METHOD(GitObject::New) { - NanScope(); +Handle GitObject::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_object is required.")); + return ThrowException(Exception::Error(String::New("git_object is required."))); } - GitObject* object = new GitObject((git_object *) External::Cast(*args[0])->Value()); + GitObject* object = new GitObject((git_object *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitObject::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitObject::constructor_template->NewInstance(1, argv)); } git_object *GitObject::GetValue() { @@ -70,8 +68,8 @@ git_object *GitObject::GetValue() { /** * @return {Oid} result */ -NAN_METHOD(GitObject::Oid) { - NanScope(); +Handle GitObject::Oid(const Arguments& args) { + HandleScope scope; const git_oid * result = git_object_id( @@ -87,14 +85,14 @@ NAN_METHOD(GitObject::Oid) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitObject::Type) { - NanScope(); +Handle GitObject::Type(const Arguments& args) { + HandleScope scope; git_otype result = git_object_type( @@ -103,7 +101,7 @@ NAN_METHOD(GitObject::Type) { Handle to; to = Number::New(result); - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -112,31 +110,31 @@ NAN_METHOD(GitObject::Type) { * @param {Number} target_type * @param {Object} callback */ -NAN_METHOD(GitObject::Peel) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError(String::New("Number target_type is required.")); +Handle GitObject::Peel(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number target_type is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } PeelBaton* baton = new PeelBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->objectReference, args.This()); + baton->objectReference = Persistent::New(args.This()); baton->object = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->target_typeReference, args[0]); - git_otype from_target_type; - from_target_type = (git_otype) args[0]->ToInt32()->Value(); - baton->target_type = from_target_type; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->target_typeReference = Persistent::New(args[0]); + git_otype from_target_type; + from_target_type = (git_otype) args[0]->ToInt32()->Value(); + baton->target_type = from_target_type; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, PeelWork, (uv_after_work_cb)PeelAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitObject::PeelWork(uv_work_t *req) { @@ -153,7 +151,7 @@ void GitObject::PeelWork(uv_work_t *req) { } void GitObject::PeelAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; PeelBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -166,23 +164,23 @@ void GitObject::PeelAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal< Value >(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -193,4 +191,4 @@ void GitObject::PeelAfterWork(uv_work_t *req) { delete baton; } -Persistent GitObject::constructor_template; +Persistent GitObject::constructor_template; diff --git a/src/odb.cc b/src/odb.cc index d820b6d27..0ed9b605f 100644 --- a/src/odb.cc +++ b/src/odb.cc @@ -26,12 +26,12 @@ GitOdb::~GitOdb() { } void GitOdb::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Odb")); + tpl->SetClassName(String::NewSymbol("Odb")); NODE_SET_METHOD(tpl, "create()", Create); NODE_SET_METHOD(tpl, "open", Open); @@ -45,30 +45,28 @@ void GitOdb::Initialize(Handle target) { NODE_SET_METHOD(tpl, "hash", Hash); NODE_SET_METHOD(tpl, "hashfile", Hashfile); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Odb"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Odb"), constructor_template); } -NAN_METHOD(GitOdb::New) { - NanScope(); +Handle GitOdb::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_odb is required.")); + return ThrowException(Exception::Error(String::New("git_odb is required."))); } - GitOdb* object = new GitOdb((git_odb *) External::Cast(*args[0])->Value()); + GitOdb* object = new GitOdb((git_odb *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitOdb::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitOdb::constructor_template->NewInstance(1, argv)); } git_odb *GitOdb::GetValue() { @@ -79,8 +77,8 @@ git_odb *GitOdb::GetValue() { /** * @return {Odb} out */ -NAN_METHOD(GitOdb::Create) { - NanScope(); +Handle GitOdb::Create(const Arguments& args) { + HandleScope scope; git_odb * out = 0; @@ -89,9 +87,9 @@ NAN_METHOD(GitOdb::Create) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -101,17 +99,17 @@ NAN_METHOD(GitOdb::Create) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} objects_dir * @return {Odb} out */ -NAN_METHOD(GitOdb::Open) { - NanScope(); +Handle GitOdb::Open(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String objects_dir is required.")); + return ThrowException(Exception::Error(String::New("String objects_dir is required."))); } git_odb * out = 0; @@ -126,9 +124,9 @@ NAN_METHOD(GitOdb::Open) { free((void *)from_objects_dir); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -138,16 +136,16 @@ NAN_METHOD(GitOdb::Open) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} path */ -NAN_METHOD(GitOdb::AddDiskAlternate) { - NanScope(); +Handle GitOdb::AddDiskAlternate(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); + return ThrowException(Exception::Error(String::New("String path is required."))); } const char * from_path; @@ -161,13 +159,13 @@ NAN_METHOD(GitOdb::AddDiskAlternate) { free((void *)from_path); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } #include "../include/functions/copy.h" @@ -176,31 +174,31 @@ NAN_METHOD(GitOdb::AddDiskAlternate) { * @param {Oid} id * @param {OdbObject} callback */ -NAN_METHOD(GitOdb::Read) { - NanScope(); +Handle GitOdb::Read(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); + return ThrowException(Exception::Error(String::New("Oid id is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } ReadBaton* baton = new ReadBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->dbReference, args.This()); + baton->dbReference = Persistent::New(args.This()); baton->db = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->idReference, args[0]); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, ReadWork, (uv_after_work_cb)ReadAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitOdb::ReadWork(uv_work_t *req) { @@ -217,7 +215,7 @@ void GitOdb::ReadWork(uv_work_t *req) { } void GitOdb::ReadAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; ReadBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -230,21 +228,21 @@ void GitOdb::ReadAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -263,16 +261,16 @@ void GitOdb::ReadAfterWork(uv_work_t *req) { * @param {Number} len * @return {OdbObject} out */ -NAN_METHOD(GitOdb::ReadPrefix) { - NanScope(); +Handle GitOdb::ReadPrefix(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Odb db is required.")); + return ThrowException(Exception::Error(String::New("Odb db is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError(String::New("Oid short_id is required.")); + return ThrowException(Exception::Error(String::New("Oid short_id is required."))); } if (args.Length() == 2 || !args[2]->IsUint32()) { - return NanThrowError(String::New("Number len is required.")); + return ThrowException(Exception::Error(String::New("Number len is required."))); } git_odb_object * out = 0; @@ -281,7 +279,7 @@ NAN_METHOD(GitOdb::ReadPrefix) { const git_oid * from_short_id; from_short_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); size_t from_len; - from_len = (size_t) args[2]->ToUint32()->Value(); + from_len = (size_t) args[2]->ToUint32()->Value(); int result = git_odb_read_prefix( &out @@ -291,9 +289,9 @@ NAN_METHOD(GitOdb::ReadPrefix) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -303,7 +301,7 @@ NAN_METHOD(GitOdb::ReadPrefix) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** @@ -312,13 +310,13 @@ NAN_METHOD(GitOdb::ReadPrefix) { * @return {Number} len_out * @return {Number} type_out */ -NAN_METHOD(GitOdb::ReadHeader) { - NanScope(); +Handle GitOdb::ReadHeader(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Odb db is required.")); + return ThrowException(Exception::Error(String::New("Odb db is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); + return ThrowException(Exception::Error(String::New("Oid id is required."))); } size_t len_out = 0; @@ -336,9 +334,9 @@ NAN_METHOD(GitOdb::ReadHeader) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -350,16 +348,16 @@ NAN_METHOD(GitOdb::ReadHeader) { to = Int32::New(type_out); toReturn->Set(String::NewSymbol("type_out"), to); - NanReturnValue(toReturn); + return scope.Close(toReturn); } /** * @param {Oid} id */ -NAN_METHOD(GitOdb::Exists) { - NanScope(); +Handle GitOdb::Exists(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); + return ThrowException(Exception::Error(String::New("Oid id is required."))); } const git_oid * from_id; @@ -371,19 +369,19 @@ NAN_METHOD(GitOdb::Exists) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** */ -NAN_METHOD(GitOdb::Refresh) { - NanScope(); +Handle GitOdb::Refresh(const Arguments& args) { + HandleScope scope; int result = git_odb_refresh( @@ -391,13 +389,13 @@ NAN_METHOD(GitOdb::Refresh) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } #include "../include/functions/copy.h" @@ -408,20 +406,20 @@ NAN_METHOD(GitOdb::Refresh) { * @param {Number} type * @param {Oid} callback */ -NAN_METHOD(GitOdb::Write) { - NanScope(); +Handle GitOdb::Write(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String data is required.")); + return ThrowException(Exception::Error(String::New("String data is required."))); } if (args.Length() == 1 || !args[1]->IsUint32()) { - return NanThrowError(String::New("Number len is required.")); + return ThrowException(Exception::Error(String::New("Number len is required."))); } if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError(String::New("Number type is required.")); + return ThrowException(Exception::Error(String::New("Number type is required."))); } if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } WriteBaton* baton = new WriteBaton; @@ -429,26 +427,26 @@ NAN_METHOD(GitOdb::Write) { baton->error = NULL; baton->request.data = baton; baton->out = (git_oid *)malloc(sizeof(git_oid )); - NanAssignPersistent(Value, baton->odbReference, args.This()); + baton->odbReference = Persistent::New(args.This()); baton->odb = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->dataReference, args[0]); - const void * from_data; - String::Utf8Value data(args[0]->ToString()); - from_data = strdup(*data); - baton->data = from_data; - NanAssignPersistent(Value, baton->lenReference, args[1]); - size_t from_len; - from_len = (size_t) args[1]->ToUint32()->Value(); - baton->len = from_len; - NanAssignPersistent(Value, baton->typeReference, args[2]); - git_otype from_type; - from_type = (git_otype) args[2]->ToInt32()->Value(); - baton->type = from_type; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[3])); + baton->dataReference = Persistent::New(args[0]); + const void * from_data; + String::Utf8Value data(args[0]->ToString()); + from_data = strdup(*data); + baton->data = from_data; + baton->lenReference = Persistent::New(args[1]); + size_t from_len; + from_len = (size_t) args[1]->ToUint32()->Value(); + baton->len = from_len; + baton->typeReference = Persistent::New(args[2]); + git_otype from_type; + from_type = (git_otype) args[2]->ToInt32()->Value(); + baton->type = from_type; + baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, WriteWork, (uv_after_work_cb)WriteAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitOdb::WriteWork(uv_work_t *req) { @@ -467,7 +465,7 @@ void GitOdb::WriteWork(uv_work_t *req) { } void GitOdb::WriteAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; WriteBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -480,21 +478,21 @@ void GitOdb::WriteAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } free(baton->out); } @@ -517,25 +515,25 @@ void GitOdb::WriteAfterWork(uv_work_t *req) { * @param {Number} type * @return {Oid} out */ -NAN_METHOD(GitOdb::Hash) { - NanScope(); +Handle GitOdb::Hash(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Buffer data is required.")); + return ThrowException(Exception::Error(String::New("Buffer data is required."))); } if (args.Length() == 1 || !args[1]->IsUint32()) { - return NanThrowError(String::New("Number len is required.")); + return ThrowException(Exception::Error(String::New("Number len is required."))); } if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError(String::New("Number type is required.")); + return ThrowException(Exception::Error(String::New("Number type is required."))); } git_oid *out = (git_oid *)malloc(sizeof(git_oid)); const void * from_data; from_data = Buffer::Data(args[0]->ToObject()); size_t from_len; - from_len = (size_t) args[1]->ToUint32()->Value(); + from_len = (size_t) args[1]->ToUint32()->Value(); git_otype from_type; - from_type = (git_otype) args[2]->ToInt32()->Value(); + from_type = (git_otype) args[2]->ToInt32()->Value(); int result = git_odb_hash( out @@ -546,9 +544,9 @@ NAN_METHOD(GitOdb::Hash) { if (result != GIT_OK) { free(out); if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -558,7 +556,7 @@ NAN_METHOD(GitOdb::Hash) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** @@ -566,13 +564,13 @@ NAN_METHOD(GitOdb::Hash) { * @param {Number} type * @return {Oid} out */ -NAN_METHOD(GitOdb::Hashfile) { - NanScope(); +Handle GitOdb::Hashfile(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError(String::New("Number type is required.")); + return ThrowException(Exception::Error(String::New("Number type is required."))); } git_oid *out = (git_oid *)malloc(sizeof(git_oid)); @@ -580,7 +578,7 @@ NAN_METHOD(GitOdb::Hashfile) { String::Utf8Value path(args[0]->ToString()); from_path = strdup(*path); git_otype from_type; - from_type = (git_otype) args[1]->ToInt32()->Value(); + from_type = (git_otype) args[1]->ToInt32()->Value(); int result = git_odb_hashfile( out @@ -591,9 +589,9 @@ NAN_METHOD(GitOdb::Hashfile) { if (result != GIT_OK) { free(out); if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -603,7 +601,7 @@ NAN_METHOD(GitOdb::Hashfile) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -Persistent GitOdb::constructor_template; +Persistent GitOdb::constructor_template; diff --git a/src/odb_object.cc b/src/odb_object.cc index 7c8db710e..507d63736 100644 --- a/src/odb_object.cc +++ b/src/odb_object.cc @@ -25,42 +25,40 @@ GitOdbObject::~GitOdbObject() { } void GitOdbObject::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("OdbObject")); + tpl->SetClassName(String::NewSymbol("OdbObject")); NODE_SET_PROTOTYPE_METHOD(tpl, "data", Data); NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("OdbObject"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("OdbObject"), constructor_template); } -NAN_METHOD(GitOdbObject::New) { - NanScope(); +Handle GitOdbObject::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_odb_object is required.")); + return ThrowException(Exception::Error(String::New("git_odb_object is required."))); } - GitOdbObject* object = new GitOdbObject((git_odb_object *) External::Cast(*args[0])->Value()); + GitOdbObject* object = new GitOdbObject((git_odb_object *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitOdbObject::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitOdbObject::constructor_template->NewInstance(1, argv)); } git_odb_object *GitOdbObject::GetValue() { @@ -71,8 +69,8 @@ git_odb_object *GitOdbObject::GetValue() { /** * @return {Wrapper} result */ -NAN_METHOD(GitOdbObject::Data) { - NanScope(); +Handle GitOdbObject::Data(const Arguments& args) { + HandleScope scope; const void * result = git_odb_object_data( @@ -85,14 +83,14 @@ NAN_METHOD(GitOdbObject::Data) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitOdbObject::Size) { - NanScope(); +Handle GitOdbObject::Size(const Arguments& args) { + HandleScope scope; size_t result = git_odb_object_size( @@ -101,14 +99,14 @@ NAN_METHOD(GitOdbObject::Size) { Handle to; to = Uint32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitOdbObject::Type) { - NanScope(); +Handle GitOdbObject::Type(const Arguments& args) { + HandleScope scope; git_otype result = git_odb_object_type( @@ -117,14 +115,14 @@ NAN_METHOD(GitOdbObject::Type) { Handle to; to = Int32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Oid} result */ -NAN_METHOD(GitOdbObject::Oid) { - NanScope(); +Handle GitOdbObject::Oid(const Arguments& args) { + HandleScope scope; const git_oid * result = git_odb_object_id( @@ -140,7 +138,7 @@ NAN_METHOD(GitOdbObject::Oid) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -Persistent GitOdbObject::constructor_template; +Persistent GitOdbObject::constructor_template; diff --git a/src/oid.cc b/src/oid.cc index b00c1feb8..0f354998f 100755 --- a/src/oid.cc +++ b/src/oid.cc @@ -23,40 +23,38 @@ GitOid::~GitOid() { } void GitOid::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Oid")); + tpl->SetClassName(String::NewSymbol("Oid")); NODE_SET_METHOD(tpl, "fromString", FromString); NODE_SET_PROTOTYPE_METHOD(tpl, "sha", Sha); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Oid"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Oid"), constructor_template); } -NAN_METHOD(GitOid::New) { - NanScope(); +Handle GitOid::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_oid is required.")); + return ThrowException(Exception::Error(String::New("git_oid is required."))); } - GitOid* object = new GitOid((git_oid *) External::Cast(*args[0])->Value()); + GitOid* object = new GitOid((git_oid *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitOid::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitOid::constructor_template->NewInstance(1, argv)); } git_oid *GitOid::GetValue() { @@ -68,10 +66,10 @@ git_oid *GitOid::GetValue() { * @param {String} str * @return {Oid} out */ -NAN_METHOD(GitOid::FromString) { - NanScope(); +Handle GitOid::FromString(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String str is required.")); + return ThrowException(Exception::Error(String::New("String str is required."))); } git_oid *out = (git_oid *)malloc(sizeof(git_oid)); @@ -87,9 +85,9 @@ NAN_METHOD(GitOid::FromString) { if (result != GIT_OK) { free(out); if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -99,14 +97,14 @@ NAN_METHOD(GitOid::FromString) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitOid::Sha) { - NanScope(); +Handle GitOid::Sha(const Arguments& args) { + HandleScope scope; char * result = git_oid_allocfmt( @@ -116,7 +114,7 @@ NAN_METHOD(GitOid::Sha) { Handle to; to = String::New(result); free(result); - NanReturnValue(to); + return scope.Close(to); } -Persistent GitOid::constructor_template; +Persistent GitOid::constructor_template; diff --git a/src/patch.cc b/src/patch.cc index 36ba451de..ce5e9d90f 100644 --- a/src/patch.cc +++ b/src/patch.cc @@ -25,12 +25,12 @@ GitPatch::~GitPatch() { } void GitPatch::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Patch")); + tpl->SetClassName(String::NewSymbol("Patch")); NODE_SET_PROTOTYPE_METHOD(tpl, "delta", Delta); NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); @@ -40,30 +40,28 @@ void GitPatch::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "line", Line); NODE_SET_METHOD(tpl, "toString", ToString); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Patch"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Patch"), constructor_template); } -NAN_METHOD(GitPatch::New) { - NanScope(); +Handle GitPatch::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_diff_patch is required.")); + return ThrowException(Exception::Error(String::New("git_diff_patch is required."))); } - GitPatch* object = new GitPatch((git_diff_patch *) External::Cast(*args[0])->Value()); + GitPatch* object = new GitPatch((git_diff_patch *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitPatch::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitPatch::constructor_template->NewInstance(1, argv)); } git_diff_patch *GitPatch::GetValue() { @@ -74,8 +72,8 @@ git_diff_patch *GitPatch::GetValue() { /** * @return {Delta} result */ -NAN_METHOD(GitPatch::Delta) { - NanScope(); +Handle GitPatch::Delta(const Arguments& args) { + HandleScope scope; const git_diff_delta * result = git_diff_patch_delta( @@ -91,14 +89,14 @@ NAN_METHOD(GitPatch::Delta) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitPatch::Size) { - NanScope(); +Handle GitPatch::Size(const Arguments& args) { + HandleScope scope; size_t result = git_diff_patch_num_hunks( @@ -107,7 +105,7 @@ NAN_METHOD(GitPatch::Size) { Handle to; to = Uint32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** @@ -115,8 +113,8 @@ NAN_METHOD(GitPatch::Size) { * @return {Number} total_additions * @return {Number} total_deletions */ -NAN_METHOD(GitPatch::Stats) { - NanScope(); +Handle GitPatch::Stats(const Arguments& args) { + HandleScope scope; size_t total_context = 0; size_t total_additions = 0; @@ -130,9 +128,9 @@ NAN_METHOD(GitPatch::Stats) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -147,7 +145,7 @@ NAN_METHOD(GitPatch::Stats) { to = Integer::New(total_deletions); toReturn->Set(String::NewSymbol("total_deletions"), to); - NanReturnValue(toReturn); + return scope.Close(toReturn); } /** @@ -157,10 +155,10 @@ NAN_METHOD(GitPatch::Stats) { * @return {Number} header_len * @return {Number} lines_in_hunk */ -NAN_METHOD(GitPatch::Hunk) { - NanScope(); +Handle GitPatch::Hunk(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError(String::New("Number hunk_idx is required.")); + return ThrowException(Exception::Error(String::New("Number hunk_idx is required."))); } const git_diff_range * range = 0; @@ -168,7 +166,7 @@ NAN_METHOD(GitPatch::Hunk) { size_t header_len = 0; size_t lines_in_hunk = 0; size_t from_hunk_idx; - from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); + from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); int result = git_diff_patch_get_hunk( &range @@ -180,9 +178,9 @@ NAN_METHOD(GitPatch::Hunk) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -207,21 +205,21 @@ NAN_METHOD(GitPatch::Hunk) { to = Uint32::New(lines_in_hunk); toReturn->Set(String::NewSymbol("lines"), to); - NanReturnValue(toReturn); + return scope.Close(toReturn); } /** * @param {Number} hunk_idx * @return {Number} result */ -NAN_METHOD(GitPatch::Lines) { - NanScope(); +Handle GitPatch::Lines(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError(String::New("Number hunk_idx is required.")); + return ThrowException(Exception::Error(String::New("Number hunk_idx is required."))); } size_t from_hunk_idx; - from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); + from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); int result = git_diff_patch_num_lines_in_hunk( ObjectWrap::Unwrap(args.This())->GetValue() @@ -230,7 +228,7 @@ NAN_METHOD(GitPatch::Lines) { Handle to; to = Int32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** @@ -242,13 +240,13 @@ NAN_METHOD(GitPatch::Lines) { * @return {Number} old_lineno * @return {Number} new_lineno */ -NAN_METHOD(GitPatch::Line) { - NanScope(); +Handle GitPatch::Line(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError(String::New("Number hunk_idx is required.")); + return ThrowException(Exception::Error(String::New("Number hunk_idx is required."))); } if (args.Length() == 1 || !args[1]->IsUint32()) { - return NanThrowError(String::New("Number line_of_hunk is required.")); + return ThrowException(Exception::Error(String::New("Number line_of_hunk is required."))); } char line_origin = 0; @@ -257,9 +255,9 @@ NAN_METHOD(GitPatch::Line) { int old_lineno = 0; int new_lineno = 0; size_t from_hunk_idx; - from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); + from_hunk_idx = (size_t) args[0]->ToUint32()->Value(); size_t from_line_of_hunk; - from_line_of_hunk = (size_t) args[1]->ToUint32()->Value(); + from_line_of_hunk = (size_t) args[1]->ToUint32()->Value(); int result = git_diff_patch_get_line_in_hunk( &line_origin @@ -273,9 +271,9 @@ NAN_METHOD(GitPatch::Line) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -296,14 +294,14 @@ NAN_METHOD(GitPatch::Line) { to = Int32::New(new_lineno); toReturn->Set(String::NewSymbol("newLineNumber"), to); - NanReturnValue(toReturn); + return scope.Close(toReturn); } /** * @return {String} string */ -NAN_METHOD(GitPatch::ToString) { - NanScope(); +Handle GitPatch::ToString(const Arguments& args) { + HandleScope scope; char * string = 0; @@ -313,16 +311,16 @@ NAN_METHOD(GitPatch::ToString) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } Handle to; to = String::New(string); free(string); - NanReturnValue(to); + return scope.Close(to); } -Persistent GitPatch::constructor_template; +Persistent GitPatch::constructor_template; diff --git a/src/refdb.cc b/src/refdb.cc index 5f5074420..d1b344d76 100644 --- a/src/refdb.cc +++ b/src/refdb.cc @@ -23,38 +23,36 @@ GitRefDb::~GitRefDb() { } void GitRefDb::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("RefDb")); + tpl->SetClassName(String::NewSymbol("RefDb")); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("RefDb"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("RefDb"), constructor_template); } -NAN_METHOD(GitRefDb::New) { - NanScope(); +Handle GitRefDb::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_refdb is required.")); + return ThrowException(Exception::Error(String::New("git_refdb is required."))); } - GitRefDb* object = new GitRefDb((git_refdb *) External::Cast(*args[0])->Value()); + GitRefDb* object = new GitRefDb((git_refdb *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitRefDb::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitRefDb::constructor_template->NewInstance(1, argv)); } git_refdb *GitRefDb::GetValue() { @@ -62,4 +60,4 @@ git_refdb *GitRefDb::GetValue() { } -Persistent GitRefDb::constructor_template; +Persistent GitRefDb::constructor_template; diff --git a/src/reference.cc b/src/reference.cc index 4f1957410..53a666230 100755 --- a/src/reference.cc +++ b/src/reference.cc @@ -26,12 +26,12 @@ GitReference::~GitReference() { } void GitReference::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Reference")); + tpl->SetClassName(String::NewSymbol("Reference")); NODE_SET_METHOD(tpl, "oidForName", OidForName); NODE_SET_PROTOTYPE_METHOD(tpl, "target", Target); @@ -48,30 +48,28 @@ void GitReference::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); NODE_SET_METHOD(tpl, "isValidName", IsValidName); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Reference"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Reference"), constructor_template); } -NAN_METHOD(GitReference::New) { - NanScope(); +Handle GitReference::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_reference is required.")); + return ThrowException(Exception::Error(String::New("git_reference is required."))); } - GitReference* object = new GitReference((git_reference *) External::Cast(*args[0])->Value()); + GitReference* object = new GitReference((git_reference *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitReference::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitReference::constructor_template->NewInstance(1, argv)); } git_reference *GitReference::GetValue() { @@ -86,18 +84,17 @@ git_reference *GitReference::GetValue() { * @param {String} name * @param {Oid} callback */ -NAN_METHOD(GitReference::OidForName) { - NanScope(); - - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Repository repo is required.")); +Handle GitReference::OidForName(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError(String::New("String name is required.")); + return ThrowException(Exception::Error(String::New("String name is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } OidForNameBaton* baton = new OidForNameBaton; @@ -105,21 +102,20 @@ NAN_METHOD(GitReference::OidForName) { baton->error = NULL; baton->request.data = baton; baton->out = (git_oid *)malloc(sizeof(git_oid )); - - NanAssignPersistent(Value, baton->repoReference, args[0]); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - NanAssignPersistent(Value, baton->nameReference, args[1]); - const char * from_name; - String::Utf8Value name(args[1]->ToString()); - from_name = strdup(*name); - baton->name = from_name; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[2])); + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->nameReference = Persistent::New(args[1]); + const char * from_name; + String::Utf8Value name(args[1]->ToString()); + from_name = strdup(*name); + baton->name = from_name; + baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, OidForNameWork, (uv_after_work_cb)OidForNameAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitReference::OidForNameWork(uv_work_t *req) { @@ -136,7 +132,7 @@ void GitReference::OidForNameWork(uv_work_t *req) { } void GitReference::OidForNameAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; OidForNameBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -149,25 +145,24 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } free(baton->out); - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -182,9 +177,9 @@ void GitReference::OidForNameAfterWork(uv_work_t *req) { /** * @return {Oid} result */ -NAN_METHOD(GitReference::Target) { - NanScope(); - +Handle GitReference::Target(const Arguments& args) { + HandleScope scope; + const git_oid * result = git_reference_target( ObjectWrap::Unwrap(args.This())->GetValue() @@ -199,14 +194,14 @@ NAN_METHOD(GitReference::Target) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitReference::SymbolicTarget) { - NanScope(); +Handle GitReference::SymbolicTarget(const Arguments& args) { + HandleScope scope; const char * result = git_reference_symbolic_target( @@ -215,15 +210,15 @@ NAN_METHOD(GitReference::SymbolicTarget) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitReference::Type) { - NanScope(); - +Handle GitReference::Type(const Arguments& args) { + HandleScope scope; + git_ref_t result = git_reference_type( ObjectWrap::Unwrap(args.This())->GetValue() @@ -231,15 +226,15 @@ NAN_METHOD(GitReference::Type) { Handle to; to = Number::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitReference::Name) { - NanScope(); - +Handle GitReference::Name(const Arguments& args) { + HandleScope scope; + const char * result = git_reference_name( ObjectWrap::Unwrap(args.This())->GetValue() @@ -247,7 +242,7 @@ NAN_METHOD(GitReference::Name) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -255,25 +250,24 @@ NAN_METHOD(GitReference::Name) { /** * @param {Reference} callback */ -NAN_METHOD(GitReference::Resolve) { - NanScope(); - +Handle GitReference::Resolve(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } ResolveBaton* baton = new ResolveBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->refReference, args.This()); + baton->refReference = Persistent::New(args.This()); baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, ResolveWork, (uv_after_work_cb)ResolveAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitReference::ResolveWork(uv_work_t *req) { @@ -289,7 +283,7 @@ void GitReference::ResolveWork(uv_work_t *req) { } void GitReference::ResolveAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; ResolveBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -302,23 +296,23 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -332,10 +326,10 @@ void GitReference::ResolveAfterWork(uv_work_t *req) { * @param {String} target * @return {Reference} out */ -NAN_METHOD(GitReference::SetSymbolicTarget) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String target is required.")); +Handle GitReference::SetSymbolicTarget(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String target is required."))); } git_reference * out = 0; @@ -351,9 +345,9 @@ NAN_METHOD(GitReference::SetSymbolicTarget) { free((void *)from_target); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -363,17 +357,17 @@ NAN_METHOD(GitReference::SetSymbolicTarget) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {Oid} id * @return {Reference} out */ -NAN_METHOD(GitReference::setTarget) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); +Handle GitReference::setTarget(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); } git_reference * out = 0; @@ -387,9 +381,9 @@ NAN_METHOD(GitReference::setTarget) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -399,7 +393,7 @@ NAN_METHOD(GitReference::setTarget) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -409,39 +403,39 @@ NAN_METHOD(GitReference::setTarget) { * @param {Number} force * @param {Reference} callback */ -NAN_METHOD(GitReference::Rename) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String new_name is required.")); +Handle GitReference::Rename(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String new_name is required."))); } if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError(String::New("Number force is required.")); + return ThrowException(Exception::Error(String::New("Number force is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } RenameBaton* baton = new RenameBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->refReference, args.This()); + baton->refReference = Persistent::New(args.This()); baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->new_nameReference, args[0]); - const char * from_new_name; - String::Utf8Value new_name(args[0]->ToString()); - from_new_name = strdup(*new_name); - baton->new_name = from_new_name; - NanAssignPersistent(Value, baton->forceReference, args[1]); - int from_force; - from_force = (int) args[1]->ToInt32()->Value(); - baton->force = from_force; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[2])); + baton->new_nameReference = Persistent::New(args[0]); + const char * from_new_name; + String::Utf8Value new_name(args[0]->ToString()); + from_new_name = strdup(*new_name); + baton->new_name = from_new_name; + baton->forceReference = Persistent::New(args[1]); + int from_force; + from_force = (int) args[1]->ToInt32()->Value(); + baton->force = from_force; + baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, RenameWork, (uv_after_work_cb)RenameAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitReference::RenameWork(uv_work_t *req) { @@ -459,36 +453,36 @@ void GitReference::RenameWork(uv_work_t *req) { } void GitReference::RenameAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; RenameBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { Handle to; - if (baton->out != NULL) { + if (baton->out != NULL) { to = GitReference::New((void *)baton->out); } else { to = Null(); } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -505,24 +499,24 @@ void GitReference::RenameAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitReference::Delete) { - NanScope(); +Handle GitReference::Delete(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } DeleteBaton* baton = new DeleteBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->refReference, Local::Cast(args.This())); + baton->refReference = Persistent::New(args.This()); baton->ref = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, DeleteWork, (uv_after_work_cb)DeleteAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitReference::DeleteWork(uv_work_t *req) { @@ -537,30 +531,30 @@ void GitReference::DeleteWork(uv_work_t *req) { } void GitReference::DeleteAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; DeleteBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -572,27 +566,28 @@ void GitReference::DeleteAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitReference::IsBranch) { - NanScope(); +Handle GitReference::IsBranch(const Arguments& args) { + HandleScope scope; + int result = git_reference_is_branch( ObjectWrap::Unwrap(args.This())->GetValue() ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** */ -NAN_METHOD(GitReference::IsRemote) { - NanScope(); +Handle GitReference::IsRemote(const Arguments& args) { + HandleScope scope; int result = git_reference_is_remote( @@ -600,28 +595,28 @@ NAN_METHOD(GitReference::IsRemote) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @param {Number} type * @return {Object} out */ -NAN_METHOD(GitReference::Peel) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError(String::New("Number type is required.")); +Handle GitReference::Peel(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsInt32()) { + return ThrowException(Exception::Error(String::New("Number type is required."))); } git_object * out = 0; git_otype from_type; - from_type = (git_otype) args[0]->ToInt32()->Value(); + from_type = (git_otype) args[0]->ToInt32()->Value(); int result = git_reference_peel( &out @@ -630,9 +625,9 @@ NAN_METHOD(GitReference::Peel) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -642,16 +637,16 @@ NAN_METHOD(GitReference::Peel) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} refname */ -NAN_METHOD(GitReference::IsValidName) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String refname is required.")); +Handle GitReference::IsValidName(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String refname is required."))); } const char * from_refname; @@ -664,13 +659,13 @@ NAN_METHOD(GitReference::IsValidName) { free((void *)from_refname); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } -Persistent GitReference::constructor_template; +Persistent GitReference::constructor_template; diff --git a/src/remote.cc b/src/remote.cc index 7945b9ee5..c0fd95a6b 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -24,12 +24,12 @@ GitRemote::~GitRemote() { } void GitRemote::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Remote")); + tpl->SetClassName(String::NewSymbol("Remote")); NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); NODE_SET_PROTOTYPE_METHOD(tpl, "url", Url); @@ -50,30 +50,27 @@ void GitRemote::Initialize(Handle target) { NODE_SET_METHOD(tpl, "isValidName", IsValidName); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Remote"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Remote"), constructor_template); } -NAN_METHOD(GitRemote::New) { - NanScope(); +Handle GitRemote::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_remote is required.")); + return ThrowException(Exception::Error(String::New("git_remote is required."))); } - GitRemote* object = new GitRemote((git_remote *) External::Cast(*args[0])->Value()); + GitRemote* object = new GitRemote((git_remote *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitRemote::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitRemote::constructor_template->NewInstance(1, argv)); } git_remote *GitRemote::GetValue() { @@ -84,8 +81,8 @@ git_remote *GitRemote::GetValue() { /** * @return {String} result */ -NAN_METHOD(GitRemote::Name) { - NanScope(); +Handle GitRemote::Name(const Arguments& args) { + HandleScope scope; const char * result = git_remote_name( @@ -94,14 +91,14 @@ NAN_METHOD(GitRemote::Name) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitRemote::Url) { - NanScope(); +Handle GitRemote::Url(const Arguments& args) { + HandleScope scope; const char * result = git_remote_url( @@ -110,14 +107,14 @@ NAN_METHOD(GitRemote::Url) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitRemote::PushUrl) { - NanScope(); +Handle GitRemote::PushUrl(const Arguments& args) { + HandleScope scope; const char * result = git_remote_pushurl( @@ -126,16 +123,16 @@ NAN_METHOD(GitRemote::PushUrl) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} url */ -NAN_METHOD(GitRemote::SetUrl) { - NanScope(); +Handle GitRemote::SetUrl(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String url is required.")); + return ThrowException(Exception::Error(String::New("String url is required."))); } const char* from_url; @@ -149,22 +146,22 @@ NAN_METHOD(GitRemote::SetUrl) { free((void *)from_url); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @param {String} url */ -NAN_METHOD(GitRemote::SetPushUrl) { - NanScope(); +Handle GitRemote::SetPushUrl(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String url is required.")); + return ThrowException(Exception::Error(String::New("String url is required."))); } const char* from_url; @@ -178,13 +175,13 @@ NAN_METHOD(GitRemote::SetPushUrl) { free((void *)from_url); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } #include "../include/functions/copy.h" @@ -192,31 +189,31 @@ NAN_METHOD(GitRemote::SetPushUrl) { /** * @param {Number} direction */ -NAN_METHOD(GitRemote::Connect) { - NanScope(); +Handle GitRemote::Connect(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsNumber()) { - return NanThrowError(String::New("Number direction is required.")); + return ThrowException(Exception::Error(String::New("Number direction is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } ConnectBaton* baton = new ConnectBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->remoteReference, args.This()); + baton->remoteReference = Persistent::New(args.This()); baton->remote = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->directionReference, args[0]); - git_direction from_direction; - from_direction = (git_direction) args[0]->ToNumber()->Value(); - baton->direction = from_direction; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->directionReference = Persistent::New(args[0]); + git_direction from_direction; + from_direction = (git_direction) (int) args[0]->ToNumber()->Value(); + baton->direction = from_direction; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, ConnectWork, (uv_after_work_cb)ConnectAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRemote::ConnectWork(uv_work_t *req) { @@ -232,28 +229,28 @@ void GitRemote::ConnectWork(uv_work_t *req) { } void GitRemote::ConnectAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; ConnectBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -272,34 +269,33 @@ void GitRemote::ConnectAfterWork(uv_work_t *req) { * @param {Function} progress_cb * @param {void} payload */ -NAN_METHOD(GitRemote::Download) { - NanScope(); +Handle GitRemote::Download(const Arguments& args) { + HandleScope scope; if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } DownloadBaton* baton = new DownloadBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->remoteReference, args.This()); + baton->remoteReference = Persistent::New(args.This()); baton->remote = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->progress_cbReference, args[0]); - git_transfer_progress_callback from_progress_cb; - if (!args[0]->IsFunction()) { - //TODO Make progress callback work - //NanAssignPersistent(Function, baton->progress_cb, Local::Cast(args[0])); - } else { - from_progress_cb = 0; - } - baton->progress_cb = from_progress_cb; - NanAssignPersistent(Value, baton->payloadReference, args[1]); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->progress_cbReference = Persistent::New(args[0]); + git_transfer_progress_callback from_progress_cb; + if (args[0]->IsFunction()) { + Persistent::New(Local::Cast(args[0])); + } else { + from_progress_cb = 0; + } + baton->progress_cb = from_progress_cb; + baton->payloadReference = Persistent::New(args[1]); + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, DownloadWork, (uv_after_work_cb)DownloadAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRemote::DownloadWork(uv_work_t *req) { @@ -316,28 +312,28 @@ void GitRemote::DownloadWork(uv_work_t *req) { } void GitRemote::DownloadAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; DownloadBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -353,8 +349,8 @@ void GitRemote::DownloadAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitRemote::Connected) { - NanScope(); +Handle GitRemote::Connected(const Arguments& args) { + HandleScope scope; int result = git_remote_connected( @@ -362,50 +358,50 @@ NAN_METHOD(GitRemote::Connected) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** */ -NAN_METHOD(GitRemote::Stop) { - NanScope(); +Handle GitRemote::Stop(const Arguments& args) { + HandleScope scope; git_remote_stop( ObjectWrap::Unwrap(args.This())->GetValue() ); - NanReturnUndefined(); + return Undefined(); } #include "../include/functions/copy.h" /** */ -NAN_METHOD(GitRemote::Disconnect) { - NanScope(); +Handle GitRemote::Disconnect(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } DisconnectBaton* baton = new DisconnectBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->remoteReference, args.This()); + baton->remoteReference = Persistent::New(args.This()); baton->remote = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, DisconnectWork, (uv_after_work_cb)DisconnectAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRemote::DisconnectWork(uv_work_t *req) { @@ -416,28 +412,28 @@ void GitRemote::DisconnectWork(uv_work_t *req) { } void GitRemote::DisconnectAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; DisconnectBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -451,8 +447,8 @@ void GitRemote::DisconnectAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitRemote::UpdateTips) { - NanScope(); +Handle GitRemote::UpdateTips(const Arguments& args) { + HandleScope scope; int result = git_remote_update_tips( @@ -460,22 +456,22 @@ NAN_METHOD(GitRemote::UpdateTips) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @param {String} url */ -NAN_METHOD(GitRemote::ValidUrl) { - NanScope(); +Handle GitRemote::ValidUrl(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String url is required.")); + return ThrowException(Exception::Error(String::New("String url is required."))); } const char * from_url; @@ -488,22 +484,22 @@ NAN_METHOD(GitRemote::ValidUrl) { free((void *)from_url); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @param {String} url */ -NAN_METHOD(GitRemote::SupportedUrl) { - NanScope(); +Handle GitRemote::SupportedUrl(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String url is required.")); + return ThrowException(Exception::Error(String::New("String url is required."))); } const char* from_url; @@ -516,39 +512,39 @@ NAN_METHOD(GitRemote::SupportedUrl) { free((void *)from_url); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @param {Number} check */ -NAN_METHOD(GitRemote::CheckCert) { - NanScope(); +Handle GitRemote::CheckCert(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError(String::New("Number check is required.")); + return ThrowException(Exception::Error(String::New("Number check is required."))); } int from_check; - from_check = (int) args[0]->ToInt32()->Value(); + from_check = (int) args[0]->ToInt32()->Value(); git_remote_check_cert( ObjectWrap::Unwrap(args.This())->GetValue() , from_check ); - NanReturnUndefined(); + return Undefined(); } /** */ -NAN_METHOD(GitRemote::UpdateFetchhead) { - NanScope(); +Handle GitRemote::UpdateFetchhead(const Arguments& args) { + HandleScope scope; int result = git_remote_update_fetchhead( @@ -556,42 +552,42 @@ NAN_METHOD(GitRemote::UpdateFetchhead) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @param {Number} value */ -NAN_METHOD(GitRemote::SetUpdateFetchhead) { - NanScope(); +Handle GitRemote::SetUpdateFetchhead(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError(String::New("Number value is required.")); + return ThrowException(Exception::Error(String::New("Number value is required."))); } int from_value; - from_value = (int) args[0]->ToInt32()->Value(); + from_value = (int) args[0]->ToInt32()->Value(); git_remote_set_update_fetchhead( ObjectWrap::Unwrap(args.This())->GetValue() , from_value ); - NanReturnUndefined(); + return Undefined(); } /** * @param {String} remote_name */ -NAN_METHOD(GitRemote::IsValidName) { - NanScope(); +Handle GitRemote::IsValidName(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String remote_name is required.")); + return ThrowException(Exception::Error(String::New("String remote_name is required."))); } const char * from_remote_name; @@ -604,13 +600,13 @@ NAN_METHOD(GitRemote::IsValidName) { free((void *)from_remote_name); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } -Persistent GitRemote::constructor_template; +Persistent GitRemote::constructor_template; diff --git a/src/repo.cc b/src/repo.cc index 279252df2..637479573 100755 --- a/src/repo.cc +++ b/src/repo.cc @@ -39,7 +39,7 @@ GitRepo::~GitRepo() { } void GitRepo::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); @@ -76,32 +76,28 @@ void GitRepo::Initialize(Handle target) { NODE_SET_METHOD(tpl, "clone", Clone); NODE_SET_PROTOTYPE_METHOD(tpl, "getRemote", GetRemote); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Repo"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Repo"), constructor_template); } -NAN_METHOD(GitRepo::New) { - NanScope(); +Handle GitRepo::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_repository is required.")); + return ThrowException(Exception::Error(String::New("git_repository is required."))); } - GitRepo* object = new GitRepo((git_repository *) External::Cast(*args[0])->Value()); + GitRepo* object = new GitRepo((git_repository *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitRepo::New(void *raw) { - NanScope(); - + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - - return scope.Close(instance); + return scope.Close(GitRepo::constructor_template->NewInstance(1, argv)); } git_repository *GitRepo::GetValue() { @@ -115,30 +111,30 @@ git_repository *GitRepo::GetValue() { * @param {String} path * @param {Repository} callback */ -NAN_METHOD(GitRepo::Open) { - NanScope(); +Handle GitRepo::Open(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } OpenBaton* baton = new OpenBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->pathReference, args[0]); - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - baton->path = from_path; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->pathReference = Persistent::New(args[0]); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + baton->path = from_path; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::OpenWork(uv_work_t *req) { @@ -154,7 +150,7 @@ void GitRepo::OpenWork(uv_work_t *req) { } void GitRepo::OpenAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; OpenBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -167,23 +163,23 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -201,37 +197,37 @@ void GitRepo::OpenAfterWork(uv_work_t *req) { * @param {Boolean} is_bare * @param {Repository} callback */ -NAN_METHOD(GitRepo::Init) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); +Handle GitRepo::Init(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsBoolean()) { - return NanThrowError(String::New("Boolean is_bare is required.")); + return ThrowException(Exception::Error(String::New("Boolean is_bare is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } InitBaton* baton = new InitBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->pathReference, args[0]); - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - baton->path = from_path; - NanAssignPersistent(Value, baton->is_bareReference, args[1]); - unsigned from_is_bare; - from_is_bare = (unsigned) args[1]->ToBoolean()->Value(); - baton->is_bare = from_is_bare; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[2])); + baton->pathReference = Persistent::New(args[0]); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + baton->path = from_path; + baton->is_bareReference = Persistent::New(args[1]); + unsigned from_is_bare; + from_is_bare = (unsigned) args[1]->ToBoolean()->Value(); + baton->is_bare = from_is_bare; + baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, InitWork, (uv_after_work_cb)InitAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::InitWork(uv_work_t *req) { @@ -248,7 +244,7 @@ void GitRepo::InitWork(uv_work_t *req) { } void GitRepo::InitAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; InitBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -261,23 +257,23 @@ void GitRepo::InitAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -292,8 +288,8 @@ void GitRepo::InitAfterWork(uv_work_t *req) { /** * @return {String} result */ -NAN_METHOD(GitRepo::Path) { - NanScope(); +Handle GitRepo::Path(const Arguments& args) { + HandleScope scope; const char * result = git_repository_path( @@ -302,14 +298,14 @@ NAN_METHOD(GitRepo::Path) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitRepo::Workdir) { - NanScope(); +Handle GitRepo::Workdir(const Arguments& args) { + HandleScope scope; const char * result = git_repository_workdir( @@ -318,14 +314,14 @@ NAN_METHOD(GitRepo::Workdir) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Odb} out */ -NAN_METHOD(GitRepo::Odb) { - NanScope(); +Handle GitRepo::Odb(const Arguments& args) { + HandleScope scope; git_odb * out = 0; @@ -335,9 +331,9 @@ NAN_METHOD(GitRepo::Odb) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -347,7 +343,7 @@ NAN_METHOD(GitRepo::Odb) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -355,24 +351,24 @@ NAN_METHOD(GitRepo::Odb) { /** * @param {Index} callback */ -NAN_METHOD(GitRepo::openIndex) { - NanScope(); +Handle GitRepo::openIndex(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } openIndexBaton* baton = new openIndexBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, openIndexWork, (uv_after_work_cb)openIndexAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::openIndexWork(uv_work_t *req) { @@ -388,7 +384,7 @@ void GitRepo::openIndexWork(uv_work_t *req) { } void GitRepo::openIndexAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; openIndexBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -401,23 +397,23 @@ void GitRepo::openIndexAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -433,31 +429,31 @@ void GitRepo::openIndexAfterWork(uv_work_t *req) { * @param {Oid} id * @param {Blob} callback */ -NAN_METHOD(GitRepo::GetBlob) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); +Handle GitRepo::GetBlob(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetBlobBaton* baton = new GetBlobBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->idReference, args[0]); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, GetBlobWork, (uv_after_work_cb)GetBlobAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::GetBlobWork(uv_work_t *req) { @@ -474,7 +470,7 @@ void GitRepo::GetBlobWork(uv_work_t *req) { } void GitRepo::GetBlobAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetBlobBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -487,21 +483,21 @@ void GitRepo::GetBlobAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -520,31 +516,31 @@ void GitRepo::GetBlobAfterWork(uv_work_t *req) { * @param {Oid} id * @param {Commit} callback */ -NAN_METHOD(GitRepo::GetCommit) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); +Handle GitRepo::GetCommit(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetCommitBaton* baton = new GetCommitBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->idReference, args[0]); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, GetCommitWork, (uv_after_work_cb)GetCommitAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::GetCommitWork(uv_work_t *req) { @@ -561,7 +557,7 @@ void GitRepo::GetCommitWork(uv_work_t *req) { } void GitRepo::GetCommitAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetCommitBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -574,23 +570,23 @@ void GitRepo::GetCommitAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -614,29 +610,29 @@ void GitRepo::GetCommitAfterWork(uv_work_t *req) { * @param {Array} parents * @param {Oid} callback */ -NAN_METHOD(GitRepo::CreateCommit) { - NanScope(); - if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError(String::New("Signature author is required.")); +Handle GitRepo::CreateCommit(const Arguments& args) { + HandleScope scope; + if (args.Length() == 1 || !args[1]->IsObject()) { + return ThrowException(Exception::Error(String::New("Signature author is required."))); } if (args.Length() == 2 || !args[2]->IsObject()) { - return NanThrowError(String::New("Signature committer is required.")); + return ThrowException(Exception::Error(String::New("Signature committer is required."))); } if (args.Length() == 4 || !args[4]->IsString()) { - return NanThrowError(String::New("String message is required.")); + return ThrowException(Exception::Error(String::New("String message is required."))); } if (args.Length() == 5 || !args[5]->IsObject()) { - return NanThrowError(String::New("Tree tree is required.")); + return ThrowException(Exception::Error(String::New("Tree tree is required."))); } if (args.Length() == 6 || !args[6]->IsInt32()) { - return NanThrowError(String::New("Number parent_count is required.")); + return ThrowException(Exception::Error(String::New("Number parent_count is required."))); } if (args.Length() == 7 || !args[7]->IsObject()) { - return NanThrowError(String::New("Array parents is required.")); + return ThrowException(Exception::Error(String::New("Array parents is required."))); } if (args.Length() == 8 || !args[8]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } CreateCommitBaton* baton = new CreateCommitBaton; @@ -644,60 +640,61 @@ NAN_METHOD(GitRepo::CreateCommit) { baton->error = NULL; baton->request.data = baton; baton->id = (git_oid *)malloc(sizeof(git_oid )); - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->update_refReference, args[0]); - const char * from_update_ref; - if (args[0]->IsString()) { - String::Utf8Value update_ref(args[0]->ToString()); - from_update_ref = strdup(*update_ref); - } else { - from_update_ref = 0; - } - baton->update_ref = from_update_ref; - NanAssignPersistent(Value, baton->authorReference, args[1]); - const git_signature * from_author; - from_author = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->author = from_author; - NanAssignPersistent(Value, baton->committerReference, args[2]); - const git_signature * from_committer; - from_committer = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->committer = from_committer; - NanAssignPersistent(Value, baton->message_encodingReference, args[3]); - const char * from_message_encoding; - if (args[3]->IsString()) { - String::Utf8Value message_encoding(args[3]->ToString()); - from_message_encoding = strdup(*message_encoding); - } else { - from_message_encoding = 0; - } - baton->message_encoding = from_message_encoding; - NanAssignPersistent(Value, baton->messageReference, args[4]); - const char * from_message; - String::Utf8Value message(args[4]->ToString()); - from_message = strdup(*message); - baton->message = from_message; - NanAssignPersistent(Value, baton->treeReference, args[5]); - const git_tree * from_tree; - from_tree = ObjectWrap::Unwrap(args[5]->ToObject())->GetValue(); - baton->tree = from_tree; - NanAssignPersistent(Value, baton->parent_countReference, args[6]); - int from_parent_count; - from_parent_count = (int) args[6]->ToInt32()->Value(); - baton->parent_count = from_parent_count; - NanAssignPersistent(Value, baton->parentsReference, args[7]); - const git_commit ** from_parents; - Array *tmp_parents = Array::Cast(*args[7]); - from_parents = (const git_commit **)malloc(tmp_parents->Length() * sizeof(const git_commit *)); - for (unsigned int i = 0; i < tmp_parents->Length(); i++) { - from_parents[i] = ObjectWrap::Unwrap(tmp_parents->Get(Number::New(static_cast(i)))->ToObject())->GetValue(); - } - baton->parents = from_parents; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[8])); + baton->update_refReference = Persistent::New(args[0]); + const char * from_update_ref; + if (args[0]->IsString()) { + String::Utf8Value update_ref(args[0]->ToString()); + from_update_ref = strdup(*update_ref); + } else { + from_update_ref = 0; + } + baton->update_ref = from_update_ref; + baton->authorReference = Persistent::New(args[1]); + const git_signature * from_author; + from_author = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->author = from_author; + baton->committerReference = Persistent::New(args[2]); + const git_signature * from_committer; + from_committer = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->committer = from_committer; + baton->message_encodingReference = Persistent::New(args[3]); + const char * from_message_encoding; + if (args[3]->IsString()) { + String::Utf8Value message_encoding(args[3]->ToString()); + from_message_encoding = strdup(*message_encoding); + } else { + from_message_encoding = 0; + } + baton->message_encoding = from_message_encoding; + baton->messageReference = Persistent::New(args[4]); + const char * from_message; + String::Utf8Value message(args[4]->ToString()); + from_message = strdup(*message); + baton->message = from_message; + baton->treeReference = Persistent::New(args[5]); + const git_tree * from_tree; + from_tree = ObjectWrap::Unwrap(args[5]->ToObject())->GetValue(); + baton->tree = from_tree; + baton->parent_countReference = Persistent::New(args[6]); + int from_parent_count; + from_parent_count = (int) args[6]->ToInt32()->Value(); + baton->parent_count = from_parent_count; + baton->parentsReference = Persistent::New(args[7]); + const git_commit ** from_parents; + Array *tmp_parents = Array::Cast(*args[7]); + from_parents = (const git_commit **)malloc(tmp_parents->Length() * sizeof(const git_commit *)); + for (unsigned int i = 0; i < tmp_parents->Length(); i++) { + + from_parents[i] = ObjectWrap::Unwrap(tmp_parents->Get(Number::New(static_cast(i)))->ToObject())->GetValue(); + } + baton->parents = from_parents; + baton->callback = Persistent::New(Local::Cast(args[8])); uv_queue_work(uv_default_loop(), &baton->request, CreateCommitWork, (uv_after_work_cb)CreateCommitAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::CreateCommitWork(uv_work_t *req) { @@ -721,7 +718,7 @@ void GitRepo::CreateCommitWork(uv_work_t *req) { } void GitRepo::CreateCommitAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; CreateCommitBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -734,24 +731,24 @@ void GitRepo::CreateCommitAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - free(baton->id); - } + free(baton->id); + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -780,39 +777,38 @@ void GitRepo::CreateCommitAfterWork(uv_work_t *req) { * @param {Number} type * @param {Object} callback */ -NAN_METHOD(GitRepo::GetObject) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); +Handle GitRepo::GetObject(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); } if (args.Length() == 1 || !args[1]->IsInt32()) { - return NanThrowError(String::New("Number type is required.")); + return ThrowException(Exception::Error(String::New("Number type is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetObjectBaton* baton = new GetObjectBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->idReference, args[0]); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - NanAssignPersistent(Value, baton->typeReference, args[1]); - - git_otype from_type; - from_type = (git_otype) args[1]->ToInt32()->Value(); - baton->type = from_type; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[2])); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->typeReference = Persistent::New(args[1]); + git_otype from_type; + from_type = (git_otype) args[1]->ToInt32()->Value(); + baton->type = from_type; + baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, GetObjectWork, (uv_after_work_cb)GetObjectAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::GetObjectWork(uv_work_t *req) { @@ -830,7 +826,7 @@ void GitRepo::GetObjectWork(uv_work_t *req) { } void GitRepo::GetObjectAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetObjectBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -843,21 +839,21 @@ void GitRepo::GetObjectAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -877,32 +873,32 @@ void GitRepo::GetObjectAfterWork(uv_work_t *req) { * @param {String} name * @param {Reference} callback */ -NAN_METHOD(GitRepo::GetReference) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String name is required.")); +Handle GitRepo::GetReference(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetReferenceBaton* baton = new GetReferenceBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->nameReference, args[0]); - const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); - baton->name = from_name; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->nameReference = Persistent::New(args[0]); + const char * from_name; + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); + baton->name = from_name; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, GetReferenceWork, (uv_after_work_cb)GetReferenceAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::GetReferenceWork(uv_work_t *req) { @@ -919,7 +915,7 @@ void GitRepo::GetReferenceWork(uv_work_t *req) { } void GitRepo::GetReferenceAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetReferenceBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -932,21 +928,21 @@ void GitRepo::GetReferenceAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -966,16 +962,16 @@ void GitRepo::GetReferenceAfterWork(uv_work_t *req) { * @param {Number} force * @return {Reference} out */ -NAN_METHOD(GitRepo::CreateSymbolicReference) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String name is required.")); +Handle GitRepo::CreateSymbolicReference(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError(String::New("String target is required.")); + return ThrowException(Exception::Error(String::New("String target is required."))); } if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError(String::New("Number force is required.")); + return ThrowException(Exception::Error(String::New("Number force is required."))); } git_reference * out = 0; @@ -986,7 +982,7 @@ NAN_METHOD(GitRepo::CreateSymbolicReference) { String::Utf8Value target(args[1]->ToString()); from_target = strdup(*target); int from_force; - from_force = (int) args[2]->ToInt32()->Value(); + from_force = (int) args[2]->ToInt32()->Value(); int result = git_reference_symbolic_create( &out @@ -999,9 +995,9 @@ NAN_METHOD(GitRepo::CreateSymbolicReference) { free((void *)from_target); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -1011,7 +1007,7 @@ NAN_METHOD(GitRepo::CreateSymbolicReference) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** @@ -1020,16 +1016,16 @@ NAN_METHOD(GitRepo::CreateSymbolicReference) { * @param {Number} force * @return {Reference} out */ -NAN_METHOD(GitRepo::CreateReference) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String name is required.")); +Handle GitRepo::CreateReference(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); + return ThrowException(Exception::Error(String::New("Oid id is required."))); } if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError(String::New("Number force is required.")); + return ThrowException(Exception::Error(String::New("Number force is required."))); } git_reference * out = 0; @@ -1039,7 +1035,7 @@ NAN_METHOD(GitRepo::CreateReference) { const git_oid * from_id; from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); int from_force; - from_force = (int) args[2]->ToInt32()->Value(); + from_force = (int) args[2]->ToInt32()->Value(); int result = git_reference_create( &out @@ -1051,9 +1047,9 @@ NAN_METHOD(GitRepo::CreateReference) { free((void *)from_name); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -1063,7 +1059,7 @@ NAN_METHOD(GitRepo::CreateReference) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -1073,40 +1069,40 @@ NAN_METHOD(GitRepo::CreateReference) { * @param {String} url * @param {Remote} callback */ -NAN_METHOD(GitRepo::AddRemote) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String name is required.")); +Handle GitRepo::AddRemote(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError(String::New("String url is required.")); + return ThrowException(Exception::Error(String::New("String url is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } AddRemoteBaton* baton = new AddRemoteBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->nameReference, args[0]); - const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); - baton->name = from_name; - NanAssignPersistent(Value, baton->urlReference, args[1]); - const char * from_url; - String::Utf8Value url(args[1]->ToString()); - from_url = strdup(*url); - baton->url = from_url; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[2])); + baton->nameReference = Persistent::New(args[0]); + const char * from_name; + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); + baton->name = from_name; + baton->urlReference = Persistent::New(args[1]); + const char * from_url; + String::Utf8Value url(args[1]->ToString()); + from_url = strdup(*url); + baton->url = from_url; + baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, AddRemoteWork, (uv_after_work_cb)AddRemoteAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::AddRemoteWork(uv_work_t *req) { @@ -1124,7 +1120,7 @@ void GitRepo::AddRemoteWork(uv_work_t *req) { } void GitRepo::AddRemoteAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; AddRemoteBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -1137,21 +1133,21 @@ void GitRepo::AddRemoteAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -1170,8 +1166,8 @@ void GitRepo::AddRemoteAfterWork(uv_work_t *req) { /** * @return {RevWalk} out */ -NAN_METHOD(GitRepo::CreateRevWalk) { - NanScope(); +Handle GitRepo::CreateRevWalk(const Arguments& args) { + HandleScope scope; git_revwalk * out = 0; @@ -1181,9 +1177,9 @@ NAN_METHOD(GitRepo::CreateRevWalk) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -1193,17 +1189,17 @@ NAN_METHOD(GitRepo::CreateRevWalk) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} name * @return {Submodule} submodule */ -NAN_METHOD(GitRepo::GetSubmodule) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String name is required.")); +Handle GitRepo::GetSubmodule(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); } git_submodule * submodule = 0; @@ -1219,9 +1215,9 @@ NAN_METHOD(GitRepo::GetSubmodule) { free((void *)from_name); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -1231,7 +1227,7 @@ NAN_METHOD(GitRepo::GetSubmodule) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** @@ -1240,16 +1236,16 @@ NAN_METHOD(GitRepo::GetSubmodule) { * @param {Number} use_gitlink * @return {Submodule} submodule */ -NAN_METHOD(GitRepo::AddSubmodule) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String url is required.")); +Handle GitRepo::AddSubmodule(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError(String::New("String path is required.")); + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError(String::New("Number use_gitlink is required.")); + return ThrowException(Exception::Error(String::New("Number use_gitlink is required."))); } git_submodule * submodule = 0; @@ -1260,7 +1256,7 @@ NAN_METHOD(GitRepo::AddSubmodule) { String::Utf8Value path(args[1]->ToString()); from_path = strdup(*path); int from_use_gitlink; - from_use_gitlink = (int) args[2]->ToInt32()->Value(); + from_use_gitlink = (int) args[2]->ToInt32()->Value(); int result = git_submodule_add_setup( &submodule @@ -1273,9 +1269,9 @@ NAN_METHOD(GitRepo::AddSubmodule) { free((void *)from_path); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -1285,7 +1281,7 @@ NAN_METHOD(GitRepo::AddSubmodule) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -1294,31 +1290,31 @@ NAN_METHOD(GitRepo::AddSubmodule) { * @param {Oid} id * @param {Tag} callback */ -NAN_METHOD(GitRepo::GetTag) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); +Handle GitRepo::GetTag(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetTagBaton* baton = new GetTagBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->idReference, args[0]); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, GetTagWork, (uv_after_work_cb)GetTagAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::GetTagWork(uv_work_t *req) { @@ -1335,7 +1331,7 @@ void GitRepo::GetTagWork(uv_work_t *req) { } void GitRepo::GetTagAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetTagBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -1348,21 +1344,21 @@ void GitRepo::GetTagAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -1385,26 +1381,26 @@ void GitRepo::GetTagAfterWork(uv_work_t *req) { * @param {Number} force * @param {Oid} callback */ -NAN_METHOD(GitRepo::CreateTag) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String tag_name is required.")); +Handle GitRepo::CreateTag(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError(String::New("Object target is required.")); + return ThrowException(Exception::Error(String::New("Object target is required."))); } if (args.Length() == 2 || !args[2]->IsObject()) { - return NanThrowError(String::New("Signature tagger is required.")); + return ThrowException(Exception::Error(String::New("Signature tagger is required."))); } if (args.Length() == 3 || !args[3]->IsString()) { - return NanThrowError(String::New("String message is required.")); + return ThrowException(Exception::Error(String::New("String message is required."))); } if (args.Length() == 4 || !args[4]->IsInt32()) { - return NanThrowError(String::New("Number force is required.")); + return ThrowException(Exception::Error(String::New("Number force is required."))); } if (args.Length() == 5 || !args[5]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } CreateTagBaton* baton = new CreateTagBaton; @@ -1412,35 +1408,35 @@ NAN_METHOD(GitRepo::CreateTag) { baton->error = NULL; baton->request.data = baton; baton->oid = (git_oid *)malloc(sizeof(git_oid )); - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->tag_nameReference, args[0]); - const char * from_tag_name; - String::Utf8Value tag_name(args[0]->ToString()); - from_tag_name = strdup(*tag_name); - baton->tag_name = from_tag_name; - NanAssignPersistent(Value, baton->targetReference, args[1]); - const git_object * from_target; - from_target = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->target = from_target; - NanAssignPersistent(Value, baton->taggerReference, args[2]); - const git_signature * from_tagger; - from_tagger = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - baton->tagger = from_tagger; - NanAssignPersistent(Value, baton->messageReference, args[3]); - const char * from_message; - String::Utf8Value message(args[3]->ToString()); - from_message = strdup(*message); - baton->message = from_message; - NanAssignPersistent(Value, baton->forceReference, args[4]); - int from_force; - from_force = (int) args[4]->ToInt32()->Value(); - baton->force = from_force; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[5])); + baton->tag_nameReference = Persistent::New(args[0]); + const char * from_tag_name; + String::Utf8Value tag_name(args[0]->ToString()); + from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; + baton->targetReference = Persistent::New(args[1]); + const git_object * from_target; + from_target = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->target = from_target; + baton->taggerReference = Persistent::New(args[2]); + const git_signature * from_tagger; + from_tagger = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + baton->tagger = from_tagger; + baton->messageReference = Persistent::New(args[3]); + const char * from_message; + String::Utf8Value message(args[3]->ToString()); + from_message = strdup(*message); + baton->message = from_message; + baton->forceReference = Persistent::New(args[4]); + int from_force; + from_force = (int) args[4]->ToInt32()->Value(); + baton->force = from_force; + baton->callback = Persistent::New(Local::Cast(args[5])); uv_queue_work(uv_default_loop(), &baton->request, CreateTagWork, (uv_after_work_cb)CreateTagAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::CreateTagWork(uv_work_t *req) { @@ -1461,7 +1457,7 @@ void GitRepo::CreateTagWork(uv_work_t *req) { } void GitRepo::CreateTagAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; CreateTagBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -1474,21 +1470,21 @@ void GitRepo::CreateTagAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } free(baton->oid); } @@ -1516,20 +1512,20 @@ void GitRepo::CreateTagAfterWork(uv_work_t *req) { * @param {Number} force * @param {Oid} callback */ -NAN_METHOD(GitRepo::CreateLightweightTag) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String tag_name is required.")); +Handle GitRepo::CreateLightweightTag(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError(String::New("Object target is required.")); + return ThrowException(Exception::Error(String::New("Object target is required."))); } if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError(String::New("Number force is required.")); + return ThrowException(Exception::Error(String::New("Number force is required."))); } if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } CreateLightweightTagBaton* baton = new CreateLightweightTagBaton; @@ -1537,26 +1533,26 @@ NAN_METHOD(GitRepo::CreateLightweightTag) { baton->error = NULL; baton->request.data = baton; baton->oid = (git_oid *)malloc(sizeof(git_oid )); - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->tag_nameReference, args[0]); - const char * from_tag_name; - String::Utf8Value tag_name(args[0]->ToString()); - from_tag_name = strdup(*tag_name); - baton->tag_name = from_tag_name; - NanAssignPersistent(Value, baton->targetReference, args[1]); - const git_object * from_target; - from_target = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->target = from_target; - NanAssignPersistent(Value, baton->forceReference, args[2]); - int from_force; - from_force = (int) args[2]->ToInt32()->Value(); - baton->force = from_force; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[3])); + baton->tag_nameReference = Persistent::New(args[0]); + const char * from_tag_name; + String::Utf8Value tag_name(args[0]->ToString()); + from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; + baton->targetReference = Persistent::New(args[1]); + const git_object * from_target; + from_target = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->target = from_target; + baton->forceReference = Persistent::New(args[2]); + int from_force; + from_force = (int) args[2]->ToInt32()->Value(); + baton->force = from_force; + baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, CreateLightweightTagWork, (uv_after_work_cb)CreateLightweightTagAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::CreateLightweightTagWork(uv_work_t *req) { @@ -1575,7 +1571,7 @@ void GitRepo::CreateLightweightTagWork(uv_work_t *req) { } void GitRepo::CreateLightweightTagAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; CreateLightweightTagBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -1588,21 +1584,21 @@ void GitRepo::CreateLightweightTagAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } free(baton->oid); } @@ -1625,31 +1621,31 @@ void GitRepo::CreateLightweightTagAfterWork(uv_work_t *req) { * @param {Oid} id * @param {Tree} callback */ -NAN_METHOD(GitRepo::GetTree) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); +Handle GitRepo::GetTree(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid id is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetTreeBaton* baton = new GetTreeBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->idReference, args[0]); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, GetTreeWork, (uv_after_work_cb)GetTreeAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::GetTreeWork(uv_work_t *req) { @@ -1666,7 +1662,7 @@ void GitRepo::GetTreeWork(uv_work_t *req) { } void GitRepo::GetTreeAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetTreeBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -1679,21 +1675,21 @@ void GitRepo::GetTreeAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -1710,24 +1706,24 @@ void GitRepo::GetTreeAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitRepo::ReloadSubmodules) { - NanScope(); +Handle GitRepo::ReloadSubmodules(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } ReloadSubmodulesBaton* baton = new ReloadSubmodulesBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, ReloadSubmodulesWork, (uv_after_work_cb)ReloadSubmodulesAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::ReloadSubmodulesWork(uv_work_t *req) { @@ -1742,28 +1738,28 @@ void GitRepo::ReloadSubmodulesWork(uv_work_t *req) { } void GitRepo::ReloadSubmodulesAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; ReloadSubmodulesBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -1780,32 +1776,32 @@ void GitRepo::ReloadSubmodulesAfterWork(uv_work_t *req) { /** * @param {String} tag_name */ -NAN_METHOD(GitRepo::Delete) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String tag_name is required.")); +Handle GitRepo::Delete(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String tag_name is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } DeleteBaton* baton = new DeleteBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->tag_nameReference, args[0]); - const char * from_tag_name; - String::Utf8Value tag_name(args[0]->ToString()); - from_tag_name = strdup(*tag_name); - baton->tag_name = from_tag_name; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->tag_nameReference = Persistent::New(args[0]); + const char * from_tag_name; + String::Utf8Value tag_name(args[0]->ToString()); + from_tag_name = strdup(*tag_name); + baton->tag_name = from_tag_name; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, DeleteWork, (uv_after_work_cb)DeleteAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::DeleteWork(uv_work_t *req) { @@ -1821,28 +1817,28 @@ void GitRepo::DeleteWork(uv_work_t *req) { } void GitRepo::DeleteAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; DeleteBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -1862,11 +1858,11 @@ void GitRepo::DeleteAfterWork(uv_work_t *req) { * @param {Number} list_flags * @param {Array} callback */ -NAN_METHOD(GitRepo::GetReferences) { - NanScope(); +Handle GitRepo::GetReferences(const Arguments& args) { + HandleScope scope; if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetReferencesBaton* baton = new GetReferencesBaton; @@ -1874,21 +1870,21 @@ NAN_METHOD(GitRepo::GetReferences) { baton->error = NULL; baton->request.data = baton; baton->array = (git_strarray *)malloc(sizeof(git_strarray )); - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->list_flagsReference, args[0]); - unsigned int from_list_flags; - if (args[0]->IsUint32()) { - from_list_flags = (unsigned int) args[0]->ToUint32()->Value(); - } else { - from_list_flags = 0; - } - baton->list_flags = from_list_flags; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->list_flagsReference = Persistent::New(args[0]); + unsigned int from_list_flags; + if (args[0]->IsUint32()) { + from_list_flags = (unsigned int) args[0]->ToUint32()->Value(); + } else { + from_list_flags = 0; + } + baton->list_flags = from_list_flags; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, GetReferencesWork, (uv_after_work_cb)GetReferencesAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::GetReferencesWork(uv_work_t *req) { @@ -1905,7 +1901,7 @@ void GitRepo::GetReferencesWork(uv_work_t *req) { } void GitRepo::GetReferencesAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetReferencesBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -1919,21 +1915,21 @@ void GitRepo::GetReferencesAfterWork(uv_work_t *req) { to = tmpArray; Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } free(baton->array); } @@ -1956,17 +1952,17 @@ void GitRepo::GetReferencesAfterWork(uv_work_t *req) { * @param {Number} len * @param {Oid} callback */ -NAN_METHOD(GitRepo::CreateBlobFromBuffer) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Buffer buffer is required.")); +Handle GitRepo::CreateBlobFromBuffer(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Buffer buffer is required."))); } if (args.Length() == 1 || !args[1]->IsNumber()) { - return NanThrowError(String::New("Number len is required.")); + return ThrowException(Exception::Error(String::New("Number len is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } CreateBlobFromBufferBaton* baton = new CreateBlobFromBufferBaton; @@ -1974,21 +1970,21 @@ NAN_METHOD(GitRepo::CreateBlobFromBuffer) { baton->error = NULL; baton->request.data = baton; baton->oid = (git_oid *)malloc(sizeof(git_oid )); - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->bufferReference, args[0]); - const void * from_buffer; - from_buffer = Buffer::Data(args[0]->ToObject()); - baton->buffer = from_buffer; - NanAssignPersistent(Value, baton->lenReference, args[1]); - size_t from_len; - from_len = (size_t) args[1]->ToNumber()->Value(); - baton->len = from_len; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[2])); + baton->bufferReference = Persistent::New(args[0]); + const void * from_buffer; + from_buffer = Buffer::Data(args[0]->ToObject()); + baton->buffer = from_buffer; + baton->lenReference = Persistent::New(args[1]); + size_t from_len; + from_len = (size_t) args[1]->ToNumber()->Value(); + baton->len = from_len; + baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, CreateBlobFromBufferWork, (uv_after_work_cb)CreateBlobFromBufferAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::CreateBlobFromBufferWork(uv_work_t *req) { @@ -2006,7 +2002,7 @@ void GitRepo::CreateBlobFromBufferWork(uv_work_t *req) { } void GitRepo::CreateBlobFromBufferAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; CreateBlobFromBufferBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -2019,21 +2015,21 @@ void GitRepo::CreateBlobFromBufferAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } free(baton->oid); } @@ -2054,14 +2050,14 @@ void GitRepo::CreateBlobFromBufferAfterWork(uv_work_t *req) { * @param {String} path * @param {Oid} callback */ -NAN_METHOD(GitRepo::CreateBlobFromFile) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); +Handle GitRepo::CreateBlobFromFile(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } CreateBlobFromFileBaton* baton = new CreateBlobFromFileBaton; @@ -2069,18 +2065,18 @@ NAN_METHOD(GitRepo::CreateBlobFromFile) { baton->error = NULL; baton->request.data = baton; baton->id = (git_oid *)malloc(sizeof(git_oid )); - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->pathReference, args[0]); - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - baton->path = from_path; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->pathReference = Persistent::New(args[0]); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + baton->path = from_path; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, CreateBlobFromFileWork, (uv_after_work_cb)CreateBlobFromFileAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::CreateBlobFromFileWork(uv_work_t *req) { @@ -2097,7 +2093,7 @@ void GitRepo::CreateBlobFromFileWork(uv_work_t *req) { } void GitRepo::CreateBlobFromFileAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; CreateBlobFromFileBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -2110,21 +2106,21 @@ void GitRepo::CreateBlobFromFileAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } free(baton->id); } @@ -2144,11 +2140,11 @@ void GitRepo::CreateBlobFromFileAfterWork(uv_work_t *req) { /** * @param {Array} callback */ -NAN_METHOD(GitRepo::GetRemotes) { - NanScope(); +Handle GitRepo::GetRemotes(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetRemotesBaton* baton = new GetRemotesBaton; @@ -2156,13 +2152,13 @@ NAN_METHOD(GitRepo::GetRemotes) { baton->error = NULL; baton->request.data = baton; baton->out = (git_strarray *)malloc(sizeof(git_strarray )); - NanAssignPersistent(Value, baton->repoReference, args.This()); + baton->repoReference = Persistent::New(args.This()); baton->repo = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, GetRemotesWork, (uv_after_work_cb)GetRemotesAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::GetRemotesWork(uv_work_t *req) { @@ -2178,7 +2174,7 @@ void GitRepo::GetRemotesWork(uv_work_t *req) { } void GitRepo::GetRemotesAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetRemotesBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -2192,21 +2188,21 @@ void GitRepo::GetRemotesAfterWork(uv_work_t *req) { to = tmpArray; Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } free(baton->out); } @@ -2229,46 +2225,46 @@ void GitRepo::GetRemotesAfterWork(uv_work_t *req) { * @param {CloneOptions} options * @param {Repository} callback */ -NAN_METHOD(GitRepo::Clone) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String url is required.")); +Handle GitRepo::Clone(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String url is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError(String::New("String local_path is required.")); + return ThrowException(Exception::Error(String::New("String local_path is required."))); } if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } CloneBaton* baton = new CloneBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->urlReference, args[0]); - const char * from_url; - String::Utf8Value url(args[0]->ToString()); - from_url = strdup(*url); - baton->url = from_url; - NanAssignPersistent(Value, baton->local_pathReference, args[1]); - const char * from_local_path; - String::Utf8Value local_path(args[1]->ToString()); - from_local_path = strdup(*local_path); - baton->local_path = from_local_path; - NanAssignPersistent(Value, baton->optionsReference, args[2]); - const git_clone_options * from_options; - if (args[2]->IsObject()) { - from_options = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - } else { - from_options = 0; - } - baton->options = from_options; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[3])); + baton->urlReference = Persistent::New(args[0]); + const char * from_url; + String::Utf8Value url(args[0]->ToString()); + from_url = strdup(*url); + baton->url = from_url; + baton->local_pathReference = Persistent::New(args[1]); + const char * from_local_path; + String::Utf8Value local_path(args[1]->ToString()); + from_local_path = strdup(*local_path); + baton->local_path = from_local_path; + baton->optionsReference = Persistent::New(args[2]); + const git_clone_options * from_options; + if (args[2]->IsObject()) { + from_options = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + } else { + from_options = 0; + } + baton->options = from_options; + baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, CloneWork, (uv_after_work_cb)CloneAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRepo::CloneWork(uv_work_t *req) { @@ -2286,7 +2282,7 @@ void GitRepo::CloneWork(uv_work_t *req) { } void GitRepo::CloneAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; CloneBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -2299,23 +2295,23 @@ void GitRepo::CloneAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -2333,16 +2329,16 @@ void GitRepo::CloneAfterWork(uv_work_t *req) { * @param {String} name * @return {Remote} out */ -NAN_METHOD(GitRepo::GetRemote) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String name is required.")); +Handle GitRepo::GetRemote(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); } git_remote * out = 0; const char * from_name; - String::Utf8Value name(args[0]->ToString()); - from_name = strdup(*name); + String::Utf8Value name(args[0]->ToString()); + from_name = strdup(*name); int result = git_remote_load( &out @@ -2352,9 +2348,9 @@ NAN_METHOD(GitRepo::GetRemote) { free((void *)from_name); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -2364,7 +2360,7 @@ NAN_METHOD(GitRepo::GetRemote) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -Persistent GitRepo::constructor_template; +Persistent GitRepo::constructor_template; diff --git a/src/revwalk.cc b/src/revwalk.cc index 63751cf04..20d7a940b 100755 --- a/src/revwalk.cc +++ b/src/revwalk.cc @@ -25,12 +25,12 @@ GitRevWalk::~GitRevWalk() { } void GitRevWalk::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("RevWalk")); + tpl->SetClassName(String::NewSymbol("RevWalk")); NODE_SET_PROTOTYPE_METHOD(tpl, "reset", Reset); NODE_SET_PROTOTYPE_METHOD(tpl, "push", Push); @@ -45,29 +45,27 @@ void GitRevWalk::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "sorting", Sorting); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("RevWalk"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("RevWalk"), constructor_template); } -NAN_METHOD(GitRevWalk::New) { - NanScope(); + +Handle GitRevWalk::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_revwalk is required.")); + return ThrowException(Exception::Error(String::New("git_revwalk is required."))); } - GitRevWalk* object = new GitRevWalk((git_revwalk *) External::Cast(*args[0])->Value()); + GitRevWalk* object = new GitRevWalk((git_revwalk *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitRevWalk::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitRevWalk::constructor_template->NewInstance(1, argv)); } git_revwalk *GitRevWalk::GetValue() { @@ -77,15 +75,15 @@ git_revwalk *GitRevWalk::GetValue() { /** */ -NAN_METHOD(GitRevWalk::Reset) { - NanScope(); +Handle GitRevWalk::Reset(const Arguments& args) { + HandleScope scope; git_revwalk_reset( ObjectWrap::Unwrap(args.This())->GetValue() ); - NanReturnUndefined(); + return Undefined(); } #include "../include/functions/copy.h" @@ -93,31 +91,31 @@ NAN_METHOD(GitRevWalk::Reset) { /** * @param {Oid} id */ -NAN_METHOD(GitRevWalk::Push) { - NanScope(); +Handle GitRevWalk::Push(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); + return ThrowException(Exception::Error(String::New("Oid id is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } PushBaton* baton = new PushBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->walkReference, args.This()); + baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->idReference, args[0]); - const git_oid * from_id; - from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->id = from_id; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->idReference = Persistent::New(args[0]); + const git_oid * from_id; + from_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->id = from_id; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, PushWork, (uv_after_work_cb)PushAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRevWalk::PushWork(uv_work_t *req) { @@ -133,28 +131,28 @@ void GitRevWalk::PushWork(uv_work_t *req) { } void GitRevWalk::PushAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; PushBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -172,32 +170,32 @@ void GitRevWalk::PushAfterWork(uv_work_t *req) { /** * @param {String} glob */ -NAN_METHOD(GitRevWalk::PushGlob) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String glob is required.")); +Handle GitRevWalk::PushGlob(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String glob is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } PushGlobBaton* baton = new PushGlobBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->walkReference, args.This()); + baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->globReference, args[0]); - const char * from_glob; - String::Utf8Value glob(args[0]->ToString()); - from_glob = strdup(*glob); - baton->glob = from_glob; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->globReference = Persistent::New(args[0]); + const char * from_glob; + String::Utf8Value glob(args[0]->ToString()); + from_glob = strdup(*glob); + baton->glob = from_glob; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, PushGlobWork, (uv_after_work_cb)PushGlobAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRevWalk::PushGlobWork(uv_work_t *req) { @@ -213,28 +211,28 @@ void GitRevWalk::PushGlobWork(uv_work_t *req) { } void GitRevWalk::PushGlobAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; PushGlobBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -252,24 +250,24 @@ void GitRevWalk::PushGlobAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitRevWalk::PushHead) { - NanScope(); +Handle GitRevWalk::PushHead(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } PushHeadBaton* baton = new PushHeadBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->walkReference, args.This()); + baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, PushHeadWork, (uv_after_work_cb)PushHeadAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRevWalk::PushHeadWork(uv_work_t *req) { @@ -284,28 +282,28 @@ void GitRevWalk::PushHeadWork(uv_work_t *req) { } void GitRevWalk::PushHeadAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; PushHeadBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -322,31 +320,31 @@ void GitRevWalk::PushHeadAfterWork(uv_work_t *req) { /** * @param {Oid} commit_id */ -NAN_METHOD(GitRevWalk::Hide) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid commit_id is required.")); +Handle GitRevWalk::Hide(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsObject()) { + return ThrowException(Exception::Error(String::New("Oid commit_id is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } HideBaton* baton = new HideBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->walkReference, args.This()); + baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->commit_idReference, args[0]); - const git_oid * from_commit_id; - from_commit_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->commit_id = from_commit_id; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->commit_idReference = Persistent::New(args[0]); + const git_oid * from_commit_id; + from_commit_id = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->commit_id = from_commit_id; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, HideWork, (uv_after_work_cb)HideAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRevWalk::HideWork(uv_work_t *req) { @@ -362,28 +360,28 @@ void GitRevWalk::HideWork(uv_work_t *req) { } void GitRevWalk::HideAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; HideBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -401,32 +399,32 @@ void GitRevWalk::HideAfterWork(uv_work_t *req) { /** * @param {String} glob */ -NAN_METHOD(GitRevWalk::HideGlob) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String glob is required.")); +Handle GitRevWalk::HideGlob(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String glob is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } HideGlobBaton* baton = new HideGlobBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->walkReference, args.This()); + baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->globReference, args[0]); - const char * from_glob; - String::Utf8Value glob(args[0]->ToString()); - from_glob = strdup(*glob); - baton->glob = from_glob; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->globReference = Persistent::New(args[0]); + const char * from_glob; + String::Utf8Value glob(args[0]->ToString()); + from_glob = strdup(*glob); + baton->glob = from_glob; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, HideGlobWork, (uv_after_work_cb)HideGlobAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRevWalk::HideGlobWork(uv_work_t *req) { @@ -442,28 +440,28 @@ void GitRevWalk::HideGlobWork(uv_work_t *req) { } void GitRevWalk::HideGlobAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; HideGlobBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -481,24 +479,24 @@ void GitRevWalk::HideGlobAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitRevWalk::HideHead) { - NanScope(); +Handle GitRevWalk::HideHead(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } HideHeadBaton* baton = new HideHeadBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->walkReference, args.This()); + baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, HideHeadWork, (uv_after_work_cb)HideHeadAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRevWalk::HideHeadWork(uv_work_t *req) { @@ -513,30 +511,30 @@ void GitRevWalk::HideHeadWork(uv_work_t *req) { } void GitRevWalk::HideHeadAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; HideHeadBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -551,32 +549,32 @@ void GitRevWalk::HideHeadAfterWork(uv_work_t *req) { /** * @param {String} refname */ -NAN_METHOD(GitRevWalk::PushRef) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String refname is required.")); +Handle GitRevWalk::PushRef(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String refname is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } PushRefBaton* baton = new PushRefBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->walkReference, args.This()); + baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->refnameReference, args[0]); - const char * from_refname; - String::Utf8Value refname(args[0]->ToString()); - from_refname = strdup(*refname); - baton->refname = from_refname; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->refnameReference = Persistent::New(args[0]); + const char * from_refname; + String::Utf8Value refname(args[0]->ToString()); + from_refname = strdup(*refname); + baton->refname = from_refname; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, PushRefWork, (uv_after_work_cb)PushRefAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRevWalk::PushRefWork(uv_work_t *req) { @@ -592,30 +590,30 @@ void GitRevWalk::PushRefWork(uv_work_t *req) { } void GitRevWalk::PushRefAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; PushRefBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -632,32 +630,32 @@ void GitRevWalk::PushRefAfterWork(uv_work_t *req) { /** * @param {String} refname */ -NAN_METHOD(GitRevWalk::HideRef) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String refname is required.")); +Handle GitRevWalk::HideRef(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String refname is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } HideRefBaton* baton = new HideRefBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->walkReference, args.This()); + baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->refnameReference, args[0]); - const char * from_refname; - String::Utf8Value refname(args[0]->ToString()); - from_refname = strdup(*refname); - baton->refname = from_refname; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->refnameReference = Persistent::New(args[0]); + const char * from_refname; + String::Utf8Value refname(args[0]->ToString()); + from_refname = strdup(*refname); + baton->refname = from_refname; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, HideRefWork, (uv_after_work_cb)HideRefAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRevWalk::HideRefWork(uv_work_t *req) { @@ -673,30 +671,30 @@ void GitRevWalk::HideRefWork(uv_work_t *req) { } void GitRevWalk::HideRefAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; HideRefBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } - } + } if (try_catch.HasCaught()) { node::FatalException(try_catch); @@ -713,11 +711,11 @@ void GitRevWalk::HideRefAfterWork(uv_work_t *req) { /** * @param {Oid} callback */ -NAN_METHOD(GitRevWalk::Next) { - NanScope(); +Handle GitRevWalk::Next(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } NextBaton* baton = new NextBaton; @@ -725,13 +723,13 @@ NAN_METHOD(GitRevWalk::Next) { baton->error = NULL; baton->request.data = baton; baton->out = (git_oid *)malloc(sizeof(git_oid )); - NanAssignPersistent(Value, baton->walkReference, args.This()); + baton->walkReference = Persistent::New(args.This()); baton->walk = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, NextWork, (uv_after_work_cb)NextAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitRevWalk::NextWork(uv_work_t *req) { @@ -747,7 +745,7 @@ void GitRevWalk::NextWork(uv_work_t *req) { } void GitRevWalk::NextAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; NextBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -760,21 +758,21 @@ void GitRevWalk::NextAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } free(baton->out); } @@ -790,21 +788,21 @@ void GitRevWalk::NextAfterWork(uv_work_t *req) { /** * @param {Number} sort_mode */ -NAN_METHOD(GitRevWalk::Sorting) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError(String::New("Number sort_mode is required.")); +Handle GitRevWalk::Sorting(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsUint32()) { + return ThrowException(Exception::Error(String::New("Number sort_mode is required."))); } unsigned int from_sort_mode; - from_sort_mode = (unsigned int) args[0]->ToUint32()->Value(); + from_sort_mode = (unsigned int) args[0]->ToUint32()->Value(); git_revwalk_sorting( ObjectWrap::Unwrap(args.This())->GetValue() , from_sort_mode ); - NanReturnUndefined(); + return Undefined(); } -Persistent GitRevWalk::constructor_template; +Persistent GitRevWalk::constructor_template; diff --git a/src/signature.cc b/src/signature.cc index aec9b1f3a..d355896eb 100755 --- a/src/signature.cc +++ b/src/signature.cc @@ -24,12 +24,12 @@ GitSignature::~GitSignature() { } void GitSignature::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Signature")); + tpl->SetClassName(String::NewSymbol("Signature")); NODE_SET_METHOD(tpl, "create", Create); NODE_SET_METHOD(tpl, "now", Now); @@ -38,30 +38,27 @@ void GitSignature::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "email", Email); NODE_SET_PROTOTYPE_METHOD(tpl, "time", Time); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Signature"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Signature"), constructor_template); } -NAN_METHOD(GitSignature::New) { - NanScope(); +Handle GitSignature::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_signature is required.")); + return ThrowException(Exception::Error(String::New("git_signature is required."))); } - GitSignature* object = new GitSignature((git_signature *) External::Cast(*args[0])->Value()); + GitSignature* object = new GitSignature((git_signature *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitSignature::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitSignature::constructor_template->NewInstance(1, argv)); } git_signature *GitSignature::GetValue() { @@ -76,19 +73,19 @@ git_signature *GitSignature::GetValue() { * @param {Number} offset * @return {Signature} out */ -NAN_METHOD(GitSignature::Create) { - NanScope(); - if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String name is required.")); +Handle GitSignature::Create(const Arguments& args) { + HandleScope scope; + if (args.Length() == 0 || !args[0]->IsString()) { + return ThrowException(Exception::Error(String::New("String name is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError(String::New("String email is required.")); + return ThrowException(Exception::Error(String::New("String email is required."))); } if (args.Length() == 2 || !args[2]->IsInt32()) { - return NanThrowError(String::New("Number time is required.")); + return ThrowException(Exception::Error(String::New("Number time is required."))); } if (args.Length() == 3 || !args[3]->IsInt32()) { - return NanThrowError(String::New("Number offset is required.")); + return ThrowException(Exception::Error(String::New("Number offset is required."))); } git_signature * out = 0; @@ -99,9 +96,9 @@ NAN_METHOD(GitSignature::Create) { String::Utf8Value email(args[1]->ToString()); from_email = strdup(*email); git_time_t from_time; - from_time = (git_time_t) args[2]->ToInt32()->Value(); + from_time = (git_time_t) args[2]->ToInt32()->Value(); int from_offset; - from_offset = (int) args[3]->ToInt32()->Value(); + from_offset = (int) args[3]->ToInt32()->Value(); int result = git_signature_new( &out @@ -114,9 +111,9 @@ NAN_METHOD(GitSignature::Create) { free((void *)from_email); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -126,7 +123,7 @@ NAN_METHOD(GitSignature::Create) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** @@ -134,13 +131,13 @@ NAN_METHOD(GitSignature::Create) { * @param {String} email * @return {Signature} out */ -NAN_METHOD(GitSignature::Now) { - NanScope(); +Handle GitSignature::Now(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String name is required.")); + return ThrowException(Exception::Error(String::New("String name is required."))); } if (args.Length() == 1 || !args[1]->IsString()) { - return NanThrowError(String::New("String email is required.")); + return ThrowException(Exception::Error(String::New("String email is required."))); } git_signature * out = 0; @@ -160,9 +157,9 @@ NAN_METHOD(GitSignature::Now) { free((void *)from_email); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -172,32 +169,33 @@ NAN_METHOD(GitSignature::Now) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitSignature::Name) { - NanScope(); + +Handle GitSignature::Name(const Arguments& args) { + HandleScope scope; Handle to; const char * name = ObjectWrap::Unwrap(args.This())->GetValue()->name; to = String::New(name); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitSignature::Email) { - NanScope(); +Handle GitSignature::Email(const Arguments& args) { + HandleScope scope; Handle to; const char * email = ObjectWrap::Unwrap(args.This())->GetValue()->email; to = String::New(email); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitSignature::Time) { - NanScope(); +Handle GitSignature::Time(const Arguments& args) { + HandleScope scope; Handle to; git_time *when = @@ -211,7 +209,7 @@ NAN_METHOD(GitSignature::Time) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -Persistent GitSignature::constructor_template; +Persistent GitSignature::constructor_template; diff --git a/src/submodule.cc b/src/submodule.cc index 367426317..2b355fc9c 100644 --- a/src/submodule.cc +++ b/src/submodule.cc @@ -25,12 +25,12 @@ GitSubmodule::~GitSubmodule() { } void GitSubmodule::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Submodule")); + tpl->SetClassName(String::NewSymbol("Submodule")); NODE_SET_PROTOTYPE_METHOD(tpl, "addFinalize", AddFinalize); NODE_SET_PROTOTYPE_METHOD(tpl, "addToIndex", AddToIndex); @@ -48,30 +48,27 @@ void GitSubmodule::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "status", Status); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Submodule"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Submodule"), constructor_template); } -NAN_METHOD(GitSubmodule::New) { - NanScope(); +Handle GitSubmodule::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_submodule is required.")); + return ThrowException(Exception::Error(String::New("git_submodule is required."))); } - GitSubmodule* object = new GitSubmodule((git_submodule *) External::Cast(*args[0])->Value()); + GitSubmodule* object = new GitSubmodule((git_submodule *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitSubmodule::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitSubmodule::constructor_template->NewInstance(1, argv)); } git_submodule *GitSubmodule::GetValue() { @@ -83,24 +80,24 @@ git_submodule *GitSubmodule::GetValue() { /** */ -NAN_METHOD(GitSubmodule::AddFinalize) { - NanScope(); +Handle GitSubmodule::AddFinalize(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } AddFinalizeBaton* baton = new AddFinalizeBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->submoduleReference, args.This()); + baton->submoduleReference = Persistent::New(args.This()); baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, AddFinalizeWork, (uv_after_work_cb)AddFinalizeAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitSubmodule::AddFinalizeWork(uv_work_t *req) { @@ -115,28 +112,28 @@ void GitSubmodule::AddFinalizeWork(uv_work_t *req) { } void GitSubmodule::AddFinalizeAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; AddFinalizeBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -153,31 +150,31 @@ void GitSubmodule::AddFinalizeAfterWork(uv_work_t *req) { /** * @param {Number} write_index */ -NAN_METHOD(GitSubmodule::AddToIndex) { - NanScope(); +Handle GitSubmodule::AddToIndex(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError(String::New("Number write_index is required.")); + return ThrowException(Exception::Error(String::New("Number write_index is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } AddToIndexBaton* baton = new AddToIndexBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->submoduleReference, args.This()); + baton->submoduleReference = Persistent::New(args.This()); baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->write_indexReference, args[0]); - int from_write_index; - from_write_index = (int) args[0]->ToInt32()->Value(); - baton->write_index = from_write_index; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->write_indexReference = Persistent::New(args[0]); + int from_write_index; + from_write_index = (int) args[0]->ToInt32()->Value(); + baton->write_index = from_write_index; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, AddToIndexWork, (uv_after_work_cb)AddToIndexAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitSubmodule::AddToIndexWork(uv_work_t *req) { @@ -193,28 +190,28 @@ void GitSubmodule::AddToIndexWork(uv_work_t *req) { } void GitSubmodule::AddToIndexAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; AddToIndexBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -231,24 +228,24 @@ void GitSubmodule::AddToIndexAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitSubmodule::Save) { - NanScope(); +Handle GitSubmodule::Save(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } SaveBaton* baton = new SaveBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->submoduleReference, args.This()); + baton->submoduleReference = Persistent::New(args.This()); baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, SaveWork, (uv_after_work_cb)SaveAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitSubmodule::SaveWork(uv_work_t *req) { @@ -263,28 +260,28 @@ void GitSubmodule::SaveWork(uv_work_t *req) { } void GitSubmodule::SaveAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; SaveBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -299,8 +296,8 @@ void GitSubmodule::SaveAfterWork(uv_work_t *req) { /** * @return {String} result */ -NAN_METHOD(GitSubmodule::Name) { - NanScope(); +Handle GitSubmodule::Name(const Arguments& args) { + HandleScope scope; const char * result = git_submodule_name( @@ -309,14 +306,14 @@ NAN_METHOD(GitSubmodule::Name) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitSubmodule::Path) { - NanScope(); +Handle GitSubmodule::Path(const Arguments& args) { + HandleScope scope; const char * result = git_submodule_path( @@ -325,14 +322,14 @@ NAN_METHOD(GitSubmodule::Path) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitSubmodule::Url) { - NanScope(); +Handle GitSubmodule::Url(const Arguments& args) { + HandleScope scope; const char * result = git_submodule_url( @@ -341,16 +338,16 @@ NAN_METHOD(GitSubmodule::Url) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} url */ -NAN_METHOD(GitSubmodule::SetUrl) { - NanScope(); +Handle GitSubmodule::SetUrl(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String url is required.")); + return ThrowException(Exception::Error(String::New("String url is required."))); } const char * from_url; @@ -364,20 +361,20 @@ NAN_METHOD(GitSubmodule::SetUrl) { free((void *)from_url); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** * @return {Oid} result */ -NAN_METHOD(GitSubmodule::IndexId) { - NanScope(); +Handle GitSubmodule::IndexId(const Arguments& args) { + HandleScope scope; const git_oid * result = git_submodule_index_id( @@ -393,14 +390,14 @@ NAN_METHOD(GitSubmodule::IndexId) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Oid} result */ -NAN_METHOD(GitSubmodule::HeadId) { - NanScope(); +Handle GitSubmodule::HeadId(const Arguments& args) { + HandleScope scope; const git_oid * result = git_submodule_head_id( @@ -416,7 +413,7 @@ NAN_METHOD(GitSubmodule::HeadId) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -424,31 +421,31 @@ NAN_METHOD(GitSubmodule::HeadId) { /** * @param {Number} overwrite */ -NAN_METHOD(GitSubmodule::Init) { - NanScope(); +Handle GitSubmodule::Init(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError(String::New("Number overwrite is required.")); + return ThrowException(Exception::Error(String::New("Number overwrite is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } InitBaton* baton = new InitBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->submoduleReference, args.This()); + baton->submoduleReference = Persistent::New(args.This()); baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->overwriteReference, args[0]); - int from_overwrite; - from_overwrite = (int) args[0]->ToInt32()->Value(); - baton->overwrite = from_overwrite; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->overwriteReference = Persistent::New(args[0]); + int from_overwrite; + from_overwrite = (int) args[0]->ToInt32()->Value(); + baton->overwrite = from_overwrite; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, InitWork, (uv_after_work_cb)InitAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitSubmodule::InitWork(uv_work_t *req) { @@ -464,28 +461,28 @@ void GitSubmodule::InitWork(uv_work_t *req) { } void GitSubmodule::InitAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; InitBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -502,24 +499,24 @@ void GitSubmodule::InitAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitSubmodule::Sync) { - NanScope(); +Handle GitSubmodule::Sync(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } SyncBaton* baton = new SyncBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->submoduleReference, args.This()); + baton->submoduleReference = Persistent::New(args.This()); baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, SyncWork, (uv_after_work_cb)SyncAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitSubmodule::SyncWork(uv_work_t *req) { @@ -534,28 +531,28 @@ void GitSubmodule::SyncWork(uv_work_t *req) { } void GitSubmodule::SyncAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; SyncBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -572,24 +569,24 @@ void GitSubmodule::SyncAfterWork(uv_work_t *req) { /** * @param {Repository} callback */ -NAN_METHOD(GitSubmodule::Open) { - NanScope(); +Handle GitSubmodule::Open(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } OpenBaton* baton = new OpenBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->submoduleReference, args.This()); + baton->submoduleReference = Persistent::New(args.This()); baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, OpenWork, (uv_after_work_cb)OpenAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitSubmodule::OpenWork(uv_work_t *req) { @@ -605,7 +602,7 @@ void GitSubmodule::OpenWork(uv_work_t *req) { } void GitSubmodule::OpenAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; OpenBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -618,21 +615,21 @@ void GitSubmodule::OpenAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -648,24 +645,24 @@ void GitSubmodule::OpenAfterWork(uv_work_t *req) { /** */ -NAN_METHOD(GitSubmodule::Reload) { - NanScope(); +Handle GitSubmodule::Reload(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } ReloadBaton* baton = new ReloadBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->submoduleReference, args.This()); + baton->submoduleReference = Persistent::New(args.This()); baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, ReloadWork, (uv_after_work_cb)ReloadAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitSubmodule::ReloadWork(uv_work_t *req) { @@ -680,28 +677,28 @@ void GitSubmodule::ReloadWork(uv_work_t *req) { } void GitSubmodule::ReloadAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; ReloadBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -718,31 +715,31 @@ void GitSubmodule::ReloadAfterWork(uv_work_t *req) { /** * @param {Number} status */ -NAN_METHOD(GitSubmodule::Status) { - NanScope(); +Handle GitSubmodule::Status(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsInt32()) { - return NanThrowError(String::New("Number status is required.")); + return ThrowException(Exception::Error(String::New("Number status is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } StatusBaton* baton = new StatusBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->statusReference, args[0]); - unsigned int * from_status; - from_status = (unsigned int *) args[0]->ToInt32()->Value(); - baton->status = from_status; - NanAssignPersistent(Value, baton->submoduleReference, args.This()); + baton->statusReference = Persistent::New(args[0]); + unsigned int * from_status; + from_status = (unsigned int *) args[0]->ToInt32()->Value(); + baton->status = from_status; + baton->submoduleReference = Persistent::New(args.This()); baton->submodule = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, StatusWork, (uv_after_work_cb)StatusAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitSubmodule::StatusWork(uv_work_t *req) { @@ -758,28 +755,28 @@ void GitSubmodule::StatusWork(uv_work_t *req) { } void GitSubmodule::StatusAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; StatusBaton *baton = static_cast(req->data); TryCatch try_catch; if (baton->error_code == GIT_OK) { - Handle result = NanNewLocal(Undefined()); + Handle result = Local::New(Undefined()); Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -792,4 +789,4 @@ void GitSubmodule::StatusAfterWork(uv_work_t *req) { delete baton; } -Persistent GitSubmodule::constructor_template; +Persistent GitSubmodule::constructor_template; diff --git a/src/tag.cc b/src/tag.cc index 4423559e6..08b099d41 100644 --- a/src/tag.cc +++ b/src/tag.cc @@ -27,12 +27,12 @@ GitTag::~GitTag() { } void GitTag::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Tag")); + tpl->SetClassName(String::NewSymbol("Tag")); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "getTarget", GetTarget); @@ -44,30 +44,27 @@ void GitTag::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "peel", Peel); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Tag"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Tag"), constructor_template); } -NAN_METHOD(GitTag::New) { - NanScope(); +Handle GitTag::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_tag is required.")); + return ThrowException(Exception::Error(String::New("git_tag is required."))); } - GitTag* object = new GitTag((git_tag *) External::Cast(*args[0])->Value()); + GitTag* object = new GitTag((git_tag *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitTag::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitTag::constructor_template->NewInstance(1, argv)); } git_tag *GitTag::GetValue() { @@ -78,8 +75,8 @@ git_tag *GitTag::GetValue() { /** * @return {Oid} result */ -NAN_METHOD(GitTag::Oid) { - NanScope(); +Handle GitTag::Oid(const Arguments& args) { + HandleScope scope; const git_oid * result = git_tag_id( @@ -95,7 +92,7 @@ NAN_METHOD(GitTag::Oid) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -103,24 +100,24 @@ NAN_METHOD(GitTag::Oid) { /** * @param {Object} callback */ -NAN_METHOD(GitTag::GetTarget) { - NanScope(); +Handle GitTag::GetTarget(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetTargetBaton* baton = new GetTargetBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->tagReference, args.This()); + baton->tagReference = Persistent::New(args.This()); baton->tag = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[0])); + baton->callback = Persistent::New(Local::Cast(args[0])); uv_queue_work(uv_default_loop(), &baton->request, GetTargetWork, (uv_after_work_cb)GetTargetAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitTag::GetTargetWork(uv_work_t *req) { @@ -136,7 +133,7 @@ void GitTag::GetTargetWork(uv_work_t *req) { } void GitTag::GetTargetAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetTargetBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -149,21 +146,21 @@ void GitTag::GetTargetAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -178,8 +175,9 @@ void GitTag::GetTargetAfterWork(uv_work_t *req) { /** * @return {Oid} result */ -NAN_METHOD(GitTag::TargetId) { - NanScope(); +Handle GitTag::TargetId(const Arguments& args) { + HandleScope scope; + const git_oid * result = git_tag_target_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -194,14 +192,14 @@ NAN_METHOD(GitTag::TargetId) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitTag::TargetType) { - NanScope(); +Handle GitTag::TargetType(const Arguments& args) { + HandleScope scope; git_otype result = git_tag_target_type( @@ -210,14 +208,14 @@ NAN_METHOD(GitTag::TargetType) { Handle to; to = Int32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitTag::Name) { - NanScope(); +Handle GitTag::Name(const Arguments& args) { + HandleScope scope; const char * result = git_tag_name( @@ -226,14 +224,14 @@ NAN_METHOD(GitTag::Name) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Signature} result */ -NAN_METHOD(GitTag::Tagger) { - NanScope(); +Handle GitTag::Tagger(const Arguments& args) { + HandleScope scope; const git_signature * result = git_tag_tagger( @@ -249,14 +247,14 @@ NAN_METHOD(GitTag::Tagger) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {String} result */ -NAN_METHOD(GitTag::Message) { - NanScope(); +Handle GitTag::Message(const Arguments& args) { + HandleScope scope; const char * result = git_tag_message( @@ -265,17 +263,17 @@ NAN_METHOD(GitTag::Message) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @param {Tag} tag * @return {Object} tag_target_out */ -NAN_METHOD(GitTag::Peel) { - NanScope(); +Handle GitTag::Peel(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Tag tag is required.")); + return ThrowException(Exception::Error(String::New("Tag tag is required."))); } git_object * tag_target_out = 0; @@ -288,9 +286,9 @@ NAN_METHOD(GitTag::Peel) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -300,7 +298,7 @@ NAN_METHOD(GitTag::Peel) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } -Persistent GitTag::constructor_template; +Persistent GitTag::constructor_template; diff --git a/src/threads.cc b/src/threads.cc index 3aa2edaff..020600206 100755 --- a/src/threads.cc +++ b/src/threads.cc @@ -15,47 +15,45 @@ using namespace v8; using namespace node; void GitThreads::Initialize(Handle target) { - NanScope(); + HandleScope scope; - Persistent object; + Persistent object = Persistent::New(Object::New()); - NanAssignPersistent(Object, object, Object::New()); + object->Set(String::NewSymbol("init"), FunctionTemplate::New(Init)->GetFunction()); + object->Set(String::NewSymbol("shutdown"), FunctionTemplate::New(Shutdown)->GetFunction()); - NanPersistentToLocal(object)->Set(String::NewSymbol("init"), FunctionTemplate::New(Init)->GetFunction()); - NanPersistentToLocal(object)->Set(String::NewSymbol("shutdown"), FunctionTemplate::New(Shutdown)->GetFunction()); - - target->Set(String::NewSymbol("Threads"), NanPersistentToLocal(object)); + target->Set(String::NewSymbol("Threads"), object); } /** */ -NAN_METHOD(GitThreads::Init) { - NanScope(); +Handle GitThreads::Init(const Arguments& args) { + HandleScope scope; int result = git_threads_init( ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } /** */ -NAN_METHOD(GitThreads::Shutdown) { - NanScope(); +Handle GitThreads::Shutdown(const Arguments& args) { + HandleScope scope; git_threads_shutdown( ); - NanReturnUndefined(); + return Undefined(); } diff --git a/src/time.cc b/src/time.cc index 4196ec83e..b03a49c84 100644 --- a/src/time.cc +++ b/src/time.cc @@ -23,66 +23,65 @@ GitTime::~GitTime() { } void GitTime::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Time")); - + tpl->SetClassName(String::NewSymbol("Time")); + + NODE_SET_PROTOTYPE_METHOD(tpl, "time", Time); NODE_SET_PROTOTYPE_METHOD(tpl, "offset", Offset); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Time"), tpl->GetFunction()); + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Time"), constructor_template); } -NAN_METHOD(GitTime::New) { - NanScope(); +Handle GitTime::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_time is required.")); + return ThrowException(Exception::Error(String::New("git_time is required."))); } - GitTime* object = new GitTime((git_time *) External::Cast(*args[0])->Value()); + GitTime* object = new GitTime((git_time *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitTime::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitTime::constructor_template->NewInstance(1, argv)); } git_time *GitTime::GetValue() { return this->raw; } -NAN_METHOD(GitTime::Time) { - NanScope(); + +Handle GitTime::Time(const Arguments& args) { + HandleScope scope; Handle to; git_time_t time = ObjectWrap::Unwrap(args.This())->GetValue()->time; to = Integer::New(time); - NanReturnValue(to); + return scope.Close(to); } -NAN_METHOD(GitTime::Offset) { - NanScope(); +Handle GitTime::Offset(const Arguments& args) { + HandleScope scope; Handle to; int offset = ObjectWrap::Unwrap(args.This())->GetValue()->offset; to = Int32::New(offset); - NanReturnValue(to); + return scope.Close(to); } -Persistent GitTime::constructor_template; +Persistent GitTime::constructor_template; diff --git a/src/tree.cc b/src/tree.cc index 6798183ae..8a2661ce1 100755 --- a/src/tree.cc +++ b/src/tree.cc @@ -30,13 +30,13 @@ GitTree::~GitTree() { } void GitTree::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("Tree")); - + tpl->SetClassName(String::NewSymbol("Tree")); + NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "size", Size); NODE_SET_PROTOTYPE_METHOD(tpl, "entryByName", EntryByName); @@ -48,30 +48,28 @@ void GitTree::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "diffIndex", DiffIndex); NODE_SET_PROTOTYPE_METHOD(tpl, "diffWorkDir", DiffWorkDir); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("Tree"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("Tree"), constructor_template); } -NAN_METHOD(GitTree::New) { - NanScope(); +Handle GitTree::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_tree is required.")); + return ThrowException(Exception::Error(String::New("git_tree is required."))); } - GitTree* object = new GitTree((git_tree *) External::Cast(*args[0])->Value()); + GitTree* object = new GitTree((git_tree *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitTree::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitTree::constructor_template->NewInstance(1, argv)); } git_tree *GitTree::GetValue() { @@ -82,9 +80,9 @@ git_tree *GitTree::GetValue() { /** * @return {Oid} result */ -NAN_METHOD(GitTree::Oid) { - NanScope(); - +Handle GitTree::Oid(const Arguments& args) { + HandleScope scope; + const git_oid * result = git_tree_id( ObjectWrap::Unwrap(args.This())->GetValue() @@ -99,14 +97,14 @@ NAN_METHOD(GitTree::Oid) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitTree::Size) { - NanScope(); +Handle GitTree::Size(const Arguments& args) { + HandleScope scope; size_t result = git_tree_entrycount( @@ -115,17 +113,17 @@ NAN_METHOD(GitTree::Size) { Handle to; to = Uint32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} filename * @return {TreeEntry} result */ -NAN_METHOD(GitTree::EntryByName) { - NanScope(); +Handle GitTree::EntryByName(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String filename is required.")); + return ThrowException(Exception::Error(String::New("String filename is required."))); } const char * from_filename; @@ -147,21 +145,21 @@ NAN_METHOD(GitTree::EntryByName) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {Number} idx * @return {TreeEntry} result */ -NAN_METHOD(GitTree::EntryByIndex) { - NanScope(); +Handle GitTree::EntryByIndex(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsUint32()) { - return NanThrowError(String::New("Number idx is required.")); + return ThrowException(Exception::Error(String::New("Number idx is required."))); } size_t from_idx; - from_idx = (size_t) args[0]->ToUint32()->Value(); + from_idx = (size_t) args[0]->ToUint32()->Value(); const git_tree_entry * result = git_tree_entry_byindex( ObjectWrap::Unwrap(args.This())->GetValue() @@ -177,17 +175,17 @@ NAN_METHOD(GitTree::EntryByIndex) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {Oid} oid * @return {TreeEntry} result */ -NAN_METHOD(GitTree::EntryByOid) { - NanScope(); +Handle GitTree::EntryByOid(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Oid oid is required.")); + return ThrowException(Exception::Error(String::New("Oid oid is required."))); } const git_oid * from_oid; @@ -207,7 +205,7 @@ NAN_METHOD(GitTree::EntryByOid) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -216,32 +214,32 @@ NAN_METHOD(GitTree::EntryByOid) { * @param {String} path * @param {TreeEntry} callback */ -NAN_METHOD(GitTree::GetEntry) { - NanScope(); +Handle GitTree::GetEntry(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String path is required.")); + return ThrowException(Exception::Error(String::New("String path is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetEntryBaton* baton = new GetEntryBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->rootReference, args.This()); + baton->rootReference = Persistent::New(args.This()); baton->root = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->pathReference, args[0]); - const char * from_path; - String::Utf8Value path(args[0]->ToString()); - from_path = strdup(*path); - baton->path = from_path; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->pathReference = Persistent::New(args[0]); + const char * from_path; + String::Utf8Value path(args[0]->ToString()); + from_path = strdup(*path); + baton->path = from_path; + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, GetEntryWork, (uv_after_work_cb)GetEntryAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitTree::GetEntryWork(uv_work_t *req) { @@ -258,7 +256,7 @@ void GitTree::GetEntryWork(uv_work_t *req) { } void GitTree::GetEntryAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetEntryBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -271,21 +269,21 @@ void GitTree::GetEntryAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -302,8 +300,8 @@ void GitTree::GetEntryAfterWork(uv_work_t *req) { /** * @return {TreeBuilder} out */ -NAN_METHOD(GitTree::Builder) { - NanScope(); +Handle GitTree::Builder(const Arguments& args) { + HandleScope scope; git_treebuilder * out = 0; @@ -313,9 +311,9 @@ NAN_METHOD(GitTree::Builder) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -325,7 +323,7 @@ NAN_METHOD(GitTree::Builder) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -336,46 +334,46 @@ NAN_METHOD(GitTree::Builder) { * @param {DiffOptions} opts * @param {DiffList} callback */ -NAN_METHOD(GitTree::DiffTree) { - NanScope(); +Handle GitTree::DiffTree(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Repository repo is required.")); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError(String::New("Tree new_tree is required.")); + return ThrowException(Exception::Error(String::New("Tree new_tree is required."))); } if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } DiffTreeBaton* baton = new DiffTreeBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args[0]); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - NanAssignPersistent(Value, baton->old_treeReference, args.This()); + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->old_treeReference = Persistent::New(args.This()); baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->new_treeReference, args[1]); - git_tree * from_new_tree; - from_new_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - baton->new_tree = from_new_tree; - NanAssignPersistent(Value, baton->optsReference, args[2]); - const git_diff_options * from_opts; - if (args[2]->IsObject()) { - from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - } else { - from_opts = 0; - } - baton->opts = from_opts; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[3])); + baton->new_treeReference = Persistent::New(args[1]); + git_tree * from_new_tree; + from_new_tree = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + baton->new_tree = from_new_tree; + baton->optsReference = Persistent::New(args[2]); + const git_diff_options * from_opts; + if (args[2]->IsObject()) { + from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + } else { + from_opts = 0; + } + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, DiffTreeWork, (uv_after_work_cb)DiffTreeAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitTree::DiffTreeWork(uv_work_t *req) { @@ -394,7 +392,7 @@ void GitTree::DiffTreeWork(uv_work_t *req) { } void GitTree::DiffTreeAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; DiffTreeBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -407,21 +405,21 @@ void GitTree::DiffTreeAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -444,47 +442,47 @@ void GitTree::DiffTreeAfterWork(uv_work_t *req) { * @param {DiffOptions} opts * @param {DiffList} callback */ -NAN_METHOD(GitTree::DiffIndex) { - NanScope(); +Handle GitTree::DiffIndex(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Repository repo is required.")); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 3 || !args[3]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } DiffIndexBaton* baton = new DiffIndexBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args[0]); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - NanAssignPersistent(Value, baton->old_treeReference, args.This()); + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->old_treeReference = Persistent::New(args.This()); baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->indexReference, args[1]); - git_index * from_index; - if (args[1]->IsObject()) { - from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - } else { - from_index = 0; - } - baton->index = from_index; - NanAssignPersistent(Value, baton->optsReference, args[2]); - const git_diff_options * from_opts; - if (args[2]->IsObject()) { - from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); - } else { - from_opts = 0; - } - baton->opts = from_opts; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[3])); + baton->indexReference = Persistent::New(args[1]); + git_index * from_index; + if (args[1]->IsObject()) { + from_index = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + } else { + from_index = 0; + } + baton->index = from_index; + baton->optsReference = Persistent::New(args[2]); + const git_diff_options * from_opts; + if (args[2]->IsObject()) { + from_opts = ObjectWrap::Unwrap(args[2]->ToObject())->GetValue(); + } else { + from_opts = 0; + } + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[3])); uv_queue_work(uv_default_loop(), &baton->request, DiffIndexWork, (uv_after_work_cb)DiffIndexAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitTree::DiffIndexWork(uv_work_t *req) { @@ -503,7 +501,7 @@ void GitTree::DiffIndexWork(uv_work_t *req) { } void GitTree::DiffIndexAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; DiffIndexBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -516,21 +514,21 @@ void GitTree::DiffIndexAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -552,39 +550,39 @@ void GitTree::DiffIndexAfterWork(uv_work_t *req) { * @param {DiffOptions} opts * @param {DiffList} callback */ -NAN_METHOD(GitTree::DiffWorkDir) { - NanScope(); +Handle GitTree::DiffWorkDir(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Repository repo is required.")); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 2 || !args[2]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } DiffWorkDirBaton* baton = new DiffWorkDirBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args[0]); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - NanAssignPersistent(Value, baton->old_treeReference, args.This()); + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->old_treeReference = Persistent::New(args.This()); baton->old_tree = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Value, baton->optsReference, args[1]); - const git_diff_options * from_opts; - if (args[1]->IsObject()) { - from_opts = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); - } else { - from_opts = 0; - } - baton->opts = from_opts; - NanAssignPersistent(Function, baton->callback, Local::Cast(args[2])); + baton->optsReference = Persistent::New(args[1]); + const git_diff_options * from_opts; + if (args[1]->IsObject()) { + from_opts = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); + } else { + from_opts = 0; + } + baton->opts = from_opts; + baton->callback = Persistent::New(Local::Cast(args[2])); uv_queue_work(uv_default_loop(), &baton->request, DiffWorkDirWork, (uv_after_work_cb)DiffWorkDirAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitTree::DiffWorkDirWork(uv_work_t *req) { @@ -602,7 +600,7 @@ void GitTree::DiffWorkDirWork(uv_work_t *req) { } void GitTree::DiffWorkDirAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; DiffWorkDirBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -615,21 +613,21 @@ void GitTree::DiffWorkDirAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -643,4 +641,4 @@ void GitTree::DiffWorkDirAfterWork(uv_work_t *req) { delete baton; } -Persistent GitTree::constructor_template; +Persistent GitTree::constructor_template; diff --git a/src/tree_builder.cc b/src/tree_builder.cc index 59ccd63ba..3a6b6585f 100644 --- a/src/tree_builder.cc +++ b/src/tree_builder.cc @@ -30,13 +30,13 @@ GitTreeBuilder::~GitTreeBuilder() { } void GitTreeBuilder::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("TreeBuilder")); - + tpl->SetClassName(String::NewSymbol("TreeBuilder")); + NODE_SET_METHOD(tpl, "create", Create); NODE_SET_PROTOTYPE_METHOD(tpl, "clear", Clear); NODE_SET_METHOD(tpl, "size", Size); @@ -45,30 +45,28 @@ void GitTreeBuilder::Initialize(Handle target) { NODE_SET_PROTOTYPE_METHOD(tpl, "gitTreebuilderRemove", GitTreebuilderRemove); NODE_SET_PROTOTYPE_METHOD(tpl, "write", Write); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("TreeBuilder"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("TreeBuilder"), constructor_template); } -NAN_METHOD(GitTreeBuilder::New) { - NanScope(); +Handle GitTreeBuilder::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_treebuilder is required.")); + return ThrowException(Exception::Error(String::New("git_treebuilder is required."))); } - GitTreeBuilder* object = new GitTreeBuilder((git_treebuilder *) External::Cast(*args[0])->Value()); + GitTreeBuilder* object = new GitTreeBuilder((git_treebuilder *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitTreeBuilder::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitTreeBuilder::constructor_template->NewInstance(1, argv)); } git_treebuilder *GitTreeBuilder::GetValue() { @@ -80,8 +78,8 @@ git_treebuilder *GitTreeBuilder::GetValue() { * @param {Tree} source * @return {TreeBuilder} out */ -NAN_METHOD(GitTreeBuilder::Create) { - NanScope(); +Handle GitTreeBuilder::Create(const Arguments& args) { + HandleScope scope; git_treebuilder * out = 0; const git_tree * from_source; @@ -97,9 +95,9 @@ NAN_METHOD(GitTreeBuilder::Create) { ); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -109,16 +107,16 @@ NAN_METHOD(GitTreeBuilder::Create) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {TreeBuilder} bld */ -NAN_METHOD(GitTreeBuilder::Clear) { - NanScope(); +Handle GitTreeBuilder::Clear(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("TreeBuilder bld is required.")); + return ThrowException(Exception::Error(String::New("TreeBuilder bld is required."))); } git_treebuilder * from_bld; @@ -128,14 +126,14 @@ NAN_METHOD(GitTreeBuilder::Clear) { from_bld ); - NanReturnUndefined(); + return Undefined(); } /** * @return {Number} result */ -NAN_METHOD(GitTreeBuilder::Size) { - NanScope(); +Handle GitTreeBuilder::Size(const Arguments& args) { + HandleScope scope; unsigned int result = git_treebuilder_entrycount( @@ -144,17 +142,17 @@ NAN_METHOD(GitTreeBuilder::Size) { Handle to; to = Uint32::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} filename * @return {TreeEntry} result */ -NAN_METHOD(GitTreeBuilder::Get) { - NanScope(); +Handle GitTreeBuilder::Get(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String filename is required.")); + return ThrowException(Exception::Error(String::New("String filename is required."))); } const char * from_filename; @@ -176,7 +174,7 @@ NAN_METHOD(GitTreeBuilder::Get) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** @@ -185,16 +183,16 @@ NAN_METHOD(GitTreeBuilder::Get) { * @param {Number} filemode * @return {TreeEntry} out */ -NAN_METHOD(GitTreeBuilder::Insert) { - NanScope(); +Handle GitTreeBuilder::Insert(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String filename is required.")); + return ThrowException(Exception::Error(String::New("String filename is required."))); } if (args.Length() == 1 || !args[1]->IsObject()) { - return NanThrowError(String::New("Oid id is required.")); + return ThrowException(Exception::Error(String::New("Oid id is required."))); } if (args.Length() == 2 || !args[2]->IsNumber()) { - return NanThrowError(String::New("Number filemode is required.")); + return ThrowException(Exception::Error(String::New("Number filemode is required."))); } const git_tree_entry * out = 0; @@ -204,7 +202,7 @@ NAN_METHOD(GitTreeBuilder::Insert) { const git_oid * from_id; from_id = ObjectWrap::Unwrap(args[1]->ToObject())->GetValue(); git_filemode_t from_filemode; - from_filemode = (git_filemode_t) args[2]->ToNumber()->Value(); + from_filemode = (git_filemode_t) (int) args[2]->ToNumber()->Value(); int result = git_treebuilder_insert( &out @@ -216,9 +214,9 @@ NAN_METHOD(GitTreeBuilder::Insert) { free((void *)from_filename); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } @@ -231,16 +229,16 @@ NAN_METHOD(GitTreeBuilder::Insert) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @param {String} filename */ -NAN_METHOD(GitTreeBuilder::GitTreebuilderRemove) { - NanScope(); +Handle GitTreeBuilder::GitTreebuilderRemove(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsString()) { - return NanThrowError(String::New("String filename is required.")); + return ThrowException(Exception::Error(String::New("String filename is required."))); } const char * from_filename; @@ -254,13 +252,13 @@ NAN_METHOD(GitTreeBuilder::GitTreebuilderRemove) { free((void *)from_filename); if (result != GIT_OK) { if (giterr_last()) { - return NanThrowError(String::New(giterr_last()->message)); + return ThrowException(Exception::Error(String::New(giterr_last()->message))); } else { - return NanThrowError(String::New("Unkown Error")); + return ThrowException(Exception::Error(String::New("Unkown Error"))); } } - NanReturnUndefined(); + return Undefined(); } #include "../include/functions/copy.h" @@ -269,14 +267,14 @@ NAN_METHOD(GitTreeBuilder::GitTreebuilderRemove) { * @param {Repository} repo * @param {Oid} callback */ -NAN_METHOD(GitTreeBuilder::Write) { - NanScope(); +Handle GitTreeBuilder::Write(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Repository repo is required.")); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } WriteBaton* baton = new WriteBaton; @@ -284,17 +282,17 @@ NAN_METHOD(GitTreeBuilder::Write) { baton->error = NULL; baton->request.data = baton; baton->id = (git_oid *)malloc(sizeof(git_oid )); - NanAssignPersistent(Value, baton->repoReference, args[0]); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - NanAssignPersistent(Value, baton->bldReference, args.This()); + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->bldReference = Persistent::New(args.This()); baton->bld = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, WriteWork, (uv_after_work_cb)WriteAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitTreeBuilder::WriteWork(uv_work_t *req) { @@ -311,7 +309,7 @@ void GitTreeBuilder::WriteWork(uv_work_t *req) { } void GitTreeBuilder::WriteAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; WriteBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -324,21 +322,21 @@ void GitTreeBuilder::WriteAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } free(baton->id); } @@ -352,4 +350,4 @@ void GitTreeBuilder::WriteAfterWork(uv_work_t *req) { delete baton; } -Persistent GitTreeBuilder::constructor_template; +Persistent GitTreeBuilder::constructor_template; diff --git a/src/tree_entry.cc b/src/tree_entry.cc index baa5a1966..2d761e611 100755 --- a/src/tree_entry.cc +++ b/src/tree_entry.cc @@ -26,43 +26,41 @@ GitTreeEntry::~GitTreeEntry() { } void GitTreeEntry::Initialize(Handle target) { - NanScope(); + HandleScope scope; Local tpl = FunctionTemplate::New(New); tpl->InstanceTemplate()->SetInternalFieldCount(1); - tpl->SetClassName(NanSymbol("TreeEntry")); - + tpl->SetClassName(String::NewSymbol("TreeEntry")); + NODE_SET_PROTOTYPE_METHOD(tpl, "name", Name); NODE_SET_PROTOTYPE_METHOD(tpl, "oid", Oid); NODE_SET_PROTOTYPE_METHOD(tpl, "type", Type); NODE_SET_PROTOTYPE_METHOD(tpl, "filemode", filemode); NODE_SET_PROTOTYPE_METHOD(tpl, "getObject", GetObject); - NanAssignPersistent(FunctionTemplate, constructor_template, tpl); - target->Set(String::NewSymbol("TreeEntry"), tpl->GetFunction()); + + constructor_template = Persistent::New(tpl->GetFunction()); + target->Set(String::NewSymbol("TreeEntry"), constructor_template); } -NAN_METHOD(GitTreeEntry::New) { - NanScope(); +Handle GitTreeEntry::New(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsExternal()) { - return NanThrowError(String::New("git_tree_entry is required.")); + return ThrowException(Exception::Error(String::New("git_tree_entry is required."))); } - GitTreeEntry* object = new GitTreeEntry((git_tree_entry *) External::Cast(*args[0])->Value()); + GitTreeEntry* object = new GitTreeEntry((git_tree_entry *) External::Unwrap(args[0])); object->Wrap(args.This()); - NanReturnValue(args.This()); + return scope.Close(args.This()); } Handle GitTreeEntry::New(void *raw) { - NanScope(); + HandleScope scope; Handle argv[1] = { External::New((void *)raw) }; - Local instance; - Local constructorHandle = NanPersistentToLocal(constructor_template); - instance = constructorHandle->GetFunction()->NewInstance(1, argv); - return scope.Close(instance); + return scope.Close(GitTreeEntry::constructor_template->NewInstance(1, argv)); } git_tree_entry *GitTreeEntry::GetValue() { @@ -73,8 +71,8 @@ git_tree_entry *GitTreeEntry::GetValue() { /** * @return {String} result */ -NAN_METHOD(GitTreeEntry::Name) { - NanScope(); +Handle GitTreeEntry::Name(const Arguments& args) { + HandleScope scope; const char * result = git_tree_entry_name( @@ -83,14 +81,14 @@ NAN_METHOD(GitTreeEntry::Name) { Handle to; to = String::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Oid} result */ -NAN_METHOD(GitTreeEntry::Oid) { - NanScope(); +Handle GitTreeEntry::Oid(const Arguments& args) { + HandleScope scope; const git_oid * result = git_tree_entry_id( @@ -106,14 +104,14 @@ NAN_METHOD(GitTreeEntry::Oid) { } else { to = Null(); } - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitTreeEntry::Type) { - NanScope(); +Handle GitTreeEntry::Type(const Arguments& args) { + HandleScope scope; git_otype result = git_tree_entry_type( @@ -122,14 +120,14 @@ NAN_METHOD(GitTreeEntry::Type) { Handle to; to = Number::New(result); - NanReturnValue(to); + return scope.Close(to); } /** * @return {Number} result */ -NAN_METHOD(GitTreeEntry::filemode) { - NanScope(); +Handle GitTreeEntry::filemode(const Arguments& args) { + HandleScope scope; git_filemode_t result = git_tree_entry_filemode( @@ -138,7 +136,7 @@ NAN_METHOD(GitTreeEntry::filemode) { Handle to; to = Number::New(result); - NanReturnValue(to); + return scope.Close(to); } #include "../include/functions/copy.h" @@ -147,31 +145,31 @@ NAN_METHOD(GitTreeEntry::filemode) { * @param {Repository} repo * @param {Object} callback */ -NAN_METHOD(GitTreeEntry::GetObject) { - NanScope(); +Handle GitTreeEntry::GetObject(const Arguments& args) { + HandleScope scope; if (args.Length() == 0 || !args[0]->IsObject()) { - return NanThrowError(String::New("Repository repo is required.")); + return ThrowException(Exception::Error(String::New("Repository repo is required."))); } if (args.Length() == 1 || !args[1]->IsFunction()) { - return NanThrowError(String::New("Callback is required and must be a Function.")); + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); } GetObjectBaton* baton = new GetObjectBaton; baton->error_code = GIT_OK; baton->error = NULL; baton->request.data = baton; - NanAssignPersistent(Value, baton->repoReference, args[0]); - git_repository * from_repo; - from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); - baton->repo = from_repo; - NanAssignPersistent(Value, baton->entryReference, args.This()); + baton->repoReference = Persistent::New(args[0]); + git_repository * from_repo; + from_repo = ObjectWrap::Unwrap(args[0]->ToObject())->GetValue(); + baton->repo = from_repo; + baton->entryReference = Persistent::New(args.This()); baton->entry = ObjectWrap::Unwrap(args.This())->GetValue(); - NanAssignPersistent(Function, baton->callback, Local::Cast(args[1])); + baton->callback = Persistent::New(Local::Cast(args[1])); uv_queue_work(uv_default_loop(), &baton->request, GetObjectWork, (uv_after_work_cb)GetObjectAfterWork); - NanReturnUndefined(); + return Undefined(); } void GitTreeEntry::GetObjectWork(uv_work_t *req) { @@ -188,7 +186,7 @@ void GitTreeEntry::GetObjectWork(uv_work_t *req) { } void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { - NanScope(); + HandleScope scope; GetObjectBaton *baton = static_cast(req->data); TryCatch try_catch; @@ -201,21 +199,21 @@ void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { } Handle result = to; Handle argv[2] = { - NanNewLocal(Null()), + Local::New(Null()), result }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 2, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); } else { if (baton->error) { Handle argv[1] = { Exception::Error(String::New(baton->error->message)) }; - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 1, argv); + baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); if (baton->error->message) free((void *)baton->error->message); free((void *)baton->error); } else { - NanPersistentToLocal(baton->callback)->Call(Context::GetCurrent()->Global(), 0, NULL); + baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL); } } @@ -228,4 +226,4 @@ void GitTreeEntry::GetObjectAfterWork(uv_work_t *req) { delete baton; } -Persistent GitTreeEntry::constructor_template; +Persistent GitTreeEntry::constructor_template; diff --git a/vendor/libgit2 b/vendor/libgit2 deleted file mode 160000 index a50086d17..000000000 --- a/vendor/libgit2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a50086d174658914d4d6462afbc83b02825b1f5b From 334d3e443e05515d662ca9167894912ff129d64e Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Wed, 30 Apr 2014 02:29:16 -0400 Subject: [PATCH 9/9] Add an appveyor configuration. --- appveyor.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..ed71effd5 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,23 @@ +# appveyor file +# http://www.appveyor.com/docs/appveyor-yml +project_id: "e5a5q75l9yfhnfv2" + +# build version format +version: "{build}" + +# fix lineendings in Windows +init: + - git config --global core.autocrlf input + +# what combinations to test +environment: + matrix: + - nodejs_version: 0.10 + - nodejs_version: 0.8 + +# Get the latest stable version of Node 0.STABLE.latest +install: + - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) + - npm install + +build: off