├── docs ├── .gitignore ├── blob.rst ├── tag.rst ├── tree.rst ├── commit.rst ├── gitindex.rst ├── remote.rst ├── refspec.rst ├── reference.rst ├── signature.rst ├── repository.rst ├── api.rst ├── index.rst ├── index.html ├── Makefile ├── conf.py └── resources │ └── base.css ├── .gitignore ├── deps ├── v8-convert │ └── cvv8 │ │ ├── detail │ │ ├── Makefile │ │ ├── doxygen_hack.hpp │ │ ├── tmp.hpp │ │ └── signature_core.hpp │ │ ├── Makefile │ │ ├── generator │ │ └── Signature.hpp │ │ ├── convert.hpp │ │ ├── invocable.hpp │ │ ├── signature.hpp │ │ ├── NativeToJSMap.hpp │ │ ├── v8-convert.hpp │ │ └── XTo.hpp └── libgit2.gyp ├── test ├── stress │ ├── index.js │ ├── runner.coffee │ ├── cached_object.coffee │ └── repository.coffee ├── runner.js ├── tree.js ├── test-common.js ├── gitteh.js ├── commit.js └── reference.js ├── src ├── blah.py ├── tag.h ├── blob.h ├── tree.h ├── commit.h ├── signature.h ├── index.h ├── baton.h ├── signature.cc ├── remote.h ├── baton.cc ├── thread.h ├── error.h ├── blob.cc ├── tag.cc ├── commit.cc ├── tree.cc ├── gitteh.cc ├── repository.h ├── index.cc ├── gitteh.h └── remote.cc ├── .gitmodules ├── LIBGIT2_BUGS.md ├── .travis.yml ├── .npmignore ├── examples ├── load_repository.js ├── load_reference.js ├── load_commit.js ├── load_commit_tree.js ├── load_blob.js ├── load_tag.js ├── show_remote.js ├── clone.js ├── display-commit-tree.js └── walk-revisions.js ├── lib ├── blob.js ├── signature.js ├── reference.js ├── tag.js ├── tree.js ├── commit.js ├── index.js ├── refspec.js ├── utils.js ├── gitteh.js ├── args.js ├── remote.js └── repository.js ├── .dntrc ├── binding.gyp ├── LICENSE ├── package.json ├── CHANGELOG.md ├── TODO.md ├── install.js ├── README.md └── .jscs.json /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build/ 2 | -------------------------------------------------------------------------------- /docs/blob.rst: -------------------------------------------------------------------------------- 1 | Blob 2 | ==== 3 | 4 | .. autoclass:: gitteh::Blob -------------------------------------------------------------------------------- /docs/tag.rst: -------------------------------------------------------------------------------- 1 | Tag 2 | === 3 | 4 | .. autoclass:: gitteh::Tag 5 | -------------------------------------------------------------------------------- /docs/tree.rst: -------------------------------------------------------------------------------- 1 | Tree 2 | ==== 3 | 4 | .. autoclass:: gitteh::Tree 5 | -------------------------------------------------------------------------------- /docs/commit.rst: -------------------------------------------------------------------------------- 1 | Commit 2 | ====== 3 | 4 | .. autoclass:: gitteh::Commit 5 | -------------------------------------------------------------------------------- /docs/gitindex.rst: -------------------------------------------------------------------------------- 1 | Index 2 | ===== 3 | 4 | .. autoclass:: gitteh::Index 5 | -------------------------------------------------------------------------------- /docs/remote.rst: -------------------------------------------------------------------------------- 1 | Remote 2 | ====== 3 | 4 | .. autoclass:: gitteh::Remote 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | node_modules/ 3 | test/repo/ 4 | npm-debug.log 5 | *.*~ 6 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/detail/Makefile: -------------------------------------------------------------------------------- 1 | all $(MAKECMDGOALS): 2 | $(MAKE) -C .. $@ 3 | -------------------------------------------------------------------------------- /docs/refspec.rst: -------------------------------------------------------------------------------- 1 | Refspec 2 | ======= 3 | 4 | .. autoclass:: gitteh::Refspec 5 | -------------------------------------------------------------------------------- /docs/reference.rst: -------------------------------------------------------------------------------- 1 | Reference 2 | ========= 3 | 4 | .. autoclass:: gitteh::Reference 5 | -------------------------------------------------------------------------------- /docs/signature.rst: -------------------------------------------------------------------------------- 1 | Signature 2 | ========= 3 | 4 | .. autoclass:: gitteh::Signature 5 | -------------------------------------------------------------------------------- /test/stress/index.js: -------------------------------------------------------------------------------- 1 | coffeescript = require("coffee-script"); 2 | require("./runner"); -------------------------------------------------------------------------------- /test/stress/runner.coffee: -------------------------------------------------------------------------------- 1 | require("./repository") -> 2 | console.log "Done!", arguments -------------------------------------------------------------------------------- /docs/repository.rst: -------------------------------------------------------------------------------- 1 | Repository 2 | ========== 3 | 4 | .. autoclass:: gitteh::Repository 5 | -------------------------------------------------------------------------------- /src/blah.py: -------------------------------------------------------------------------------- 1 | def hello(): 2 | """ 3 | Omgawd. 4 | """ 5 | 6 | print(":D") 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/libgit2"] 2 | path = deps/libgit2 3 | url = git://github.com/libgit2/libgit2.git 4 | -------------------------------------------------------------------------------- /LIBGIT2_BUGS.md: -------------------------------------------------------------------------------- 1 | * Saving a commit with an unsaved tree segfaults. 2 | 3 | * calling git_remote_download without first calling git_remote_connect segfaults -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # Travis-CI build for node-gitteh 2 | # see travis-ci.org for details 3 | 4 | language: node_js 5 | 6 | node_js: 7 | - 0.10 8 | - 0.8 9 | 10 | script: 11 | - npm test 12 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | build 2 | deps/libgit2 3 | .gitignore 4 | .npmignore 5 | TODO.md 6 | .gitmodules 7 | .travis.yml 8 | LIBGIT2_BUGS.md 9 | test/ 10 | examples/ 11 | docs/ 12 | CHANGELOG.md 13 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | EXAMPLE_DIR := ../../examples 4 | ifneq (,$(wildcard $(EXAMPLE_DIR)/Makefile)) 5 | $(sort all $(MAKECMDGOALS)): 6 | $(MAKE) -C ../../examples $@ 7 | endif 8 | 9 | -------------------------------------------------------------------------------- /docs/api.rst: -------------------------------------------------------------------------------- 1 | API 2 | === 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | blob 8 | commit 9 | gitindex 10 | reference 11 | refspec 12 | remote 13 | repository 14 | signature 15 | tag 16 | tree 17 | -------------------------------------------------------------------------------- /examples/load_repository.js: -------------------------------------------------------------------------------- 1 | var gitteh = require("../lib/gitteh"); 2 | var path = require("path"); 3 | 4 | gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { 5 | exports.repo = repo; 6 | console.log(repo); 7 | }); 8 | -------------------------------------------------------------------------------- /examples/load_reference.js: -------------------------------------------------------------------------------- 1 | var gitteh = require("../lib/gitteh"), 2 | path = require("path"); 3 | 4 | gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { 5 | repo.ref("HEAD", true, function(err, ref) { 6 | console.log(ref); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /src/tag.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_TAG_H 2 | #define GITTEH_TAG_H 3 | 4 | #include "gitteh.h" 5 | 6 | namespace gitteh { 7 | namespace Tag { 8 | void Init(Handle); 9 | Handle Create(git_tag*); 10 | } 11 | }; 12 | 13 | #endif // GITTEH_TAG_H 14 | -------------------------------------------------------------------------------- /src/blob.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_BLOB_H 2 | #define GITTEH_BLOB_H 3 | 4 | #include "nan.h" 5 | #include "gitteh.h" 6 | 7 | namespace gitteh { 8 | namespace Blob { 9 | void Init(Handle); 10 | Handle Create(git_blob*); 11 | } 12 | }; 13 | 14 | #endif // GITTEH_BLOB_H 15 | -------------------------------------------------------------------------------- /src/tree.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_TREE_H 2 | #define GITTEH_TREE_H 3 | 4 | #include "nan.h" 5 | #include "gitteh.h" 6 | 7 | namespace gitteh { 8 | namespace Tree { 9 | void Init(Handle); 10 | Handle Create(git_tree*); 11 | }; 12 | }; 13 | 14 | #endif // GITTEH_TREE_H 15 | -------------------------------------------------------------------------------- /src/commit.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_COMMIT_H 2 | #define GITTEH_COMMIT_H 3 | 4 | #include "gitteh.h" 5 | 6 | namespace gitteh { 7 | namespace Commit { 8 | void Init(Handle); 9 | Handle Create(git_commit*); 10 | }; 11 | }; // namespace gitteh 12 | 13 | #endif // GITTEH_COMMIT_H 14 | -------------------------------------------------------------------------------- /examples/load_commit.js: -------------------------------------------------------------------------------- 1 | var gitteh = require("../lib/gitteh"); 2 | var path = require("path"); 3 | 4 | gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { 5 | repo.commit("8a916d5fbce49f5780668a1ee780e0ef2e89360f", function (err, commit) { 6 | console.log(commit); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /examples/load_commit_tree.js: -------------------------------------------------------------------------------- 1 | var gitteh = require("../lib/gitteh"); 2 | var path = require("path"); 3 | 4 | gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { 5 | repo.commit("8a916d5fbce49f5780668a1ee780e0ef2e89360f", function (err, commit) { 6 | commit.tree(function(err, tree) { 7 | console.log(tree.entries); 8 | }); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /lib/blob.js: -------------------------------------------------------------------------------- 1 | function Blob (utils) { 2 | 3 | return function (repository, obj) { 4 | var _this = this; 5 | this.repository = repository; 6 | 7 | utils._immutable(_this, obj) 8 | .set('id') 9 | .set('data'); 10 | }; 11 | 12 | }; 13 | 14 | module.exports.all = function (Gitteh, utils) { 15 | Gitteh.Blob = Blob(utils); 16 | } 17 | -------------------------------------------------------------------------------- /examples/load_blob.js: -------------------------------------------------------------------------------- 1 | var gitteh = require("../lib/gitteh"), 2 | path = require("path"); 3 | 4 | gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { 5 | repo.blob("aa4306ebb3e97b8ec76136feab1bb5fcd096b28a", function(err, blob) { 6 | if(err) return console.error(err); 7 | console.log(blob); 8 | console.log(blob.data.toString("UTF-8")); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /lib/signature.js: -------------------------------------------------------------------------------- 1 | function Signature (utils) { 2 | 3 | return function (obj) { 4 | var _this = this; 5 | 6 | utils._immutable(_this, obj) 7 | .set('name') 8 | .set('email') 9 | .set('time') 10 | .set('offset'); 11 | }; 12 | 13 | }; 14 | 15 | module.exports.all = function (Gitteh, utils) { 16 | Gitteh.Signature = Signature(utils); 17 | }; 18 | -------------------------------------------------------------------------------- /test/runner.js: -------------------------------------------------------------------------------- 1 | const test = require('tape') 2 | , testCommon = require('./test-common') 3 | , gitteh = require('../lib/gitteh'); 4 | 5 | var testFiles = ['gitteh', 'tree', 'reference', 'commit']; 6 | 7 | test('setup common', testCommon.setUp); 8 | 9 | Object.keys(testFiles).forEach(function (fileName) { 10 | var testFile = testFiles[fileName]; 11 | require("./" + testFile).all(gitteh, test); 12 | }); 13 | -------------------------------------------------------------------------------- /examples/load_tag.js: -------------------------------------------------------------------------------- 1 | var gitteh = require("../lib/gitteh"), 2 | path = require("path"); 3 | 4 | gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { 5 | repo.tag("5eab735c859e9d808204532061a4316ea7d6b57a", function(err, tag) { 6 | if(err) return console.error(err); 7 | 8 | console.log(tag); 9 | 10 | tag.target(function(err, obj) { 11 | if(err) return console.error(err); 12 | console.log(obj); 13 | }); 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/signature.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_SIGNATURE_H 2 | #define GITTEH_SIGNATURE_H 3 | 4 | #include "nan.h" 5 | #include "gitteh.h" 6 | 7 | namespace gitteh { 8 | namespace Signature { 9 | void Init(); 10 | Handle Create(const git_signature *sig); 11 | }; 12 | }; 13 | 14 | namespace cvv8 { 15 | template<> 16 | struct NativeToJS { 17 | Handle operator() (git_signature const *sig) const; 18 | }; 19 | }; 20 | 21 | #endif // GITTEH_SIGNATURE_H 22 | -------------------------------------------------------------------------------- /test/stress/cached_object.coffee: -------------------------------------------------------------------------------- 1 | gitteh = require "../../lib/gitteh" 2 | {projectRepo} = require "../fixtures" 3 | 4 | 5 | gitteh.openRepository projectRepo.path, (err, repo) -> 6 | repo.exists projectRepo.secondCommit.id, (err, exists) -> 7 | repo.commit projectRepo.secondCommit.id, (err, commit) -> 8 | repo.commit projectRepo.secondCommit.id, (err, commit) -> 9 | console.log "sigh." 10 | 11 | #repo.blob projectRepo.secondCommit.wscriptBlob, (err, blob) -> 12 | # console.log blob -------------------------------------------------------------------------------- /examples/show_remote.js: -------------------------------------------------------------------------------- 1 | var gitteh = require("../lib/gitteh"); 2 | var path = require("path"); 3 | 4 | gitteh.openRepository(path.join(__dirname, ".."), function(err, repo) { 5 | exports.repo = repo; 6 | 7 | repo.remote("test", function(err, remote) { 8 | exports.remote = remote; 9 | 10 | remote.connect("fetch", function(err) { 11 | if(err) return console.error(err); 12 | console.log(remote); 13 | console.log(remote.connected); 14 | console.log(remote.refs); 15 | }); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. node-gitteh documentation master file, created by 2 | sphinx-quickstart on Tue Jul 23 14:08:21 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to node-gitteh's documentation! 7 | ======================================= 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | api 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | 23 | -------------------------------------------------------------------------------- /.dntrc: -------------------------------------------------------------------------------- 1 | ## DNT config file 2 | ## see https://github.com/rvagg/dnt 3 | 4 | NODE_VERSIONS="\ 5 | v0.10.22 \ 6 | v0.8.26 \ 7 | " 8 | OUTPUT_PREFIX="gitteh-" 9 | TEST_CMD="\ 10 | cd /dnt/ && \ 11 | npm install && \ 12 | node_modules/.bin/node-gyp --nodedir /usr/src/node/ rebuild && \ 13 | node_modules/.bin/tape test/runner.js; \ 14 | " 15 | COPY_CMD="rsync -aAXx /dnt-src/ /dnt/" 16 | LOG_OK_CMD="grep '.' | sed '/#\sok/ a ok' | tail -n1" 17 | -------------------------------------------------------------------------------- /lib/reference.js: -------------------------------------------------------------------------------- 1 | function Reference (utils) { 2 | 3 | return function (repo, nativeRef) { 4 | var _this = this 5 | , _priv = utils._createPrivate(_this) 6 | 7 | _priv.native = nativeRef; 8 | utils._immutable(_this, nativeRef) 9 | .set('name') 10 | .set('direct') 11 | .set('packed') 12 | .set('target'); 13 | 14 | utils._immutable(_this, {repo: repo}) 15 | .set('repo', 'repository'); 16 | 17 | }; 18 | }; 19 | 20 | module.exports.all = function (Gitteh, utils) { 21 | Gitteh.Reference = Reference(utils); 22 | }; 23 | -------------------------------------------------------------------------------- /lib/tag.js: -------------------------------------------------------------------------------- 1 | function Tag (Gitteh, utils) { 2 | 3 | return function (repository, obj) { 4 | var _this = this; 5 | this.repository = repository; 6 | 7 | obj.tagger = new Gitteh.Signature(obj.tagger); 8 | utils._immutable(_this, obj) 9 | .set('id') 10 | .set('name') 11 | .set('message') 12 | .set('tagger') 13 | .set('target', 'targetId') 14 | .set('type'); 15 | }; 16 | 17 | }; 18 | 19 | Tag.prototype.target = function () { 20 | return this.repository.object(this.targetId, this.type, cb); 21 | }; 22 | 23 | module.exports.all = function (Gitteh, utils) { 24 | Gitteh.Tag = Tag(Gitteh, utils); 25 | }; 26 | -------------------------------------------------------------------------------- /test/tree.js: -------------------------------------------------------------------------------- 1 | module.exports.all = function (gitteh, test) { 2 | 3 | test('can find tree of last commit on master...', function (t) { 4 | 5 | gitteh.openRepository('test/repo/workdir/.git', function (err, repo) { 6 | repo.commit("60e0dbe58458ed42d0191a1780d91e14b8b7e0be", function (err, tree) { 7 | 8 | repo.tree("40040fbc2c1bcfaa96c63e2a11aed480fccb6db8", function (err, tree) { 9 | t.ok(tree instanceof gitteh.Tree, 'is an instance of #gitteh.Tree'); 10 | t.equal(tree.id, '40040fbc2c1bcfaa96c63e2a11aed480fccb6db8', 'returns tree id'); 11 | 12 | t.end(); 13 | }); 14 | 15 | }); 16 | }); 17 | 18 | }); 19 | 20 | }; 21 | -------------------------------------------------------------------------------- /lib/tree.js: -------------------------------------------------------------------------------- 1 | function Tree (utils) { 2 | 3 | return function (repository, obj) { 4 | var _this = this; 5 | this.repository = repository; 6 | 7 | obj._entries = obj.entries; 8 | obj.entries = []; 9 | 10 | _ref = obj._entries; 11 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 12 | origEntry = _ref[_i]; 13 | obj.entries.push(entry = {}); 14 | 15 | utils._immutable(entry, origEntry) 16 | .set('id') 17 | .set('name') 18 | .set('type') 19 | .set('attributes'); 20 | } 21 | 22 | utils._immutable(_this, obj) 23 | .set('id') 24 | .set('entries'); 25 | 26 | }; 27 | }; 28 | 29 | module.exports.all = function (Gitteh, utils) { 30 | Gitteh.Tree = Tree(utils); 31 | }; 32 | -------------------------------------------------------------------------------- /test/test-common.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | , fs = require('fs') 3 | , exec = require('child_process').exec; 4 | 5 | var setupRepo = function (callback) { 6 | fs.exists(path.join(__dirname, 'repo'), function (exists) { 7 | 8 | if (exists) return callback(); 9 | 10 | fs.mkdir(path.join(__dirname, 'repo'), function () { 11 | exec('git clone https://github.com/libgit2/node-gitteh.git ./test/repo/workdir', function (err) { 12 | return callback(err); 13 | }); 14 | }); 15 | 16 | }); 17 | } 18 | 19 | , setup = function (t) { 20 | setupRepo(function (err) { 21 | if (err) t.notOk(err, 'setup returned an error'); 22 | t.end(); 23 | }); 24 | }; 25 | 26 | module.exports = { 27 | setUp : setup 28 | }; 29 | -------------------------------------------------------------------------------- /lib/commit.js: -------------------------------------------------------------------------------- 1 | function Commit (Gitteh, utils) { 2 | 3 | return function (repository, obj) { 4 | var _this = this; 5 | this.repository = repository; 6 | 7 | obj.author = new Gitteh.Signature(obj.author); 8 | obj.committer = new Gitteh.Signature(obj.committer); 9 | 10 | utils._immutable(_this, obj) 11 | .set('id') 12 | .set('tree', 'treeId') 13 | .set('parents') 14 | .set('message') 15 | .set('messageEncoding') 16 | .set('author') 17 | .set('committer'); 18 | }; 19 | 20 | }; 21 | 22 | Commit.prototype.tree = function (cb) { 23 | return this.repository.tree(this.treeId, cb); 24 | }; 25 | 26 | module.exports.all = function (Gitteh, utils) { 27 | Gitteh.Commit = Commit(Gitteh, utils); 28 | }; 29 | -------------------------------------------------------------------------------- /examples/clone.js: -------------------------------------------------------------------------------- 1 | var gitteh = require("../lib/gitteh"); 2 | var path = require("path"); 3 | var temp = require("temp"); 4 | 5 | var repoPath = temp.mkdirSync(); 6 | var repo = "http://github.com/libgit2/node-gitteh.git"; 7 | 8 | console.log("Cloning " + repo + " into " + repoPath); 9 | var clone = gitteh.clone(repo, repoPath); 10 | 11 | clone.on("status", function(bytes, total, done) { 12 | var updateString = "Transferred " + bytes + " bytes."; 13 | if(done > 0) updateString += " (" + done + "/" + total + " objects )" 14 | process.stdout.write("\r" + updateString); 15 | }); 16 | 17 | clone.on("complete", function(repo) { 18 | console.log("\n... Complete!"); 19 | console.log(repo); 20 | }); 21 | 22 | clone.on("error", function(err) { 23 | console.log("\n... Error during clone!"); 24 | console.error(err); 25 | }); -------------------------------------------------------------------------------- /src/index.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_INDEX_H 2 | #define GITTEH_INDEX_H 3 | 4 | #include "nan.h" 5 | #include "gitteh.h" 6 | 7 | namespace gitteh { 8 | class IndexBaton; 9 | class Repository; 10 | 11 | class Index : public ObjectWrap { 12 | public: 13 | static Persistent constructor_template; 14 | 15 | friend class IndexBaton; 16 | 17 | Index(Repository*, git_index*); 18 | ~Index(); 19 | static void Init(Handle); 20 | protected: 21 | static NAN_METHOD(New); 22 | static NAN_METHOD(ReadTree); 23 | static NAN_METHOD(Write); 24 | private: 25 | Repository *repository_; 26 | git_index *index_; 27 | 28 | static void AsyncReadTree(uv_work_t*); 29 | static void AsyncAfterReadTree(uv_work_t*); 30 | static void AsyncWrite(uv_work_t*); 31 | static void AsyncAfterWrite(uv_work_t*); 32 | }; 33 | 34 | } // namespace gitteh 35 | 36 | #endif // GITTEH_INDEX_H 37 | -------------------------------------------------------------------------------- /src/baton.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_BATON_H 2 | #define GITTEH_BATON_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace v8; 10 | using std::string; 11 | 12 | namespace gitteh { 13 | /** 14 | A Baton class specifically for libgit2 work. 15 | Users of this Baton are expected to copy a git_error into this class. 16 | */ 17 | class Baton { 18 | public: 19 | uv_work_t req; 20 | Persistent callback; 21 | int errorCode; 22 | string errorString; 23 | 24 | Baton(); 25 | ~Baton(); 26 | void setCallback(Handle val); 27 | bool isErrored(); 28 | void setError(const git_error *err); 29 | // Creates an Exception for this error state Baton. DON'T CALL OUTSIDE OF 30 | // V8 MAIN THREAD! :) 31 | Handle createV8Error(); 32 | void defaultCallback(); 33 | }; 34 | 35 | }; // namespace gitteh 36 | 37 | #endif // GITTEH_BATON_H 38 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/detail/doxygen_hack.hpp: -------------------------------------------------------------------------------- 1 | /** @file doxygen_hack.hpp 2 | 3 | doxygen REFUSES to document class templates i forward-decl, even when 4 | adding "@class" to the docs. Being the doc-pedant that i am, i felt 5 | compelled to work around that. With gcc we can add an empty body to 6 | those classes but MSVC doesn't like it. So we leave it out unless 7 | doxygen is building, and then doxygen needs to be configured with: 8 | 9 | - ENABLE_PREPROCESSING = YES 10 | - EXPAND_AS_DEFINED = DOXYGEN_FWD_DECL_KLUDGE 11 | 12 | and possibly: 13 | 14 | - MACRO_EXPANSION = YES 15 | 16 | and/or: 17 | 18 | - EXPAND_ONLY_PREDEF = YES 19 | */ 20 | #if !defined(DOXYGEN) 21 | # if !defined DOXYGEN_FWD_DECL_KLUDGE 22 | # define DOXYGEN_FWD_DECL_KLUDGE 23 | # endif 24 | #else 25 | # if !defined DOXYGEN_FWD_DECL_KLUDGE 26 | # define DOXYGEN_FWD_DECL_KLUDGE {} 27 | # endif 28 | #endif 29 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'targets': [ 3 | { 4 | 'target_name': 'gitteh', 5 | 6 | 'sources': [ 7 | 'src/gitteh.cc', 8 | 'src/signature.cc', 9 | 'src/repository.cc', 10 | 'src/baton.cc', 11 | 'src/commit.cc', 12 | 'src/tree.cc', 13 | 'src/blob.cc', 14 | 'src/tag.cc', 15 | 'src/remote.cc', 16 | 'src/index.cc', 17 | ], 18 | 19 | 'todosources': [ 20 | 'src/index_entry.cc', 21 | 'src/tag.cc', 22 | 'src/rev_walker.cc', 23 | 'src/ref.cc', 24 | ], 25 | 26 | 'dependencies': [ 27 | '<(module_root_dir)/deps/libgit2.gyp:libgit2' 28 | ], 29 | 30 | 'include_dirs': [ 31 | 'deps/v8-convert', 32 | " name_symbol; 4 | static Persistent email_symbol; 5 | static Persistent time_symbol; 6 | static Persistent offset_symbol; 7 | 8 | namespace gitteh { 9 | namespace Signature { 10 | void Init() { 11 | name_symbol = NODE_PSYMBOL("name"); 12 | email_symbol = NODE_PSYMBOL("email"); 13 | time_symbol = NODE_PSYMBOL("time"); 14 | offset_symbol = NODE_PSYMBOL("offset"); 15 | } 16 | }; 17 | }; 18 | 19 | namespace cvv8 { 20 | Handle NativeToJS::operator() (git_signature const *sig) const { 21 | NanEscapableScope(); 22 | Handle o = NanNew(); 23 | o->Set(name_symbol, CastToJS(sig->name)); 24 | o->Set(email_symbol, CastToJS(sig->email)); 25 | o->Set(time_symbol, Date::New(sig->when.time * 1000)); 26 | o->Set(offset_symbol, CastToJS(sig->when.offset)); 27 | return NanEscapeScope(o); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | function Index (utils, args) { 2 | 3 | return function (nativeIndex) { 4 | var _this = this; 5 | this.utils = utils; 6 | this.args = args; 7 | 8 | var _priv = utils._createPrivate(_this); 9 | 10 | _priv.native = nativeIndex; 11 | }; 12 | 13 | }; 14 | 15 | Index.prototype.readTree = function () { 16 | var _this = this 17 | , _priv = this.utils._getPrivate(_this) 18 | , _ref = this.args({ 19 | id: { 20 | type: "oid" 21 | }, 22 | cb: { 23 | type: "function" 24 | } 25 | }) 26 | , id = _ref[0] 27 | , cb = _ref[1]; 28 | 29 | return _priv.native.readTree(id, cb); 30 | }; 31 | 32 | Index.prototype.write = function () { 33 | var _this = this 34 | , _priv = this.utils._getPrivate(_this) 35 | , _ref = this.args({ 36 | cb: { 37 | type: "function" 38 | } 39 | }) 40 | , cb = _ref[1]; 41 | 42 | return _priv.native.write(cb); 43 | }; 44 | 45 | module.exports.all = function (Gitteh, utils, args) { 46 | Gitteh.Index = Index(utils, args); 47 | } 48 | -------------------------------------------------------------------------------- /src/remote.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_REMOTE_H 2 | #define GITTEH_REMOTE_H 3 | 4 | #include "nan.h" 5 | #include "gitteh.h" 6 | 7 | namespace gitteh { 8 | class RemoteBaton; 9 | 10 | class Remote : public ObjectWrap { 11 | public: 12 | friend class RemoteBaton; 13 | 14 | static Persistent constructor_template; 15 | static void Init(Handle); 16 | Remote(git_remote*); 17 | ~Remote(); 18 | 19 | protected: 20 | static NAN_METHOD(New); 21 | static NAN_METHOD(UpdateTips); 22 | static NAN_METHOD(Connect); 23 | static NAN_METHOD(Download); 24 | 25 | private: 26 | git_remote *remote_; 27 | git_transfer_progress progress_; 28 | git_off_t downloadBytes_; 29 | 30 | static NAN_GETTER(GetStats); 31 | static void AsyncUpdateTips(uv_work_t*); 32 | static void AsyncAfterUpdateTips(uv_work_t*); 33 | static void AsyncConnect(uv_work_t*); 34 | static void AsyncAfterConnect(uv_work_t*); 35 | static int DownloadTransferProgressCallback(const git_transfer_progress*, void*); 36 | static void AsyncDownload(uv_work_t*); 37 | static void AsyncAfterDownload(uv_work_t*); 38 | }; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2010 Sam Day 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gitteh", 3 | "version": "0.17.4", 4 | "description": "Bindings to libgit2.", 5 | "keywords": [ 6 | "git", 7 | "libgit2", 8 | "bindings" 9 | ], 10 | "author": "Sam Day ", 11 | "contributors": [ 12 | { 13 | "name": "Robo", 14 | "email": "hop2deep@gmail.com" 15 | } 16 | ], 17 | "engines": { 18 | "node": ">= 0.8.0" 19 | }, 20 | "dependencies": { 21 | "async": "~0.2.10", 22 | "shelljs": "~0.2.6", 23 | "bindings": "~1.1.1", 24 | "nan": "~1.0.0", 25 | "tar": "~0.1.19", 26 | "request": "~2.36.0" 27 | }, 28 | "devDependencies": { 29 | "tape": "~2.13.1", 30 | "temp": "~0.7.0", 31 | "wrench": "~1.3.9" 32 | }, 33 | "repository": { 34 | "type": "git", 35 | "url": "https://github.com/libgit2/node-gitteh.git" 36 | }, 37 | "directories": { 38 | "build": "./build", 39 | "lib": "./lib" 40 | }, 41 | "scripts": { 42 | "lint": "jshint lib/", 43 | "install": "node install.js", 44 | "postinstall": "node-gyp rebuild", 45 | "test": "./node_modules/.bin/tape test/runner.js" 46 | }, 47 | "main": "./lib/gitteh", 48 | "gypfile": true 49 | } 50 | -------------------------------------------------------------------------------- /examples/display-commit-tree.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This example will load the Git repository for gitteh, and display the commit 3 | * tree of the latest revision. You have to have cloned the gitteh Git repo for 4 | * this to work, of course. 5 | */ 6 | 7 | var gitteh = require("gitteh"), 8 | path = require("path"), 9 | fs = require("fs"); 10 | 11 | var repository = gitteh.openRepository(path.join(__dirname, "..", ".git")); 12 | var headRef = repository.getReference("HEAD"); 13 | headRef = headRef.resolve(); 14 | 15 | var commit = repository.getCommit(headRef.target); 16 | 17 | var displayTreeContents = function(treeId, tabs) { 18 | var tree = repository.getTree(treeId); 19 | 20 | var tabStr = ""; for(var i = 0; i < tabs; i++) tabStr += " "; 21 | 22 | for(var i = 0, len = tree.entries.length; i < len; i++) { 23 | var entry = tree.entries[i]; 24 | var line = tabStr ; 25 | line += entry.name; 26 | 27 | // 16384 == 40000 in octal (which is directory attribute in Git). 28 | if(entry.attributes == 16384) { 29 | line += "/"; 30 | console.log(line); 31 | displayTreeContents(entry.id, tabs + 1); 32 | } 33 | else { 34 | //line += " - " + entry.id; 35 | console.log(line); 36 | } 37 | } 38 | }; 39 | 40 | displayTreeContents(commit.tree, 1); 41 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v0.1.0 - 03/04/11 2 | * Heavy refactors to bring gitteh up to date with libgit2 0.11.0. 3 | * Commits no longer have methods to retrieve tree/parents. Instead, they are just sha1 string properties on the object. 4 | * Trees no longer have getEntry() method, all tree entries are added to an array in the tree.entries property. 5 | * Tree writing is currently unsupported (as it's been broken in libgit2), next version will allow writing an index as a tree. 6 | * Ref deletion is now supported. 7 | * Ref packing is supported. This is a fairly advanced feature and required more work than it was worth. Any issues reported on this will be followed up ASAP. 8 | * Full documentation written for the bindings. Huzzah. 9 | 10 | ## v0.0.4 - 29/03/11 11 | * Added support for working with git indexes. 12 | * Fixed issues that could cause asynchronous retrieval of objects to fail miserably. 13 | 14 | ## v0.0.3 - 20/03/11 15 | * Fixed up some pretty serious memory leaks stemming from how git_oid and git_signatures were being handled. 16 | 17 | ## v0.0.2 - 20/03/11 18 | * Minor fix to support 64-bit compiles (thanks TooTallNate). 19 | * Improved build system, will now automatically checkout libgit2 and build it if it's not already present on system. 20 | 21 | ## v0.0.1 - 18/03/11 22 | * Initial release. 23 | -------------------------------------------------------------------------------- /src/baton.cc: -------------------------------------------------------------------------------- 1 | #include "baton.h" 2 | #include "gitteh.h" 3 | #include 4 | 5 | namespace gitteh { 6 | 7 | Baton::Baton() { 8 | errorCode = 0; 9 | req.data = this; 10 | } 11 | 12 | Baton::~Baton() { 13 | if(!callback.IsEmpty()) { 14 | callback.Dispose(); 15 | callback.Clear(); 16 | } 17 | } 18 | 19 | void Baton::setCallback(Handle val) { 20 | NanScope(); 21 | 22 | callback = Persistent::New(Handle::Cast(val)); 23 | } 24 | 25 | bool Baton::isErrored() { 26 | return errorCode != 0; 27 | } 28 | 29 | void Baton::setError(const git_error *err) { 30 | errorCode = err->klass; 31 | errorString = string(err->message); 32 | } 33 | 34 | Handle Baton::createV8Error() { 35 | NanEscapableScope(); 36 | 37 | assert(errorCode != 0); 38 | Handle errObj = Handle::Cast(NanThrowError( 39 | NanNew(errorString.c_str()))); 40 | errObj->Set(NanNew("code"), NanNew(errorCode)); 41 | return NanEscapeScope(errObj); 42 | } 43 | 44 | void Baton::defaultCallback() { 45 | NanScope(); 46 | 47 | if(isErrored()) { 48 | Handle argv[] = { createV8Error() }; 49 | FireCallback(callback, 1, argv); 50 | } 51 | else { 52 | Handle argv[] = { Undefined() }; 53 | FireCallback(callback, 1, argv); 54 | } 55 | } 56 | 57 | }; // namespace gitteh 58 | -------------------------------------------------------------------------------- /src/thread.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_THREAD_H 2 | #define GITTEH_THREAD_H 3 | 4 | // I honestly have no clue what the fuck I'm doing. Libgit2 doesn't seem to be 5 | // thread-safe, so I need an object to synchronize with to prevent crazy shit 6 | // happening when libeio kicks in and I'm doing libgit2 stuff in random threads. 7 | 8 | // I must be missing something, I've never really worked with threads in C++ 9 | // before, and I understand that they're not a first class feature of the 10 | // current C++ standard, but I figured libeio would have some form of lock in 11 | // place, apparently not o.O. Apparently libeio relies heavily on POSIX threads 12 | // though, so one would think I should be ok to use pthread_mutex_lock and 13 | // pthread_mutex_unlock? Just in case though I'm setting up macros for them here 14 | // so I can swap them out or write compiler/platform specific variants later. 15 | 16 | typedef pthread_mutex_t gitteh_lock; 17 | #define CREATE_MUTEX(LOCK) \ 18 | pthread_mutex_init (&LOCK, NULL); 19 | 20 | #define DESTROY_MUTEX(LOCK) \ 21 | pthread_mutex_destroy(&LOCK); 22 | 23 | #define LOCK_MUTEX(LOCK) \ 24 | pthread_mutex_lock(&LOCK); 25 | 26 | #define UNLOCK_MUTEX(LOCK) \ 27 | pthread_mutex_unlock(&LOCK) 28 | 29 | 30 | #endif // GITTEH_THREAD_H 31 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | TODO: 2 | 3 | * Improve install system. Should probably at least try and check system for a 4 | valid libgit2 system - however unlikely. Should also be downloading a tarball 5 | of release rather than heavyweight git subdirectory checkout. 6 | * Lookup lightweight/annotated tag by name. 7 | * V8 AdjustForMemoryByCompensatingWithAReallyLongMethodName when we allocate libgit2 stuff 8 | 9 | # (Old) TODO - probably still relevant 10 | 11 | * Integrity tests, make sure bindings don't choke or segfault on really bad data. 12 | * Possibly implement custom backend support, allowing JS callbacks to provide a custom git backend. 13 | * Check for memory leaks 14 | * Cache raw objects properly, so two requests for the same oid don't result in different objects. 15 | * Maybe add convenience methods to all existing wrapped objects to get the raw object equivalent of them. 16 | * Error handling in the EIO initialization stuff for objects. Not sure if something can go wrong there, but better safe than sorry. 17 | * Tests for initializing a new repository, bare or workingdir. 18 | * Stress test suite. 19 | * Perf tests. 20 | * See if we can remove the lock on repository for some serious speed. 21 | * Make sure all create/get stuff in repo is returning local copies of handles. 22 | * Update Index to not use getters/setters for index modification. Instead, work with an array like tree entries. -------------------------------------------------------------------------------- /test/gitteh.js: -------------------------------------------------------------------------------- 1 | var temp = require('temp') 2 | , path = require('path') 3 | , wrench = require('wrench'); 4 | 5 | module.exports.all = function (gitteh, test) { 6 | test('opening a valid repo...', function (t) { 7 | gitteh.openRepository("test/repo/workdir/.git", function (err, repo) { 8 | t.ok(repo instanceof gitteh.Repository, 'returns an instance of #gitteh.Repository'); 9 | t.end(); 10 | }); 11 | }); 12 | /* 13 | test('opening an invalid repo...', function (t) { 14 | gitteh.openRepository("/i/shouldnt/exist", function (err) { 15 | t.throws(err, 'throws an error'); 16 | t.end(); 17 | }); 18 | }); 19 | 20 | test('initialising on an invalid path...', function (t) { 21 | gitteh.initRepository("/i/shouldnt/exist", function (err) { 22 | t.throws(err, 'throws an exception'); 23 | t.end(); 24 | }); 25 | }); 26 | */ 27 | test('initialising a bare repo...', function (t) { 28 | var tempPath = temp.path(); 29 | 30 | gitteh.initRepository(tempPath, true, function (err, repo) { 31 | t.ok(repo instanceof gitteh.Repository, 'returns an instance of #gitteh.Repository'); 32 | t.ok(repo.bare, 'works'); 33 | t.equal(path.relative(repo.path, tempPath), '', 'initialises a bare repo in the specified path'); 34 | 35 | wrench.rmdirSyncRecursive(tempPath, true); 36 | 37 | t.end(); 38 | }); 39 | }); 40 | }; 41 | -------------------------------------------------------------------------------- /install.js: -------------------------------------------------------------------------------- 1 | var async = require("async") 2 | , path = require('path') 3 | , fs = require('fs') 4 | , request = require('request') 5 | , zlib = require('zlib') 6 | , tar = require('tar'); 7 | 8 | require('shelljs/global'); 9 | 10 | if (!which('cmake')) { 11 | console.error("[ERROR] CMake is required for installation."); 12 | exit(1); 13 | } 14 | 15 | function passthru() { 16 | var args = Array.prototype.slice.call(arguments); 17 | var cb = args.splice(-1)[0]; 18 | var cmd = args.splice(0, 1)[0]; 19 | var child = exec(cmd, { async: true }); 20 | 21 | child.stdout.pipe(process.stdout); 22 | child.stderr.pipe(process.stderr); 23 | child.on("exit", cb); 24 | } 25 | 26 | var libgit2Dir = path.join(__dirname, "deps/libgit2/"); 27 | 28 | async.series([ 29 | function(cb) { 30 | console.log("[gitteh] Downloading libgit2 dependency."); 31 | 32 | if (fs.existsSync(path.join(__dirname, '.git'))) { 33 | console.log("[gitteh] ...via git submodule"); 34 | passthru("git submodule update --init", cb); 35 | } else { 36 | console.log("[gitteh] ...via tarball"); 37 | var libgit2Version = "v0.19.0"; 38 | var url = "https://github.com/libgit2/libgit2/tarball/" + libgit2Version; 39 | request.get(url).pipe(zlib.createUnzip()).pipe(tar.Extract({path: libgit2Dir, strip: true})).on('end', cb); 40 | } 41 | 42 | } 43 | ], function(err) { 44 | if(err) process.exit(err); 45 | }); 46 | -------------------------------------------------------------------------------- /test/commit.js: -------------------------------------------------------------------------------- 1 | module.exports.all = function (gitteh, test) { 2 | 3 | test('can find the commit on master...', function (t) { 4 | t.plan(6); 5 | 6 | gitteh.openRepository('test/repo/workdir/.git', function (err, repo) { 7 | repo.commit('60e0dbe58458ed42d0191a1780d91e14b8b7e0be', function (err, commit) { 8 | t.error(err, 'shoudnt throw an exception'); 9 | t.ok(commit instanceof gitteh.Commit, 'returns an instance of #gitteh.Commit'); 10 | t.equal(commit.id, '60e0dbe58458ed42d0191a1780d91e14b8b7e0be'); 11 | t.equal(commit.parents.length, 1, 'contains a array with one parent'); 12 | 13 | 14 | t.test('validity of author...', function (t) { 15 | var author = commit.author; 16 | 17 | t.equal(author.name, 'Sam', 'name'); 18 | t.equal(author.email, 'me@samcday.com.au', 'email'); 19 | t.ok(author.offset, 'contains offset property'); 20 | t.ok(author.time, 'contains time of commit'); 21 | t.end(); 22 | }); 23 | 24 | t.test('validity of committer...', function (t) { 25 | var committer = commit.committer; 26 | 27 | t.equal(committer.name, 'Sam', 'name'); 28 | t.equal(committer.email, 'me@samcday.com.au', 'email'); 29 | t.ok(committer.offset, 'contains offset property'); 30 | t.ok(committer.time, 'contains time of commit'); 31 | t.end(); 32 | }); 33 | 34 | }); 35 | }); 36 | 37 | }); 38 | }; 39 | -------------------------------------------------------------------------------- /lib/refspec.js: -------------------------------------------------------------------------------- 1 | function Refspec(utils) { 2 | 3 | return function (src, dst) { 4 | var _this = this 5 | , _priv = utils._createPrivate(_this); 6 | 7 | _priv.srcRoot = (src !== null) && src.slice(-1) === "*" ? src.slice(0, -1) : src; 8 | _priv.dstRoot = (dst !== null) && dst.slice(-1) === "*" ? dst.slice(0, -1) : dst; 9 | 10 | utils._immutable(_this, {src: src, dst: dst}) 11 | .set('src') 12 | .set('dst'); 13 | }; 14 | }; 15 | 16 | Refspec.prototype.matchesSrc = function (refName) { 17 | var _this = this 18 | , _priv = utils._getPrivate(_this); 19 | 20 | if (refName.length <= _priv.srcRoot.length) 21 | return false; 22 | 23 | return refName.indexOf(_priv.srcRoot) === 0; 24 | }; 25 | 26 | Refspec.prototype.matchesDst = function (refName) { 27 | var _this = this 28 | , _priv = utils._getPrivate(_this); 29 | 30 | if (refName.length <= _priv.dstRoot.length) 31 | return false; 32 | 33 | return refName.indexOf(_priv.dstRoot) === 0; 34 | }; 35 | 36 | Refspec.prototype.transformTo = function (refName) { 37 | if (!this.matchesSrc(refName)) 38 | throw new Error('Ref doesn\'t match with src.'); 39 | 40 | return "" + this.dst.slice(0, -2) + refName.slice(this.src.length - 2); 41 | }; 42 | 43 | Refspec.prototype.transformFrom = function (refName) { 44 | if(!this.matchesDst(refName)) 45 | throw new Error('Ref doesn\'t match with dst.'); 46 | 47 | return "" + this.src.slice(0, -2) + refName.slice(this.dst.length - 2); 48 | }; 49 | 50 | module.exports.all = function (Gitteh, utils) { 51 | Gitteh.Refspec = Refspec(utils); 52 | }; 53 | -------------------------------------------------------------------------------- /src/error.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_ERROR_H 2 | #define GITTEH_ERROR_H 3 | 4 | #include "gitteh.h" 5 | 6 | namespace gitteh { 7 | static inline void ErrorInit(Handle target) { 8 | HandleScope scope; 9 | 10 | /*Handle errorsObj = Object::New(); 11 | target->Set(String::NewSymbol("error"), errorsObj); 12 | 13 | NODE_DEFINE_CONSTANT(errorsObj, GIT_OK); 14 | NODE_DEFINE_CONSTANT(errorsObj, GIT_ERROR); 15 | NODE_DEFINE_CONSTANT(errorsObj, GIT_ENOTOID); 16 | NODE_DEFINE_CONSTANT(errorsObj, GIT_ENOTFOUND); 17 | NODE_DEFINE_CONSTANT(errorsObj, GIT_ENOMEM); 18 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EOSERR); 19 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EOBJTYPE); 20 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EOBJCORRUPTED); 21 | NODE_DEFINE_CONSTANT(errorsObj, GIT_ENOTAREPO); 22 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EINVALIDTYPE); 23 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EMISSINGOBJDATA); 24 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EPACKCORRUPTED); 25 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EFLOCKFAIL); 26 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EZLIB); 27 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EBUSY); 28 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EBAREINDEX); 29 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EINVALIDREFNAME); 30 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EREFCORRUPTED); 31 | NODE_DEFINE_CONSTANT(errorsObj, GIT_ETOONESTEDSYMREF); 32 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EPACKEDREFSCORRUPTED); 33 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EINVALIDPATH); 34 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EREVWALKOVER); 35 | NODE_DEFINE_CONSTANT(errorsObj, GIT_EINVALIDREFSTATE); 36 | NODE_DEFINE_CONSTANT(errorsObj, GIT_ENOTIMPLEMENTED);*/ 37 | } 38 | } 39 | 40 | #endif // GITTEH_ERROR_H 41 | -------------------------------------------------------------------------------- /test/reference.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | , fs = require('fs'); 3 | 4 | module.exports.all = function (gitteh, test) { 5 | 6 | test('can find the HEAD sym reference', function (t) { 7 | t.plan(6); 8 | 9 | gitteh.openRepository('test/repo/workdir/.git', function(err, repo) { 10 | var headPath = path.join(repo.path, "HEAD") 11 | , headFile = fs.readFileSync(headPath, 'utf-8').slice(5, -1); 12 | 13 | repo.ref("HEAD", false, function (err, ref) { 14 | t.ok(ref instanceof gitteh.Reference, 'returns an instance of #gitteh.Reference'); 15 | t.equal(ref.name, 'HEAD', 'has valid property #name'); 16 | t.equal(ref.target, headFile, 'points to .git/HEAD'); 17 | t.notOk(ref.direct, 'direct should be false'); 18 | }); 19 | 20 | t.test('gives resolved direct ref', function (t) { 21 | repo.ref("HEAD", true, function (err, ref) { 22 | t.error(err, 'shouldnt throw an exception') 23 | t.equal(ref.name, headFile); 24 | t.end(); 25 | }); 26 | }); 27 | 28 | t.test('create direct ref', function (t) { 29 | fs.unlink(path.join(repo.path, "refs", "heads", "testref")); 30 | 31 | repo.createReference('refs/heads/testref', '60e0dbe58458ed42d0191a1780d91e14b8b7e0be', function (err, newref) { 32 | t.error(err, 'shouldnt throw an exception'); 33 | t.ok(newref instanceof gitteh.Reference, 'returns an instance of #gitteh.Reference'); 34 | t.equal(newref.name, 'refs/heads/testref', 'contains valid target name'); 35 | t.equal(newref.target, '60e0dbe58458ed42d0191a1780d91e14b8b7e0be', 'points to commit id'); 36 | t.end(); 37 | }); 38 | }); 39 | 40 | }); 41 | }); 42 | }; 43 | -------------------------------------------------------------------------------- /src/blob.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Sam Day 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "blob.h" 26 | #include 27 | 28 | static Persistent data_symbol; 29 | 30 | namespace gitteh { 31 | namespace Blob { 32 | void Init(Handle target) { 33 | NanScope(); 34 | data_symbol = NODE_PSYMBOL("data"); 35 | } 36 | 37 | Handle Create(git_blob *blob) { 38 | NanEscapableScope(); 39 | Handle o = NanNew(); 40 | int len = git_blob_rawsize(blob); 41 | Buffer *buffer = Buffer::New((char*)git_blob_rawcontent(blob), len); 42 | o->Set(data_symbol, MakeFastBuffer(buffer, len)); 43 | return NanEscapeScope(o); 44 | } 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /lib/utils.js: -------------------------------------------------------------------------------- 1 | function getPrivate (obj) { 2 | getPrivate.lock++; 3 | return obj._private; 4 | }; 5 | 6 | getPrivate.lock = 0; 7 | 8 | function defineObject (obj, prop, opts) { 9 | Object.defineProperty(obj, prop, 10 | { 11 | enumerable: opts.enumerable, 12 | configurable: opts.configurable, 13 | get: opts.get 14 | }); 15 | }; 16 | 17 | function createPrivate (obj) { 18 | var opts = {} 19 | ,_priv = {}; 20 | 21 | opts.get = function () { 22 | if (!getPrivate.lock--) { 23 | throw new Error("Bad Request."); 24 | } 25 | return _priv; 26 | }; 27 | 28 | defineObject(obj, '_private', opts); 29 | return _priv; 30 | }; 31 | 32 | function wrapCallback (original, callback) { 33 | return function (err) { 34 | if (err !== null) return original(err); 35 | 36 | return callback.apply(null, Array.prototype.slice.call(arguments, 1)); 37 | }; 38 | }; 39 | 40 | function immutable (obj, src) { 41 | var opts = {}, result; 42 | 43 | return result = { 44 | set: function(name, target) { 45 | if (target === undefined) target = name; 46 | if (Array.isArray(src[name])) { 47 | Object.defineProperty(obj, target, { 48 | get: function() { 49 | return src[name].slice(0); 50 | }, 51 | configurable: false, 52 | enumerable: true 53 | }); 54 | return result; 55 | } 56 | 57 | Object.defineProperty(obj, target, { 58 | value: src[name], 59 | writable: false, 60 | configurable: false, 61 | enumerable: true 62 | }); 63 | 64 | return result; 65 | } 66 | }; 67 | 68 | }; 69 | 70 | module.exports = { 71 | _getPrivate: getPrivate, 72 | _createPrivate: createPrivate, 73 | _wrapCallback: wrapCallback, 74 | _immutable: immutable, 75 | _defineObject: defineObject 76 | }; 77 | -------------------------------------------------------------------------------- /lib/gitteh.js: -------------------------------------------------------------------------------- 1 | var bindings = require("bindings")("gitteh.node") 2 | , utils = require("./utils") 3 | , args = require("./args"); 4 | 5 | var helpers = ['signature', 'refspec', 'commit', 'tree', 'blob', 'tag', 'remote', 'index', 'reference', 'repository']; 6 | 7 | var Gitteh = module.exports = {}; 8 | 9 | Gitteh.bindings = bindings 10 | , Gitteh.args = args 11 | , Gitteh.utils = utils 12 | , args.minOidLength = bindings.minOidLength; 13 | 14 | Object.keys(helpers).forEach(function (fileName) { 15 | var helper = helpers[fileName]; 16 | require("./" + helper).all(Gitteh, utils, args); 17 | }); 18 | 19 | Gitteh.openRepository = function () { 20 | var _ref = args({ 21 | path: { 22 | type: 'string' 23 | }, 24 | cb: { 25 | type: 'function' 26 | } 27 | }) 28 | , path = _ref[0] 29 | , cb = _ref[1]; 30 | 31 | return bindings.openRepository(path, utils._wrapCallback(cb, function (repo) { 32 | return cb(null, new Gitteh.Repository(repo)); 33 | })); 34 | }; 35 | 36 | Gitteh.openIndex = function () { 37 | var _ref = args({ 38 | repo: { 39 | type: "repository" 40 | }, 41 | cb: { 42 | type: "function" 43 | } 44 | }) 45 | , repo = _ref[0] 46 | , cb = _ref[1]; 47 | 48 | return bindings.openIndex(repo, utils._wrapCallback(cb, function (repo) { 49 | return cb(null, new Gitteh.Index(repo)); 50 | })); 51 | } 52 | 53 | Gitteh.initRepository = function () { 54 | var _ref = args({ 55 | path: { 56 | type: 'string' 57 | }, 58 | bare: { 59 | type: 'bool', 60 | "default": false 61 | }, 62 | cb: { 63 | type: 'function' 64 | } 65 | }) 66 | , path = _ref[0] 67 | , bare = _ref[1] 68 | , cb = _ref[2]; 69 | 70 | return bindings.initRepository(path, bare, utils._wrapCallback(cb, function (repo) { 71 | return cb(null, new Gitteh.Repository(repo)); 72 | })); 73 | }; 74 | 75 | Gitteh.clone = function () { 76 | 77 | }; 78 | -------------------------------------------------------------------------------- /src/tag.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Sam Day 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "tag.h" 26 | #include "signature.h" 27 | 28 | static Persistent name_symbol; 29 | static Persistent message_symbol; 30 | static Persistent tagger_symbol; 31 | static Persistent target_symbol; 32 | static Persistent type_symbol; 33 | 34 | namespace gitteh { 35 | namespace Tag { 36 | void Init(Handle target) { 37 | NanScope(); 38 | name_symbol = NODE_PSYMBOL("name"); 39 | message_symbol = NODE_PSYMBOL("message"); 40 | tagger_symbol = NODE_PSYMBOL("tagger"); 41 | target_symbol = NODE_PSYMBOL("target"); 42 | type_symbol = NODE_PSYMBOL("type"); 43 | } 44 | 45 | Handle Create(git_tag *tag) { 46 | NanEscapableScope(); 47 | Handle o = NanNew(); 48 | o->Set(name_symbol, CastToJS(git_tag_name(tag))); 49 | o->Set(message_symbol, CastToJS(git_tag_message(tag))); 50 | o->Set(tagger_symbol, CastToJS(git_tag_tagger(tag))); 51 | o->Set(target_symbol, CastToJS(git_tag_target_id(tag))); 52 | o->Set(type_symbol, CastToJS(git_tag_target_type(tag))); 53 | return NanEscapeScope(o); 54 | } 55 | } 56 | }; 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gitteh 2 | 3 | [![build status](https://img.shields.io/travis/libgit2/node-gitteh.svg?style=flat-square)](https://travis-ci.org/libgit2/node-gitteh) [![npm version](http://img.shields.io/npm/v/gitteh.svg?style=flat-square)](https://npmjs.org/package/gitteh) [![Dependency Status](https://david-dm.org/libgit2/node-gitteh.svg)](https://david-dm.org/libgit2/node-gitteh) [![devDependency Status](https://david-dm.org/libgit2/node-gitteh/dev-status.svg)](https://david-dm.org/libgit2/node-gitteh#info=devDependencies) 4 | 5 | ## Installation 6 | 7 | Gitteh requires `node 0.8 or 0.10`, `CMake 2.6` and `gcc`. Installation via NPM: 8 | 9 | npm install gitteh 10 | 11 | ## What? 12 | 13 | Node bindings to the excellent [libgit2](http://libgit2.github.com) C library. Right now, the bindings cover read only access to raw objects (trees/commits/blobs/tags/references), and basic access to remotes (including basic cloning/fetching support). 14 | 15 | Gitteh aims to: 16 | 17 | * Be simple and convenient 18 | * Be as performant as possible - avoids calling into underlying C library as much as possible. 19 | * Be safe for use in Node's threadpool (read: shouldn't segfault your app) 20 | 21 | ## Why? 22 | 23 | There's a few libraries out there that wrap git cli commands, parsing the output and such. This is a perfectly acceptable solution. Node-gitteh provides first-class support to work with a git repository on a low level, and does not require git.git (and its myriad of dependencies) to be installed in the server environment. 24 | 25 | The documentation is currently outdated. We're working on a new version currently for the new 0.17.x version of gitteh. The [Old pre-0.17.x documentation can be found here](http://libgit2.github.com/node-gitteh/docs/index.html). Instead, you should visit [`examples`](https://github.com/libgit2/node-gitteh/tree/master/examples) dir in the repo to see examples of 0.17.x usage. 26 | 27 | ## License 28 | 29 | Gitteh is available under the MIT License. See the LICENSE file for more information. 30 | 31 | ## Contributing 32 | 33 | Contributions are very welcome. Please feel free to fork this project and hack on it. Go ahead and check out the issues tab to see what needs to be done! Go on! Do it! 34 | 35 | ### Building 36 | 37 | ``` 38 | git clone https://github.com/libgit2/node-gitteh 39 | cd node-gitteh && npm install 40 | ``` 41 | 42 | Happy hacking! 43 | -------------------------------------------------------------------------------- /test/stress/repository.coffee: -------------------------------------------------------------------------------- 1 | # Open 1000 copies of the same repository location in one async batch, ensure 2 | # each one behaves normally. 3 | 4 | gitteh = require "../../lib/gitteh" 5 | {projectRepo} = require "../fixtures" 6 | assert = require "assert" 7 | async = require "async" 8 | 9 | openCommitAndTree = (i, cb) -> 10 | gitteh.openRepository projectRepo.path, (err, repo) -> 11 | assert repo 12 | async.parallel 13 | commit: (cb) -> repo.commit projectRepo.secondCommit.id, cb 14 | tree: (cb) -> repo.tree projectRepo.secondCommit.tree, cb 15 | , (err, results) -> 16 | return cb err if err? 17 | assert results.commit.id is projectRepo.secondCommit.id 18 | assert results.tree.id is projectRepo.secondCommit.tree 19 | cb() 20 | 21 | openCommitAndTreeSeparately = (i, cb) -> 22 | async.parallel 23 | commit: (cb) -> 24 | gitteh.openRepository projectRepo.path, (err, repo) -> 25 | return cb err if err? 26 | assert repo 27 | repo.commit projectRepo.secondCommit.id, cb 28 | ### 29 | tree: (cb) -> 30 | gitteh.openRepository projectRepo.path, (err, repo) -> 31 | assert repo 32 | repo.tree projectRepo.secondCommit.tree, cb 33 | ### 34 | , cb 35 | 36 | sameCommit = (i, cb) -> 37 | gitteh.openRepository projectRepo.path, (err, repo) -> 38 | return cb err if err? 39 | 40 | async.forEach [1..1000], (i, cb) -> 41 | repo.commit projectRepo.secondCommit.id, (err, commit) -> 42 | return cb err if err? 43 | assert commit.id is projectRepo.secondCommit.id 44 | # console.log cb 45 | cb() 46 | repo.tree projectRepo.secondCommit.tree, (err, tree) -> 47 | return cb err if err? 48 | assert tree.id is projectRepo.secondCommit.tree 49 | # console.log cb 50 | cb() 51 | , () -> 52 | # gc() 53 | cb() 54 | 55 | module.exports = (cb) -> 56 | async.series 57 | openCommitAndTree: (cb) -> 58 | console.time "openCommitAndTree" 59 | async.forEach [1..1000], openCommitAndTree, (err) -> 60 | return cb err if err? 61 | console.timeEnd "openCommitAndTree" 62 | cb() 63 | openCommitAndTreeSeparately: (cb) -> 64 | console.time "openCommitAndTreeSeparately" 65 | async.forEach [1..1000], openCommitAndTreeSeparately, (err) -> 66 | return cb err if err? 67 | console.timeEnd "openCommitAndTreeSeparately" 68 | cb() 69 | sameCommit: (cb) -> 70 | console.time "sameCommit" 71 | async.forEach [1..1000], sameCommit, (err) -> 72 | return cb err if err? 73 | console.timeEnd "sameCommit" 74 | cb() 75 | , cb 76 | -------------------------------------------------------------------------------- /examples/walk-revisions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This example will open the Gitteh Git repo and walk the entire revision 3 | * history, displaying a screen output fairly similar to what you'd get when you 4 | * run `git log`. 5 | */ 6 | var gitteh = require("gitteh"), 7 | path = require("path"), 8 | fs = require("fs"); 9 | 10 | var startTime = Date.now(); 11 | 12 | // Load up the node-gitteh repository. This will only work if you cloned the 13 | // repo of course. 14 | // You can point this to anywhere that is housing a git repo, even a bare one. 15 | // You have to point it to the GIT directory though, so if you're working with 16 | // a repo that has a working copy checked out, you need to point it to the .git 17 | // folder. 18 | var repository = gitteh.openRepository(path.join(__dirname, "..", ".git")); 19 | 20 | // First step is to grab the HEAD commit. We use the ref management features of 21 | // gitteh to achieve this. 22 | var headRef = repository.getReference("HEAD"); 23 | 24 | // Just in case the reference is pointing to another reference (symbolic link), 25 | // we "resolve" the reference to a direct reference (one that points to an OID). 26 | // If the ref being pointed to by HEAD is already direct, then resolve does 27 | // nothing but return the same reference. 28 | headRef = headRef.resolve(); 29 | 30 | // Let's create a revision walker and traverse the entire commit history. 31 | var walker = repository.createWalker(); 32 | 33 | // Let's push the head commit onto the revision walker and start walkin'! 34 | 35 | // This will sort our commits by time. They can also be sorted "topologically", 36 | // which will prioritize parents before children. Also SORT_REVERSE can be 37 | // added to sorting, which will reverse all sorting options chosen. 38 | 39 | // This will start from the most recent commit, and go back in time. 40 | // Note that you have to set sorting BEFORE you push a commit to traverse from. 41 | walker.sort(gitteh.GIT_SORT_TIME); 42 | walker.push(headRef.target); 43 | 44 | // This output basically mimicks a basic `git log` command. 45 | var commit; 46 | while(commit = walker.next()) { 47 | console.log("commit " + commit.id); 48 | 49 | console.log("Author: " + commit.author.name + " <" + 50 | commit.author.email + ">"); 51 | 52 | if((commit.committer.name != commit.author.name) || 53 | (commit.committer.email != commit.author.email)) { 54 | console.log("Committer: " + commit.committer.name + " <" + 55 | commit.committer.email + ">"); 56 | } 57 | 58 | console.log("Date: " + commit.committer.time.toUTCString()); 59 | 60 | console.log("\n " + commit.message + "\n"); 61 | } 62 | 63 | console.log((Date.now() - startTime) + "ms"); -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/generator/Signature.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(BOOST_PP_IS_ITERATING) 2 | # include 3 | # include 4 | # include 5 | # include 6 | # include 7 | # if !defined(CVV8_PP_ITER_MAX) 8 | # error "Define CVV8_PP_ITER_MAX before including this file." 9 | # endif 10 | # if !defined(CVV8_SIGNATURE_GENERATED_HPP_INCLUDED) 11 | # define BOOST_PP_ITERATION_LIMITS (0, CVV8_PP_ITER_MAX) 12 | # define BOOST_PP_FILENAME_1 "Signature.hpp" 13 | # include BOOST_PP_ITERATE() 14 | # endif /* include guard */ 15 | #else 16 | #define n BOOST_PP_ITERATION() 17 | 18 | template 19 | struct Signature< RV (BOOST_PP_ENUM_PARAMS(n, A)) > 20 | { 21 | typedef RV ReturnType; 22 | static const bool IsConst = false; 23 | typedef void Context; 24 | typedef RV (*FunctionType)(BOOST_PP_ENUM_PARAMS(n, A)); 25 | #if n > 0 26 | typedef A0 Head; 27 | typedef Signature< RV (BOOST_PP_ENUM_SHIFTED_PARAMS(n, A)) > Tail; 28 | #else 29 | typedef tmp::NilType Head; 30 | typedef Head Tail; 31 | #endif 32 | }; 33 | 34 | template 35 | struct Signature< RV (*)(BOOST_PP_ENUM_PARAMS(n, A)) > 36 | : Signature< RV (BOOST_PP_ENUM_PARAMS(n, A)) > 37 | {}; 38 | 39 | //! Non-const method. 40 | template 41 | struct Signature< RV (T::*)(BOOST_PP_ENUM_PARAMS(n, A)) > 42 | : Signature< RV (BOOST_PP_ENUM_PARAMS(n, A))> 43 | { 44 | typedef T Context; 45 | typedef RV (Context::*FunctionType)(BOOST_PP_ENUM_PARAMS(n, A)); 46 | #if n > 0 47 | typedef A0 Head; 48 | typedef Signature< RV (T::*)(BOOST_PP_ENUM_SHIFTED_PARAMS(n, A)) > Tail; 49 | #else 50 | typedef tmp::NilType Head; 51 | typedef Head Tail; 52 | #endif 53 | }; 54 | 55 | //! Const method. 56 | template 57 | struct Signature< RV (T::*)(BOOST_PP_ENUM_PARAMS(n, A)) const > 58 | : Signature< RV (BOOST_PP_ENUM_PARAMS(n, A))> 59 | { 60 | typedef T const Context; 61 | typedef RV (Context::*FunctionType)(BOOST_PP_ENUM_PARAMS(n, A)) const; 62 | static const bool IsConst = true; 63 | #if n > 0 64 | typedef A0 Head; 65 | typedef Signature< RV (T::*)(BOOST_PP_ENUM_SHIFTED_PARAMS(n, A)) const > Tail; 66 | #else 67 | typedef tmp::NilType Head; 68 | typedef Head Tail; 69 | #endif 70 | }; 71 | 72 | #endif /* BOOST_PP_IS_ITERATING */ 73 | -------------------------------------------------------------------------------- /.jscs.json: -------------------------------------------------------------------------------- 1 | { 2 | "requireCurlyBraces": [ 3 | "if", 4 | "else", 5 | "for", 6 | "while", 7 | "do", 8 | "try", 9 | "catch" 10 | ], 11 | "requireSpaceAfterKeywords": [ 12 | "if", 13 | "else", 14 | "for", 15 | "while", 16 | "do", 17 | "switch", 18 | "return", 19 | "try", 20 | "catch" 21 | ], 22 | "disallowSpaceAfterKeywords": [], 23 | "requireParenthesesAroundIIFE": true, 24 | "requireSpacesInFunctionExpression": { 25 | "beforeOpeningCurlyBrace": true 26 | }, 27 | "disallowSpacesInFunctionExpression": { 28 | "beforeOpeningRoundBrace": true 29 | }, 30 | "requireSpacesInFunctionExpression": { 31 | "beforeOpeningCurlyBrace": true 32 | }, 33 | "disallowSpacesInFunctionExpression": { 34 | "beforeOpeningRoundBrace": true 35 | }, 36 | "requireBlocksOnNewline": true, 37 | "disallowEmptyBlocks": true, 38 | "disallowSpacesInsideObjectBrackets": true, 39 | "disallowSpacesInsideArrayBrackets": true, 40 | "disallowSpaceAfterObjectKeys": true, 41 | "requireCommaBeforeLineBreak": true, 42 | "disallowLeftStickedOperators": [ 43 | "?", 44 | "+", 45 | "/", 46 | "*", 47 | "=", 48 | "==", 49 | "===", 50 | "!=", 51 | "!==", 52 | ">", 53 | ">=", 54 | "<", 55 | "<=" 56 | ], 57 | "requireRightStickedOperators": ["!"], 58 | "disallowRightStickedOperators": [ 59 | "?", 60 | "+", 61 | "/", 62 | "*", 63 | ":", 64 | "=", 65 | "==", 66 | "===", 67 | "!=", 68 | "!==", 69 | ">", 70 | ">=", 71 | "<", 72 | "<=" 73 | ], 74 | "requireLeftStickedOperators": [","], 75 | "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], 76 | "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], 77 | "requireSpaceBeforeBinaryOperators": [ 78 | "+", 79 | "-", 80 | "/", 81 | "*", 82 | "=", 83 | "==", 84 | "===", 85 | "!=", 86 | "!==" 87 | ], 88 | "requireSpaceAfterBinaryOperators": [ 89 | "+", 90 | "-", 91 | "/", 92 | "*", 93 | "=", 94 | "==", 95 | "===", 96 | "!=", 97 | "!==" 98 | ], 99 | "requireCamelCaseOrUpperCaseIdentifiers": true, 100 | "disallowKeywords": ["with"], 101 | "disallowMultipleLineStrings": true, 102 | "validateLineBreaks": "LF", 103 | "validateQuoteMarks": { 104 | "mark": "'", 105 | "escape": true 106 | }, 107 | "disallowMixedSpacesAndTabs": true, 108 | "disallowTrailingWhitespace": true, 109 | "disallowKeywordsOnNewLine": ["else"], 110 | "requireLineFeedAtFileEnd": true, 111 | "maximumLineLength": 100, 112 | "requireCapitalizedConstructors": true, 113 | "requireDotNotation": true 114 | 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/commit.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Sam Day 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "commit.h" 26 | #include "signature.h" 27 | 28 | static Persistent message_symbol; 29 | static Persistent message_encoding_symbol; 30 | static Persistent author_symbol; 31 | static Persistent committer_symbol; 32 | static Persistent tree_symbol; 33 | static Persistent parents_symbol; 34 | 35 | namespace gitteh { 36 | namespace Commit { 37 | void Init(Handle target) { 38 | NanScope(); 39 | message_symbol = NODE_PSYMBOL("message"); 40 | message_encoding_symbol = NODE_PSYMBOL("messageEncoding"); 41 | author_symbol = NODE_PSYMBOL("author"); 42 | committer_symbol = NODE_PSYMBOL("committer"); 43 | tree_symbol = NODE_PSYMBOL("tree"); 44 | parents_symbol = NODE_PSYMBOL("parents"); 45 | } 46 | 47 | Handle Create(git_commit *cm) { 48 | NanEscapableScope(); 49 | Handle o = NanNew(); 50 | o->Set(tree_symbol, CastToJS(git_commit_tree_id(cm))); 51 | o->Set(message_symbol, CastToJS(git_commit_message(cm))); 52 | const char *encoding = git_commit_message_encoding(cm); 53 | if(encoding) { 54 | o->Set(message_encoding_symbol, CastToJS(encoding)); 55 | } 56 | Handle parents = NanNew(); 57 | int parentCount = git_commit_parentcount(cm); 58 | for(int i = 0; i < parentCount; i++) { 59 | parents->Set(i, CastToJS(git_commit_parent_id(cm, i))); 60 | } 61 | o->Set(parents_symbol, parents); 62 | o->Set(author_symbol, CastToJS(git_commit_author(cm))); 63 | o->Set(committer_symbol, CastToJS(git_commit_committer(cm))); 64 | 65 | return NanEscapeScope(o); 66 | } 67 | }; 68 | }; 69 | -------------------------------------------------------------------------------- /src/tree.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Sam Day 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "tree.h" 26 | 27 | static Persistent id_symbol; 28 | static Persistent entries_symbol; 29 | static Persistent entry_id_symbol; 30 | static Persistent entry_name_symbol; 31 | static Persistent entry_type_symbol; 32 | static Persistent entry_filemode_symbol; 33 | 34 | static Handle CreateEntry(const git_tree_entry *entry) { 35 | NanEscapableScope(); 36 | Handle o = NanNew(); 37 | o->Set(entry_id_symbol, CastToJS(git_tree_entry_id(entry))); 38 | o->Set(entry_name_symbol, CastToJS(git_tree_entry_name(entry))); 39 | o->Set(entry_filemode_symbol, CastToJS(git_tree_entry_filemode(entry))); 40 | o->Set(entry_type_symbol, CastToJS(git_tree_entry_type(entry))); 41 | return NanEscapeScope(o); 42 | } 43 | 44 | namespace gitteh { 45 | namespace Tree { 46 | void Init(Handle target) { 47 | NanScope(); 48 | id_symbol = NODE_PSYMBOL("id"); 49 | entries_symbol = NODE_PSYMBOL("entries"); 50 | entry_id_symbol = NODE_PSYMBOL("id"); 51 | entry_name_symbol = NODE_PSYMBOL("name"); 52 | entry_type_symbol = NODE_PSYMBOL("type"); 53 | entry_filemode_symbol = NODE_PSYMBOL("filemode"); 54 | } 55 | 56 | Handle Create(git_tree *tree) { 57 | NanEscapableScope(); 58 | Handle o = NanNew(); 59 | 60 | Handle entries = NanNew(); 61 | int entryCount = git_tree_entrycount(tree); 62 | for(int i = 0; i < entryCount; i++) { 63 | entries->Set(i, CreateEntry(git_tree_entry_byindex(tree, i))); 64 | } 65 | o->Set(entries_symbol, entries); 66 | 67 | return NanEscapeScope(o); 68 | } 69 | }; 70 | }; 71 | -------------------------------------------------------------------------------- /src/gitteh.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License 3 | * 4 | * Copyright (c) 2010 Sam Day 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | */ 24 | 25 | #include "gitteh.h" 26 | #include "repository.h" 27 | #include "commit.h" 28 | #include "signature.h" 29 | #include "tree.h" 30 | #include "blob.h" 31 | #include "tag.h" 32 | #include "remote.h" 33 | #include "index.h" 34 | 35 | namespace gitteh { 36 | 37 | Persistent module; 38 | 39 | static Handle CreateTypeObject() { 40 | NanEscapableScope(); 41 | Handle o = NanNew(); 42 | ImmutableSet(o, NanNew("commit"), NanNew(GIT_OBJ_COMMIT)); 43 | ImmutableSet(o, NanNew("tree"), NanNew(GIT_OBJ_TREE)); 44 | ImmutableSet(o, NanNew("blob"), NanNew(GIT_OBJ_BLOB)); 45 | ImmutableSet(o, NanNew("tag"), NanNew(GIT_OBJ_TAG)); 46 | return NanEscapeScope(o); 47 | } 48 | 49 | extern "C" void 50 | init(Handle target) { 51 | NanScope(); 52 | module = Persistent::New(target); 53 | 54 | // Initialize libgit2's thread system. 55 | git_threads_init(); 56 | 57 | Signature::Init(); 58 | Repository::Init(target); 59 | Commit::Init(target); 60 | Tree::Init(target); 61 | Blob::Init(target); 62 | Tag::Init(target); 63 | Index::Init(target); 64 | 65 | Remote::Init(target); 66 | 67 | ImmutableSet(target, NanNew("minOidLength"), NanNew(GIT_OID_MINPREFIXLEN)); 68 | ImmutableSet(target, NanNew("types"), CreateTypeObject()); 69 | 70 | NODE_DEFINE_CONSTANT(target, GIT_DIRECTION_PUSH); 71 | NODE_DEFINE_CONSTANT(target, GIT_DIRECTION_FETCH); 72 | 73 | /* 74 | IndexEntry::Init(target); 75 | 76 | RevWalker::Init(target); 77 | Reference::Init(target); 78 | 79 | ErrorInit(target);*/ 80 | } 81 | 82 | Handle GetModule() { 83 | return module; 84 | } 85 | 86 | } // namespace gitteh 87 | 88 | NODE_MODULE(gitteh, gitteh::init) 89 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/convert.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(CODE_GOOGLE_COM_P_V8_CONVERT_HPP_INCLUDED) 2 | #define CODE_GOOGLE_COM_P_V8_CONVERT_HPP_INCLUDED 1 3 | 4 | #include "detail/convert_core.hpp" 5 | /** LICENSE 6 | 7 | This software's source code, including accompanying documentation and 8 | demonstration applications, are licensed under the following 9 | conditions... 10 | 11 | The author (Stephan G. Beal [http://wanderinghorse.net/home/stephan/]) 12 | explicitly disclaims copyright in all jurisdictions which recognize 13 | such a disclaimer. In such jurisdictions, this software is released 14 | into the Public Domain. 15 | 16 | In jurisdictions which do not recognize Public Domain property 17 | (e.g. Germany as of 2011), this software is Copyright (c) 2011 18 | by Stephan G. Beal, and is released under the terms of the MIT License 19 | (see below). 20 | 21 | In jurisdictions which recognize Public Domain property, the user of 22 | this software may choose to accept it either as 1) Public Domain, 2) 23 | under the conditions of the MIT License (see below), or 3) under the 24 | terms of dual Public Domain/MIT License conditions described here, as 25 | they choose. 26 | 27 | The MIT License is about as close to Public Domain as a license can 28 | get, and is described in clear, concise terms at: 29 | 30 | http://en.wikipedia.org/wiki/MIT_License 31 | 32 | The full text of the MIT License follows: 33 | 34 | -- 35 | Copyright (c) 2011 Stephan G. Beal (http://wanderinghorse.net/home/stephan/) 36 | 37 | Permission is hereby granted, free of charge, to any person 38 | obtaining a copy of this software and associated documentation 39 | files (the "Software"), to deal in the Software without 40 | restriction, including without limitation the rights to use, 41 | copy, modify, merge, publish, distribute, sublicense, and/or sell 42 | copies of the Software, and to permit persons to whom the 43 | Software is furnished to do so, subject to the following 44 | conditions: 45 | 46 | The above copyright notice and this permission notice shall be 47 | included in all copies or substantial portions of the Software. 48 | 49 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 50 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 51 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 52 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 53 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 54 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 55 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 56 | OTHER DEALINGS IN THE SOFTWARE. 57 | 58 | --END OF MIT LICENSE-- 59 | 60 | For purposes of the above license, the term "Software" includes 61 | documentation and demonstration source code which accompanies 62 | this software. ("Accompanies" = is contained in the Software's 63 | primary public source code repository.) 64 | 65 | */ 66 | #endif /* CODE_GOOGLE_COM_P_V8_CONVERT_HPP_INCLUDED */ 67 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/invocable.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(CODE_GOOGLE_COM_P_V8_CONVERT_INVOKE_HPP_INCLUDED) 2 | #define CODE_GOOGLE_COM_P_V8_CONVERT_INVOKE_HPP_INCLUDED 1 3 | 4 | #include "convert.hpp" 5 | #include "detail/invocable_core.hpp" 6 | /** LICENSE 7 | 8 | This software's source code, including accompanying documentation and 9 | demonstration applications, are licensed under the following 10 | conditions... 11 | 12 | The author (Stephan G. Beal [http://wanderinghorse.net/home/stephan/]) 13 | explicitly disclaims copyright in all jurisdictions which recognize 14 | such a disclaimer. In such jurisdictions, this software is released 15 | into the Public Domain. 16 | 17 | In jurisdictions which do not recognize Public Domain property 18 | (e.g. Germany as of 2011), this software is Copyright (c) 2011 19 | by Stephan G. Beal, and is released under the terms of the MIT License 20 | (see below). 21 | 22 | In jurisdictions which recognize Public Domain property, the user of 23 | this software may choose to accept it either as 1) Public Domain, 2) 24 | under the conditions of the MIT License (see below), or 3) under the 25 | terms of dual Public Domain/MIT License conditions described here, as 26 | they choose. 27 | 28 | The MIT License is about as close to Public Domain as a license can 29 | get, and is described in clear, concise terms at: 30 | 31 | http://en.wikipedia.org/wiki/MIT_License 32 | 33 | The full text of the MIT License follows: 34 | 35 | -- 36 | Copyright (c) 2011 Stephan G. Beal (http://wanderinghorse.net/home/stephan/) 37 | 38 | Permission is hereby granted, free of charge, to any person 39 | obtaining a copy of this software and associated documentation 40 | files (the "Software"), to deal in the Software without 41 | restriction, including without limitation the rights to use, 42 | copy, modify, merge, publish, distribute, sublicense, and/or sell 43 | copies of the Software, and to permit persons to whom the 44 | Software is furnished to do so, subject to the following 45 | conditions: 46 | 47 | The above copyright notice and this permission notice shall be 48 | included in all copies or substantial portions of the Software. 49 | 50 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 51 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 52 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 53 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 54 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 55 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 56 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 57 | OTHER DEALINGS IN THE SOFTWARE. 58 | 59 | --END OF MIT LICENSE-- 60 | 61 | For purposes of the above license, the term "Software" includes 62 | documentation and demonstration source code which accompanies 63 | this software. ("Accompanies" = is contained in the Software's 64 | primary public source code repository.) 65 | 66 | */ 67 | #endif /* CODE_GOOGLE_COM_P_V8_CONVERT_INVOKE_HPP_INCLUDED */ 68 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | CoffeeDoc 8 | 9 | 10 | 11 | 12 | 13 |
14 |

CoffeeDoc — Module Index

15 |
16 |
17 | 24 |
25 | 26 |
27 |
28 |

gitteh.coffee

29 |
30 |
31 | 32 | 33 |

Classes

34 | 57 | 58 | 59 |

Functions

60 | 80 | 81 |
82 |
83 | 84 |
85 |
86 | 87 | 88 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/signature.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(WANDERINGHORSE_NET_SIGNATURE_HPP_INCLUDED) 2 | #define WANDERINGHORSE_NET_SIGNATURE_HPP_INCLUDED 1 3 | 4 | 5 | namespace cvv8 { 6 | #include "detail/signature_core.hpp" 7 | #include "detail/signature_generated.hpp" 8 | } 9 | /** LICENSE 10 | 11 | This software's source code, including accompanying documentation and 12 | demonstration applications, are licensed under the following 13 | conditions... 14 | 15 | The author (Stephan G. Beal [http://wanderinghorse.net/home/stephan/]) 16 | explicitly disclaims copyright in all jurisdictions which recognize 17 | such a disclaimer. In such jurisdictions, this software is released 18 | into the Public Domain. 19 | 20 | In jurisdictions which do not recognize Public Domain property 21 | (e.g. Germany as of 2011), this software is Copyright (c) 2011 22 | by Stephan G. Beal, and is released under the terms of the MIT License 23 | (see below). 24 | 25 | In jurisdictions which recognize Public Domain property, the user of 26 | this software may choose to accept it either as 1) Public Domain, 2) 27 | under the conditions of the MIT License (see below), or 3) under the 28 | terms of dual Public Domain/MIT License conditions described here, as 29 | they choose. 30 | 31 | The MIT License is about as close to Public Domain as a license can 32 | get, and is described in clear, concise terms at: 33 | 34 | http://en.wikipedia.org/wiki/MIT_License 35 | 36 | The full text of the MIT License follows: 37 | 38 | -- 39 | Copyright (c) 2011 Stephan G. Beal (http://wanderinghorse.net/home/stephan/) 40 | 41 | Permission is hereby granted, free of charge, to any person 42 | obtaining a copy of this software and associated documentation 43 | files (the "Software"), to deal in the Software without 44 | restriction, including without limitation the rights to use, 45 | copy, modify, merge, publish, distribute, sublicense, and/or sell 46 | copies of the Software, and to permit persons to whom the 47 | Software is furnished to do so, subject to the following 48 | conditions: 49 | 50 | The above copyright notice and this permission notice shall be 51 | included in all copies or substantial portions of the Software. 52 | 53 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 54 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 55 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 56 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 57 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 58 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 59 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 60 | OTHER DEALINGS IN THE SOFTWARE. 61 | 62 | --END OF MIT LICENSE-- 63 | 64 | For purposes of the above license, the term "Software" includes 65 | documentation and demonstration source code which accompanies 66 | this software. ("Accompanies" = is contained in the Software's 67 | primary public source code repository.) 68 | 69 | */ 70 | #endif /* WANDERINGHORSE_NET_SIGNATURE_HPP_INCLUDED */ 71 | -------------------------------------------------------------------------------- /src/repository.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_REPO_H 2 | #define GITTEH_REPO_H 3 | 4 | #include "nan.h" 5 | #include "gitteh.h" 6 | 7 | namespace gitteh { 8 | 9 | class RepositoryBaton; 10 | 11 | class Repository : public ObjectWrap { 12 | public: 13 | static Persistent constructor_template; 14 | 15 | friend class RepositoryBaton; 16 | // template friend class ObjectFactory; 17 | 18 | Repository(); 19 | ~Repository(); 20 | static void Init(Handle); 21 | 22 | // Big ugly hacks, I hope to remove these someday. Pretty much any operation 23 | // on a libgit2 repository needs to be locked to one thread at a time, as 24 | // libgit2 is not thread safe in the slightest. 25 | void lockRepository(); 26 | void unlockRepository(); 27 | 28 | git_repository *repo_; 29 | git_odb *odb_; 30 | git_index *index_; 31 | 32 | protected: 33 | static NAN_METHOD(OpenRepository); 34 | static NAN_METHOD(InitRepository); 35 | 36 | static NAN_METHOD(New); 37 | static NAN_METHOD(GetObject); 38 | static NAN_METHOD(GetReference); 39 | static NAN_METHOD(CreateOidReference); 40 | static NAN_METHOD(CreateSymReference); 41 | static NAN_METHOD(GetRemote); 42 | static NAN_METHOD(Exists); 43 | static NAN_METHOD(CreateRemote); 44 | 45 | void close(); 46 | 47 | private: 48 | Handle wrapObject(git_object*); 49 | 50 | static void AsyncOpenRepository(uv_work_t*); 51 | static void AsyncAfterOpenRepository(uv_work_t*); 52 | static void AsyncExists(uv_work_t*); 53 | static void AsyncAfterExists(uv_work_t*); 54 | static void AsyncInitRepository(uv_work_t*); 55 | static void AsyncAfterInitRepository(uv_work_t*); 56 | static void AsyncGetObject(uv_work_t*); 57 | static void AsyncAfterGetObject(uv_work_t*); 58 | static void AsyncGetReference(uv_work_t*); 59 | static void AsyncCreateReference(uv_work_t*); 60 | static void AsyncReturnReference(uv_work_t*); 61 | static void AsyncGetRemote(uv_work_t*); 62 | static void AsyncAfterGetRemote(uv_work_t*); 63 | static void AsyncCreateRemote(uv_work_t*); 64 | static void AsyncAfterCreateRemote(uv_work_t*); 65 | 66 | static Handle CreateReferenceObject(git_reference*); 67 | 68 | // For now, I'm using one lock for anything that calls a git_* api function. 69 | // I could probably have different locks for different sections of libgit2, 70 | // as I'm sure working on the index file or working on a specific ref isn't 71 | // going to step on the toes of a simultaneous call to get a tree entry for 72 | // example. However for now I want this thing to *just work*, I'll worry 73 | // about making it a speed demon later. Ideally libgit2 will become thread 74 | // safe internally, then I can remove all this shit! 75 | gitteh_lock gitLock_; 76 | 77 | // This lock is used during ref packing. The problem is ref packing will 78 | // invalidate our previously cached pointers. Ugh. So what we do is update 79 | // those pointers after we pack references right? Cool. Only thing is with 80 | // async that process might get fucked if we don't stop any more refs from 81 | // being opened created while we're in the process of packing. Hence this lock. 82 | // gitteh_lock refLock_; 83 | }; 84 | 85 | } // namespace gitteh 86 | 87 | #endif // GITTEH_REPO_H 88 | -------------------------------------------------------------------------------- /lib/args.js: -------------------------------------------------------------------------------- 1 | var objectTypes = ["any", "blob", "commit", "tag", "tree"] 2 | , remoteDirs = ["push", "fetch"] 3 | , __hasProp = {}.hasOwnProperty 4 | , numRequired, count; 5 | 6 | function Args (params) { 7 | 8 | var paramList = [], param, retlLeft, retRight 9 | , retParam = []; 10 | 11 | for (name in params) { 12 | if (!params.hasOwnProperty(name)) continue; 13 | 14 | param = params[name]; 15 | param.name = name; 16 | 17 | paramList.push(param); 18 | } 19 | 20 | numRequired = 0; 21 | count = 0; 22 | 23 | leftRequired = (function() { 24 | var res = []; 25 | 26 | for (var i = 0, len = paramList.length; i < len; i++) { 27 | 28 | if (paramList[i].hasOwnProperty("default")) { 29 | break; 30 | } 31 | 32 | numRequired++; 33 | res.push(paramList[i]); 34 | } 35 | 36 | return res; 37 | })(); 38 | 39 | paramList.splice(0, leftRequired.length); 40 | 41 | rightRequired = (function() { 42 | var _ref = paramList.slice(0).reverse() 43 | , res = []; 44 | 45 | for (var i = 0, len = _ref.length; i < len; i++) { 46 | 47 | if (_ref[i].hasOwnProperty("default")) { 48 | break; 49 | } 50 | 51 | numRequired++; 52 | res.push(_ref[i]); 53 | } 54 | 55 | return res; 56 | })(); 57 | 58 | rightRequired = rightRequired.reverse(); 59 | paramList.splice(-rightRequired.length); 60 | argList = Array.prototype.slice.call(Args.caller["arguments"]); 61 | 62 | if (argList.length < numRequired) { 63 | throw new Error("Not enough arguments."); 64 | } 65 | 66 | left = argList.splice(0, leftRequired.length); 67 | right = argList.splice(-rightRequired.length); 68 | 69 | for (var i = 0, len = left.length; i < len; i++) { 70 | count++; 71 | 72 | if (!Args.validators[leftRequired[i].type](left[i])) { 73 | throw new TypeError("" + leftRequired[i].name + " (" + count + ") is not a valid " + leftRequired[i].type); 74 | } 75 | 76 | retParam.push(left[i]); 77 | }; 78 | 79 | for (var i = 0, len = paramList.length; i < len; i++) { 80 | count++; 81 | 82 | if (argList.length > i) { 83 | 84 | if (!Args.validators[paramList[i].type](argList[i])) { 85 | throw new TypeError("" + paramList[i].name + " (" + count + ") is not a valid " + paramList[i].type); 86 | } 87 | retParam.push(argList[i]); 88 | 89 | } else { 90 | retParam.push(paramList["default"]); 91 | } 92 | 93 | }; 94 | 95 | for (var i = 0, len = right.length; i < len; i++) { 96 | count++; 97 | 98 | if (!Args.validators[rightRequired[i].type](right[i])) { 99 | throw new TypeError("" + rightRequired[i].name + " (" + count + ") is not a valid " + rightRequired[i].type); 100 | } 101 | 102 | retParam.push(right[i]); 103 | }; 104 | 105 | return retParam; 106 | }; 107 | 108 | Args.oidRegex = oidRegex = /^[a-zA-Z0-9]{0,40}$/; 109 | 110 | Args.validators = { 111 | string: function (val) { 112 | return typeof val === "string"; 113 | }, 114 | function: function (val) { 115 | return typeof val === "function"; 116 | }, 117 | bool: function (val) { 118 | return typeof val === "boolean"; 119 | }, 120 | oid: function (val) { 121 | if (typeof val !== "string" && !oidRegex.test(val) && val.length < Args.minOidLength) { 122 | return false; 123 | } 124 | return true; 125 | }, 126 | objectType: function (val) { 127 | return objectTypes.indexOf(val) > -1; 128 | }, 129 | remoteDir: function (val) { 130 | return remoteDirs.indexOf(val) > -1; 131 | } 132 | }; 133 | 134 | module.exports = Args; 135 | -------------------------------------------------------------------------------- /lib/remote.js: -------------------------------------------------------------------------------- 1 | function Remote (utils, args) { 2 | 3 | return function (repository, nativeRemote) { 4 | this.repository = repository; 5 | this.utils = utils; 6 | this.args = args; 7 | 8 | var _this = this 9 | , _priv = utils._createPrivate(_this) 10 | , opts = {}; 11 | 12 | _priv.native = nativeRemote; 13 | _priv.connected = false; 14 | 15 | if (!(nativeRemote instanceof Gitteh.bindings.NativeRemote)) { 16 | throw new Error('Don\'t construct me, see Repository.remote()'); 17 | } 18 | 19 | opts.connected = _priv.connected; 20 | opts.enumerable = true; 21 | opts.get = function () { 22 | return opts.connected; 23 | }; 24 | 25 | utils._defineObject(_this, 'connected', opts); 26 | 27 | utils._immutable(_this, nativeRemote) 28 | .set('name') 29 | .set('url'); 30 | 31 | var fetchSpec = new RefSpec(nativeRemote.fetchSpec.src, nativeRemote.fetchSpec.dst) 32 | , pushSpec = new RefSpec(nativeRemote.pushSpec.src, nativeRemote.pushSpec.dst); 33 | 34 | utils._immutable(_this, {fetchSpec: fetchSpec, pushSpec: pushSpec}) 35 | .set('fetchSpec') 36 | .set('pushSpec'); 37 | }; 38 | }; 39 | 40 | Remote.prototype.connect = function () { 41 | var _this = this 42 | , _priv = this.utils._getPrivate(_this) 43 | , _ref = this.args({ 44 | dir: { 45 | type: "remoteDir" 46 | }, 47 | cb: { 48 | type: "function" 49 | } 50 | }) 51 | , dir = _ref[0] 52 | , cb = _ref[1]; 53 | 54 | dir = dir === "push" ? Gitteh.bindings.GIT_DIRECTION_PUSH : Gitteh.bindings.GIT_DIRECTION_FETCH; 55 | 56 | return _priv.native.connect(dir, this.utils._wrapCallback(cb, function (refs) { 57 | var refNames = Object.keys(refs) 58 | , headOid = refs["HEAD"]; 59 | 60 | for (ref in refs) { 61 | var oid = refs[ref]; 62 | if (ref === "HEAD") continue; 63 | 64 | if (oid === headOid) { 65 | var headRef = this.fetchSpec.transformTo(ref); 66 | _this.utils._immutable(_this, {headRef: headRef}) 67 | .set("headRef", "HEAD"); 68 | break; 69 | } 70 | }; 71 | 72 | _this.utils._immutable(_this, {refNames: refNames}) 73 | .set("refNames", "refs"); 74 | _priv.connected = true; 75 | cb(); 76 | })); 77 | 78 | }; 79 | 80 | Remote.prototype.fetch = function () { 81 | var _this = this 82 | , _priv = this.utils._getPrivate(_this) 83 | , updateTimer = null; 84 | 85 | if(!this.connected) { 86 | throw new Error('Remote isn\'t connected.'); 87 | } 88 | 89 | var _ref = this.args({ 90 | progressCb: { 91 | type: "function" 92 | }, 93 | cb: { 94 | type: "function" 95 | } 96 | }) 97 | , progressCb = _ref[0] 98 | , cb = _ref[1]; 99 | 100 | var update = function () { 101 | var progress = _priv.native.stats; 102 | progressCb(progress.bytes, progress.total, progress.done); 103 | updateTimer = setTimeout(update, 500); 104 | }; 105 | 106 | setTimeout(update, 500); 107 | 108 | _priv.native.download = function () { 109 | clearTimeout(updateTimer); 110 | if (err) { 111 | return cb(err); 112 | } 113 | 114 | _priv.native.updateTips(_this.utils._wrapCallback(cb, function () { 115 | cb(); 116 | })); 117 | }; 118 | 119 | return _priv.native.download; 120 | }; 121 | 122 | module.exports.all = function (Gitteh, utils, args) { 123 | Gitteh.Remote = Remote(utils, args); 124 | Gitteh.Remote.prototype = Remote.prototype; 125 | }; 126 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/detail/tmp.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CODE_GOOGLE_COM_P_V8_CONVERT_TMP_HPP_INCLUDED 2 | #define CODE_GOOGLE_COM_P_V8_CONVERT_TMP_HPP_INCLUDED 3 | 4 | namespace cvv8 { 5 | /** 6 | The tmp namespace contains code related to template 7 | metaprogramming, a-la Alexandrescu's Loki library or Boost MPL. 8 | 9 | All of it is independent of the core library. 10 | 11 | This is not a complete/full-featured TMP library - it only 12 | contains the functions needed by our library-level code. 13 | */ 14 | namespace tmp { 15 | 16 | struct NilType {}; 17 | typedef NilType nil; 18 | 19 | 20 | /** 21 | An utmost most-basic compile-time assertion template. 22 | If Condition is false, an incomplete specialization of 23 | this type is invoked, causing a compile-time error. 24 | */ 25 | template 26 | struct Assertion 27 | { 28 | enum { Value = 1 }; 29 | }; 30 | /** Unimplemented - causes a compile-time error if used. */ 31 | template <> 32 | struct Assertion; 33 | 34 | 35 | /** A convenience base type for metafunctions holding a constant value. */ 36 | template 37 | struct ConstVal 38 | { 39 | static const ValType Value = Val; 40 | }; 41 | /** A metafunction holding an integer constant. */ 42 | template 43 | struct IntVal : ConstVal {}; 44 | /** A metafunction holding an unsigned short constant. */ 45 | template 46 | struct UShortVal : ConstVal {}; 47 | /** A metafunction holding a bool constant. */ 48 | template 49 | struct BoolVal : ConstVal {}; 50 | 51 | /** A metatype whos Value member is true if X and Y are the same type. */ 52 | template 53 | struct SameType : BoolVal {}; 54 | /** Specialization for X==Y. */ 55 | template 56 | struct SameType : BoolVal {}; 57 | 58 | template 59 | struct Identity 60 | { 61 | typedef T Type; 62 | }; 63 | 64 | template 65 | struct PlainType 66 | { 67 | typedef T Type; 68 | }; 69 | template 70 | struct PlainType : PlainType {}; 71 | template 72 | struct PlainType : PlainType {}; 73 | template 74 | struct PlainType : PlainType {}; 75 | 76 | #if 0 77 | /** Metatemplate whose Type evaluates to (T*). */ 78 | template 79 | struct AddPointer 80 | { 81 | typedef T * Type; 82 | }; 83 | /** Specialization whose Type evaluates to (T *). */ 84 | template 85 | struct AddPointer 86 | { 87 | typedef T * Type; 88 | }; 89 | /** Specialization whose Type evaluates to (T const *). */ 90 | template 91 | struct AddPointer 92 | { 93 | typedef T const * Type; 94 | }; 95 | 96 | //! Unimplemented. How to handle this? 97 | template 98 | struct AddPointer; 99 | //! Unimplemented. How to handle this? 100 | template 101 | struct AddPointer; 102 | #endif 103 | 104 | template 105 | struct IsConst : BoolVal {}; 106 | template 107 | struct IsConst : BoolVal {}; 108 | template 109 | struct IsConst : IsConst {}; 110 | template 111 | struct IsConst : IsConst {}; 112 | 113 | 114 | template 115 | struct IsNil : SameType {}; 116 | 117 | 118 | 119 | }} // namespaces 120 | #endif // CODE_GOOGLE_COM_P_V8_CONVERT_TMP_HPP_INCLUDED 121 | -------------------------------------------------------------------------------- /src/index.cc: -------------------------------------------------------------------------------- 1 | #include "index.h" 2 | #include "baton.h" 3 | #include "repository.h" 4 | 5 | namespace gitteh { 6 | static Persistent class_symbol; 7 | 8 | class IndexBaton : public Baton { 9 | public: 10 | Index *index_; 11 | Repository *repository_; 12 | 13 | IndexBaton(Index *index) : Baton(), index_(index) { 14 | repository_ = index->repository_; 15 | index_->Ref(); 16 | } 17 | 18 | ~IndexBaton() { 19 | index_->Unref(); 20 | } 21 | }; 22 | 23 | class ReadTreeBaton : public IndexBaton { 24 | public: 25 | git_oid treeId; 26 | 27 | ReadTreeBaton(Index *index) : IndexBaton(index) { } 28 | }; 29 | 30 | Persistent Index::constructor_template; 31 | 32 | Index::Index(Repository *repository, git_index *index) : 33 | repository_(repository), index_(index) { 34 | 35 | } 36 | 37 | Index::~Index() { 38 | 39 | } 40 | 41 | void Index::Init(Handle module) { 42 | NanScope(); 43 | 44 | class_symbol = NODE_PSYMBOL("NativeIndex"); 45 | 46 | Local t = NanNew(New); 47 | NanAssignPersistent(constructor_template, t); 48 | constructor_template->SetClassName(class_symbol); 49 | t->InstanceTemplate()->SetInternalFieldCount(1); 50 | 51 | NODE_SET_PROTOTYPE_METHOD(t, "readTree", ReadTree); 52 | NODE_SET_PROTOTYPE_METHOD(t, "write", Write); 53 | 54 | module->Set(class_symbol, constructor_template->GetFunction()); 55 | } 56 | 57 | NAN_METHOD(Index::New) { 58 | NanEscapableScope(); 59 | REQ_EXT_ARG(0, repoArg); 60 | REQ_EXT_ARG(1, indexArg); 61 | Handle me = args.This(); 62 | 63 | Repository *repository = static_cast(repoArg->Value()); 64 | git_index *rawIndex = static_cast(indexArg->Value()); 65 | Index *index = new Index(repository, rawIndex); 66 | index->Wrap(me); 67 | 68 | return NanEscapeScope(me); 69 | } 70 | 71 | NAN_METHOD(Index::ReadTree) { 72 | NanScope(); 73 | Index *index = ObjectWrap::Unwrap(args.This()); 74 | 75 | ReadTreeBaton *baton = new ReadTreeBaton(index); 76 | baton->treeId = CastFromJS(args[0]); 77 | baton->setCallback(args[1]); 78 | 79 | uv_queue_work(uv_default_loop(), &baton->req, AsyncReadTree, 80 | NODE_094_UV_AFTER_WORK_CAST(AsyncAfterReadTree)); 81 | 82 | return NanUndefined(); 83 | } 84 | 85 | void Index::AsyncReadTree(uv_work_t *req) { 86 | ReadTreeBaton *baton = GetBaton(req); 87 | 88 | baton->repository_->lockRepository(); 89 | 90 | git_tree *tree; 91 | if(AsyncLibCall(git_tree_lookup(&tree, baton->repository_->repo_, 92 | &baton->treeId), baton)) { 93 | AsyncLibCall(git_index_read_tree(baton->index_->index_, 94 | tree), baton); 95 | git_tree_free(tree); 96 | } 97 | 98 | baton->repository_->unlockRepository(); 99 | } 100 | 101 | void Index::AsyncAfterReadTree(uv_work_t *req) { 102 | HandleScope scope; 103 | ReadTreeBaton *baton = GetBaton(req); 104 | 105 | baton->defaultCallback(); 106 | 107 | delete baton; 108 | } 109 | 110 | NAN_METHOD(Index::Write) { 111 | NanScope(); 112 | Index *index = ObjectWrap::Unwrap(args.This()); 113 | IndexBaton *baton = new IndexBaton(index); 114 | baton->setCallback(args[0]); 115 | 116 | uv_queue_work(uv_default_loop(), &baton->req, AsyncWrite, 117 | NODE_094_UV_AFTER_WORK_CAST(AsyncAfterWrite)); 118 | 119 | return NanUndefined(); 120 | } 121 | 122 | void Index::AsyncWrite(uv_work_t *req) { 123 | IndexBaton *baton = GetBaton(req); 124 | 125 | AsyncLibCall(git_index_write(baton->index_->index_), baton); 126 | } 127 | 128 | void Index::AsyncAfterWrite(uv_work_t *req) { 129 | HandleScope scope; 130 | IndexBaton *baton = GetBaton(req); 131 | 132 | baton->defaultCallback(); 133 | 134 | delete baton; 135 | } 136 | 137 | }; // namespace gitteh 138 | -------------------------------------------------------------------------------- /src/gitteh.h: -------------------------------------------------------------------------------- 1 | #ifndef GITTEH_H 2 | #define GITTEH_H 3 | 4 | #include 5 | #include "cvv8/convert.hpp" 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "nan.h" 16 | #include "thread.h" 17 | #include "baton.h" 18 | 19 | using namespace v8; 20 | using namespace node; 21 | using namespace cvv8; 22 | using std::string; 23 | 24 | #define REQ_EXT_ARG(I, VAR) \ 25 | if (args.Length() <= (I) || !args[I]->IsExternal()) { \ 26 | std::ostringstream oss; \ 27 | oss << __FILE__ \ 28 | << ":" << __LINE__ \ 29 | << " " << " Argument " #I " invalid"; \ 30 | return ThrowException(Exception::TypeError( \ 31 | String::New( oss.str().c_str() ))); \ 32 | } \ 33 | Local VAR = Local::Cast(args[I]); 34 | 35 | // Node version-dependence macros 36 | #include 37 | #if NODE_VERSION_AT_LEAST(0,9,4) 38 | #define NODE_094_UV_AFTER_WORK_CAST(x) (uv_after_work_cb)(x) 39 | #else 40 | #define NODE_094_UV_AFTER_WORK_CAST(x) (x) 41 | #endif 42 | 43 | namespace gitteh { 44 | Handle GetModule(); 45 | 46 | static inline Handle CreateGitError() { 47 | const git_error *err = giterr_last(); 48 | Handle errObj = Handle::Cast(Exception::Error( 49 | String::New(err->message))); 50 | errObj->Set(String::New("code"), Integer::New(err->klass)); 51 | return errObj; 52 | } 53 | 54 | static inline Handle ThrowGitError() { 55 | return ThrowException(CreateGitError()); 56 | } 57 | 58 | template 59 | static inline T* GetBaton(uv_work_t *req) { 60 | return static_cast(req->data); 61 | } 62 | 63 | /** 64 | Invokes provided callback with given parameters, handles catching user-land 65 | exceptions and propagating them to top of Node's event loop 66 | */ 67 | static inline bool FireCallback(Handle callback, int argc, 68 | Handle argv[]) { 69 | TryCatch tryCatch; 70 | callback->Call(Context::GetCurrent()->Global(), argc, argv); 71 | if(tryCatch.HasCaught()) { 72 | FatalException(tryCatch); 73 | return false; 74 | } 75 | 76 | return true; 77 | } 78 | 79 | /** 80 | Examines return of a libgit2 call. If it's in error state, grab error object 81 | and hand it off to ref provided. 82 | */ 83 | static inline int LibCall(int result, const git_error **err) { 84 | if(result != GIT_OK) { 85 | *err = giterr_last(); 86 | return 0; 87 | } 88 | return 1; 89 | } 90 | 91 | static inline int AsyncLibCall(int result, Baton *baton) { 92 | const git_error *err; 93 | if(!LibCall(result, &err)) { 94 | baton->setError(err); 95 | return 0; 96 | } 97 | 98 | return 1; 99 | } 100 | 101 | static inline void ImmutableSet(Handle o, Handle k, Handle v) { 102 | o->Set(k, v, (PropertyAttribute)(ReadOnly | DontDelete)); 103 | } 104 | 105 | static inline Handle MakeFastBuffer(Buffer *slowBuffer, int size) { 106 | HandleScope scope; 107 | 108 | Handle global = Context::GetCurrent()->Global(); 109 | Handle bufferConstructor = Local::Cast( 110 | global->Get(String::New("Buffer"))); 111 | 112 | Handle argv[] = { 113 | slowBuffer->handle_, Integer::New(size), Integer::New(0) 114 | }; 115 | Handle fastBuffer = bufferConstructor->NewInstance(3, argv); 116 | 117 | return scope.Close(fastBuffer); 118 | } 119 | 120 | } // namespace gitteh 121 | 122 | namespace cvv8 { 123 | template<> 124 | struct NativeToJS { 125 | Handle operator() (git_oid const *oid) const { 126 | char oidStr[41]; 127 | oidStr[40] = 0; 128 | git_oid_fmt(oidStr, oid); 129 | return CastToJS(oidStr); 130 | } 131 | Handle operator() (git_oid const oid) const { 132 | char oidStr[41]; 133 | oidStr[40] = 0; 134 | git_oid_fmt(oidStr, &oid); 135 | return CastToJS(oidStr); 136 | } 137 | }; 138 | 139 | template<> 140 | struct JSToNative { 141 | typedef git_oid ResultType; 142 | ResultType operator() (Handle const &h) const { 143 | git_oid id; 144 | memset(&id, 0, sizeof(git_oid)); 145 | 146 | string idStr = CastFromJS(h); 147 | git_oid_fromstrn(&id, idStr.c_str(), idStr.length()); 148 | return id; 149 | } 150 | }; 151 | 152 | template<> 153 | struct NativeToJS { 154 | Handle operator() (git_otype const type) const { 155 | HandleScope scope; 156 | Handle val; 157 | switch(type) { 158 | case GIT_OBJ_COMMIT: { val = String::New("commit"); break; } 159 | case GIT_OBJ_TREE: { val = String::New("tree"); break; } 160 | case GIT_OBJ_BLOB: { val = String::New("blob"); break; } 161 | case GIT_OBJ_TAG: { val = String::New("tag"); break; } 162 | default: { val = Undefined(); break; } 163 | } 164 | return scope.Close(val); 165 | } 166 | }; 167 | 168 | template<> 169 | struct JSToNative { 170 | typedef git_otype ResultType; 171 | ResultType operator() (Handle const &h) const { 172 | string typeStr = string(*String::Utf8Value(h)); 173 | if(!typeStr.compare("commit")) return GIT_OBJ_COMMIT; 174 | if(!typeStr.compare("tree")) return GIT_OBJ_TREE; 175 | if(!typeStr.compare("blob")) return GIT_OBJ_BLOB; 176 | if(!typeStr.compare("tag")) return GIT_OBJ_TAG; 177 | if(!typeStr.compare("any")) return GIT_OBJ_ANY; 178 | return GIT_OBJ_BAD; 179 | } 180 | }; 181 | 182 | template<> 183 | struct NativeToJS : public NativeToJS {}; 184 | } 185 | 186 | #endif // GITTEH_H 187 | -------------------------------------------------------------------------------- /lib/repository.js: -------------------------------------------------------------------------------- 1 | var git, types; 2 | 3 | function Repository (Gitteh, utils, args) { 4 | git = Gitteh; 5 | types = Gitteh.bindings.types; 6 | 7 | return function (nativeRepo) { 8 | var _this = this; 9 | 10 | if(!(nativeRepo instanceof Gitteh.bindings.NativeRepository)) { 11 | throw new Error('Don\'t construct me, see gitteh (open | init) Repository'); 12 | } 13 | 14 | var _priv = git.utils._createPrivate(_this); 15 | _priv.native = nativeRepo; 16 | 17 | git.utils._immutable(_this, nativeRepo) 18 | .set('bare') 19 | .set('path') 20 | .set('workDir', 'workingDirectory') 21 | .set('remotes') 22 | .set('references') 23 | .set('submodules'); 24 | 25 | var index = new Gitteh.Index(nativeRepo.Index); 26 | git.utils._immutable(_this, {index: index}) 27 | .set('index'); 28 | }; 29 | }; 30 | 31 | Repository.prototype.exists = function (oid, cb) { 32 | var _this = this 33 | , _priv = git.utils._getPrivate(_this) 34 | , _ref = git.args({ 35 | oid: { 36 | type: 'oid' 37 | }, 38 | cb: { 39 | type: 'function' 40 | } 41 | }) 42 | , oid = _ref[0] 43 | , cb = ref[1]; 44 | 45 | return _priv.native.exists(oid, cb); 46 | }; 47 | 48 | Repository.prototype.object = function () { 49 | var _this = this 50 | , _priv = git.utils._getPrivate(_this) 51 | , _ref = git.args({ 52 | oid: { 53 | type: 'oid' 54 | }, 55 | type: { 56 | type: 'objectType', 57 | 'default': 'any' 58 | }, 59 | cb: { 60 | type: 'function' 61 | } 62 | }) 63 | , oid = _ref[0] 64 | , type = _ref[1] 65 | , cb = _ref[2]; 66 | 67 | return _priv.native.object(oid, type, git.utils._wrapCallback(cb, function (object) { 68 | var clazz = (function() { 69 | switch (object._type) { 70 | case types.commit: 71 | return git.Commit; 72 | case types.tree: 73 | return git.Tree; 74 | case types.blob: 75 | return git.Blob; 76 | case types.tag: 77 | return git.Tag; 78 | default: 79 | return; 80 | } 81 | })(); 82 | 83 | if (clazz === "undefined") { 84 | return cb(new TypeError("Unexpected Object Type")); 85 | } 86 | 87 | return cb(null, new clazz(_this, object)); 88 | })); 89 | }; 90 | 91 | Repository.prototype.blob = function (oid, cb) { 92 | return this.object(oid, 'blob', cb); 93 | }; 94 | 95 | Repository.prototype.commit = function (oid, cb) { 96 | return this.object(oid, 'commit', cb); 97 | }; 98 | 99 | Repository.prototype.tag = function (oid, cb) { 100 | return this.object(oid, 'tag', cb); 101 | }; 102 | 103 | Repository.prototype.tree = function (oid, cb) { 104 | return this.object(oid, 'tree', cb); 105 | }; 106 | 107 | Repository.prototype.reference = function () { 108 | var _this = this 109 | , _priv = git.utils._getPrivate(_this) 110 | , _ref = git.args({ 111 | name: { 112 | type: 'string' 113 | }, 114 | resolve: { 115 | type: 'bool', 116 | default: false 117 | }, 118 | cb: { 119 | type: 'function' 120 | } 121 | }) 122 | , name = _ref[0] 123 | , resolve = _ref[1] 124 | , cb = _ref[2]; 125 | 126 | return _priv.native.reference(name, resolve, git.utils._wrapCallback(cb, function (ref) { 127 | return cb(null, new git.Reference(_this, ref)); 128 | })); 129 | }; 130 | 131 | Repository.prototype.createReference = function () { 132 | var _this = this 133 | , _priv = git.utils._getPrivate(_this) 134 | , _ref = git.args({ 135 | name: { 136 | type: 'string' 137 | }, 138 | target: { 139 | type: 'string' 140 | }, 141 | force: { 142 | type: 'bool', 143 | default: false 144 | }, 145 | cb: { 146 | type: 'function' 147 | } 148 | }) 149 | , name = _ref[0] 150 | , target = _ref[1] 151 | , force = _ref[2] 152 | , cb = _ref[3]; 153 | 154 | var fn = "createSymReference"; 155 | if (target.length === 40 && git.args.oidRegex.test(target)) { 156 | fn = "createOidReference"; 157 | } 158 | 159 | return _priv.native[fn](name, target, force, git.utils._wrapCallback(cb, function (ref) { 160 | return cb(null, new git.Reference(_this, ref)); 161 | })); 162 | }; 163 | 164 | Repository.prototype.remote = function () { 165 | var _this = this 166 | , _priv = git.utils._getPrivate(_this) 167 | , _ref = git.args({ 168 | name: { 169 | type: 'string' 170 | }, 171 | cb: { 172 | type: 'function' 173 | } 174 | }) 175 | , name = _ref[0] 176 | , cb = _ref[1]; 177 | 178 | return _priv.native.remote(name, git.utils._wrapCallback(cb, function (remote) { 179 | return cb(null, new git.Remote(_this, remote)); 180 | })); 181 | }; 182 | 183 | Repository.prototype.createRemote = function () { 184 | var _this = this 185 | , _priv = git.utils._getPrivate(_this) 186 | , _ref = git.args({ 187 | name: { 188 | type: 'string' 189 | }, 190 | url: { 191 | type: 'string' 192 | }, 193 | cb: { 194 | type: 'function' 195 | } 196 | }) 197 | , name = _ref[0] 198 | , url = _ref[1] 199 | , cb = _ref[2]; 200 | 201 | return _priv.native.createRemote(name, url, git.utils._wrapCallback(cb, function (remote) { 202 | return cb(null, new git.Remote(_this, remote)); 203 | })); 204 | }; 205 | 206 | Repository.prototype.ref = Repository.prototype.reference; 207 | 208 | module.exports.all = function (Gitteh, utils, args) { 209 | Gitteh.Repository = Repository(Gitteh, utils, args); 210 | Gitteh.Repository.prototype = Repository.prototype; 211 | }; 212 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/NativeToJSMap.hpp: -------------------------------------------------------------------------------- 1 | #if ! defined(V8_CONVERT_NATIVE_JS_MAPPER_HPP_INCLUDED) 2 | #define V8_CONVERT_NATIVE_JS_MAPPER_HPP_INCLUDED 3 | 4 | #include "detail/convert_core.hpp" 5 | namespace cvv8 { 6 | /** 7 | A helper class to assist in the "two-way-binding" of 8 | natives to JS objects. This class holds native-to-JS 9 | binding information. 10 | 11 | In the general case, a native-to-JS conversion is only 12 | needed at the framework-level if bound/converted 13 | functions/methods will _return_ bound native 14 | pointers/references. If they only return "core" types (numbers 15 | and strings, basically), or explicitly return v8-supported 16 | types (e.g. v8::Handle) then no native-to-JS 17 | conversion is typically needed. 18 | 19 | Known limitations: 20 | 21 | This type does not fully support subclass conversions. 22 | e.g. the following function binding: 23 | 24 | @code 25 | virtual MyType * (MyType::*)(); 26 | @endcode 27 | 28 | _should_ be able to return a MySubType from derived implementations 29 | but it currently cannot. Handling this requires that a parent class 30 | be told each of its subclasses, and that we add internal handlers 31 | which try lookups on those classes if a conversion to MyType fails. 32 | 33 | Reminder to self: the v8::juice tree has an example of that which we 34 | can probably plunder. 35 | */ 36 | template 37 | struct NativeToJSMap 38 | { 39 | private: 40 | typedef TypeInfo TI; 41 | typedef typename TI::Type Type; 42 | /** 43 | The native type to bind to. 44 | */ 45 | typedef typename TI::NativeHandle NativeHandle; 46 | /** The type for holding the JS 'this' object. */ 47 | typedef v8::Persistent JSObjHandle; 48 | //typedef v8::Handle JSObjHandle; // Hmmm. 49 | typedef std::pair ObjBindT; 50 | typedef std::map OneOfUsT; 51 | /** Maps (void const *) to ObjBindT. 52 | 53 | Reminder to self: we might need to make this map a static 54 | non-function member to work around linking problems (at 55 | least on Windows) which lead to multiple instances of 56 | the returned map being created when the types being 57 | bound are loaded from multiple DLLs. The out-of-class 58 | initialization of the member is going to require a really 59 | ugly set of template parameters, though. 60 | */ 61 | static OneOfUsT & Map() 62 | { 63 | static OneOfUsT bob; 64 | return bob; 65 | } 66 | public: 67 | /** Maps obj as a lookup key for jself. Returns false if !obj, 68 | else true. */ 69 | static bool Insert( JSObjHandle const & jself, 70 | NativeHandle obj ) 71 | { 72 | return obj 73 | ? (Map().insert( std::make_pair( obj, std::make_pair( obj, jself ) ) ),true) 74 | : 0; 75 | } 76 | 77 | /** 78 | Removes any mapping of the given key. Returns the 79 | mapped native, or 0 if none is found. 80 | */ 81 | static NativeHandle Remove( void const * key ) 82 | { 83 | typedef typename OneOfUsT::iterator Iterator; 84 | OneOfUsT & map( Map() ); 85 | Iterator it = map.find( key ); 86 | if( map.end() == it ) 87 | { 88 | return 0; 89 | } 90 | else 91 | { 92 | NativeHandle victim = (*it).second.first; 93 | map.erase(it); 94 | return victim; 95 | } 96 | } 97 | 98 | /** 99 | Returns the native associated (via Insert()) 100 | with key, or 0 if none is found. 101 | */ 102 | static NativeHandle GetNative( void const * key ) 103 | { 104 | if( ! key ) return 0; 105 | else 106 | { 107 | typename OneOfUsT::iterator it = Map().find(key); 108 | return (Map().end() == it) 109 | ? 0 110 | : (*it).second.first; 111 | } 112 | } 113 | 114 | /** 115 | Returns the JS object associated with key, or 116 | an empty handle if !key or no object is found. 117 | */ 118 | static v8::Handle GetJSObject( void const * key ) 119 | { 120 | if( ! key ) return v8::Handle(); 121 | typename OneOfUsT::const_iterator it = Map().find(key); 122 | if( Map().end() == it ) return v8::Handle(); 123 | else return (*it).second.second; 124 | } 125 | 126 | /** 127 | A base NativeToJS implementation for classes which use NativeToJSMap 128 | to hold their native-to-JS bindings. To be used like this: 129 | 130 | @code 131 | // must be in the v8::convert namespace! 132 | template <> 133 | struct NativeToJS : NativeToJSMap::NativeToJSImpl {}; 134 | @endcode 135 | */ 136 | struct NativeToJSImpl 137 | { 138 | v8::Handle operator()( Type const * n ) const 139 | { 140 | typedef NativeToJSMap BM; 141 | v8::Handle const & rc( BM::GetJSObject(n) ); 142 | if( rc.IsEmpty() ) return v8::Null(); 143 | else return rc; 144 | } 145 | v8::Handle operator()( Type const & n ) const 146 | { 147 | return this->operator()( &n ); 148 | } 149 | }; 150 | 151 | #if 0 152 | //! Experimental 153 | template 154 | struct NativeToJSImpl_Subclass 155 | { 156 | v8::Handle operator()( Type const * n ) const 157 | { 158 | typedef NativeToJSMap BM; 159 | v8::Handle const & rc( BM::GetJSObject(n) ); 160 | if( rc.IsEmpty() ) 161 | { 162 | typedef typename NativeToJSMap::NativeToJSImpl PI; 163 | return PI()(n); 164 | #if 0 165 | typedef typename TypeInfo::NativeHandle PH; 166 | rc = CastToJS(n); 167 | if( rc.IsEmpty() ) return v8::Null(); 168 | else return rc; 169 | #endif 170 | } 171 | else return rc; 172 | } 173 | v8::Handle operator()( Type const & n ) const 174 | { 175 | return this->operator()( &n ); 176 | } 177 | }; 178 | #endif 179 | }; 180 | 181 | } // namespaces 182 | 183 | #endif /* include guard */ 184 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/v8-convert.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(CODE_GOOGLE_COM_P_V8_CONVERT_V8_CONVERT_HPP_INCLUDED) 2 | #define CODE_GOOGLE_COM_P_V8_CONVERT_V8_CONVERT_HPP_INCLUDED 1 3 | 4 | // Doxygen REFUSES to use this block as namespace docs: @namespace cvv8 5 | /** @mainpage libv8-convert (cvv8) 6 | 7 | The cvv8 namespace (formerly v8::convert) houses APIs for handling the 8 | following: 9 | 10 | - Converting between v8 Value handles and "native types" using generic 11 | interface. This allows us to write generic algorithms which convert 12 | between JS/C++ without having to know the exact types we're dealing 13 | with. The basic POD types and some STL types are supported out of the 14 | box and plugging in one's own types is normally quite simple. 15 | 16 | - Converting free- and member functions into v8::InvocationCallback 17 | functions. These generated functions convert the JavaScript-originated 18 | function arguments into native counterparts, forward the data to the 19 | original native function, and convert the return values back to 20 | something JS can use. 21 | 22 | Those two core features give us all we need in order to be able to 23 | bind near-arbitrary C/C++ functions with JavaScript (where calling 24 | conventions and type conversions allow us to do so). For cases where 25 | the "automatic" function-to-InvocationCallback conversions are not 26 | suitable, the type-conversion API can simplify the implementation of 27 | custom v8::InvocationCallback functions. 28 | 29 | All of the conversions are compile-time typesafe where possible and 30 | fail gracefully when such a determination can only be made at runtime. 31 | 32 | This code originated as the core-most component of the v8-juice 33 | library (http://code.google.com/p/v8-juice). After a couple years 34 | i felt compelled to refactor it into a toolkit usable by arbitrary 35 | v8-using clients, doing a bit of cleanup along the way. The eventuall 36 | intention is that this code will replace the v8::juice::convert 37 | code. 38 | 39 | Author: Stephan Beal (http://wanderinghorse.net/home/stephan/) 40 | 41 | License: Dual MIT/Public Domain 42 | 43 | Project home page: http://code.google.com/p/v8-juice/wiki/V8Convert 44 | 45 | The most important functions and types, from a user's perspective, 46 | include: 47 | 48 | Converting types: 49 | 50 | - cvv8::CastToJS() 51 | - cvv8::CastFromJS() 52 | 53 | Implementing custom conversions: 54 | 55 | - cvv8::NativeToJS 56 | - cvv8::JSToNative 57 | 58 | Converting functions to v8::InvocationCallback: 59 | 60 | - cvv8::FunctionToInCa 61 | - cvv8::MethodToInCa 62 | - cvv8::ConstMethodToInCa 63 | - cvv8::ToInCa 64 | - cvv8::FunctorToInCa 65 | - cvv8::PredicatedInCa and cvv8::PredicatedInCaDispatcher 66 | 67 | Binding JS properties to native properties, functions, methods, or 68 | functors: 69 | 70 | - cvv8::FunctionToGetter, cvv8::FunctionToSetter 71 | - cvv8::MethodToGetter, cvv8::MethodToSetter 72 | - cvv8::ConstMethodToGetter, cvv8::ConstMethodToSetter 73 | - cvv8::FunctorToGetter, cvv8::FunctorToSetter 74 | 75 | Other utilities: 76 | 77 | - cvv8::CtorForwarder and cvv8::CtorArityDispatcher 78 | - cvv8::ClassCreator simplifies binding of C++ classes with v8. 79 | - cvv8::FunctionTo converts functions to ... 80 | - cvv8::MethodTo converts methods to ... 81 | - cvv8::FunctorTo converts functors to ... 82 | - cvv8::VarTo converts variables to ... 83 | - cvv8::CallForwarder forwards native arguments to JS functions. 84 | - The tmp and sl namespaces hold various template metaprogramming bits. 85 | - ... there's more ... 86 | 87 | Most of the code in this library are internal template specializations 88 | which take care of the dirty work. Typical clients won't typically need 89 | more than what's listed above. 90 | 91 | A core rule of this library is "if it ain't documented, don't use 92 | it." All public API members which are intended for client-side use 93 | are documented. Some one-line proxies whose purpose is either very 94 | obvious, exist only for template type resolution reasons, or 95 | are strictly internal are not necessarily documented. 96 | 97 | */ 98 | namespace cvv8 { 99 | } 100 | 101 | #include "convert.hpp" 102 | #include "invocable.hpp" 103 | #include "arguments.hpp" 104 | #include "ClassCreator.hpp" 105 | #include "properties.hpp" 106 | #include "XTo.hpp" 107 | /** LICENSE 108 | 109 | This software's source code, including accompanying documentation and 110 | demonstration applications, are licensed under the following 111 | conditions... 112 | 113 | The author (Stephan G. Beal [http://wanderinghorse.net/home/stephan/]) 114 | explicitly disclaims copyright in all jurisdictions which recognize 115 | such a disclaimer. In such jurisdictions, this software is released 116 | into the Public Domain. 117 | 118 | In jurisdictions which do not recognize Public Domain property 119 | (e.g. Germany as of 2011), this software is Copyright (c) 2011 120 | by Stephan G. Beal, and is released under the terms of the MIT License 121 | (see below). 122 | 123 | In jurisdictions which recognize Public Domain property, the user of 124 | this software may choose to accept it either as 1) Public Domain, 2) 125 | under the conditions of the MIT License (see below), or 3) under the 126 | terms of dual Public Domain/MIT License conditions described here, as 127 | they choose. 128 | 129 | The MIT License is about as close to Public Domain as a license can 130 | get, and is described in clear, concise terms at: 131 | 132 | http://en.wikipedia.org/wiki/MIT_License 133 | 134 | The full text of the MIT License follows: 135 | 136 | -- 137 | Copyright (c) 2011 Stephan G. Beal (http://wanderinghorse.net/home/stephan/) 138 | 139 | Permission is hereby granted, free of charge, to any person 140 | obtaining a copy of this software and associated documentation 141 | files (the "Software"), to deal in the Software without 142 | restriction, including without limitation the rights to use, 143 | copy, modify, merge, publish, distribute, sublicense, and/or sell 144 | copies of the Software, and to permit persons to whom the 145 | Software is furnished to do so, subject to the following 146 | conditions: 147 | 148 | The above copyright notice and this permission notice shall be 149 | included in all copies or substantial portions of the Software. 150 | 151 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 152 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 153 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 154 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 155 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 156 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 157 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 158 | OTHER DEALINGS IN THE SOFTWARE. 159 | 160 | --END OF MIT LICENSE-- 161 | 162 | For purposes of the above license, the term "Software" includes 163 | documentation and demonstration source code which accompanies 164 | this software. ("Accompanies" = is contained in the Software's 165 | primary public source code repository.) 166 | 167 | */ 168 | 169 | #endif /* CODE_GOOGLE_COM_P_V8_CONVERT_V8_CONVERT_HPP_INCLUDED */ 170 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/node-gitteh.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/node-gitteh.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/node-gitteh" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/node-gitteh" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # node-gitteh documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Jul 23 14:08:21 2013. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = ["sphinx.ext.autodoc", "sphinxcontrib.coffeedomain"] 29 | 30 | coffee_src_dir = os.path.abspath('../src') 31 | 32 | # Add any paths that contain templates here, relative to this directory. 33 | templates_path = ['_templates'] 34 | 35 | # The suffix of source filenames. 36 | source_suffix = '.rst' 37 | 38 | # The encoding of source files. 39 | #source_encoding = 'utf-8-sig' 40 | 41 | # The master toctree document. 42 | master_doc = 'index' 43 | 44 | # General information about the project. 45 | project = u'node-gitteh' 46 | copyright = u'2013, Sam Day' 47 | 48 | # The version info for the project you're documenting, acts as replacement for 49 | # |version| and |release|, also used in various other places throughout the 50 | # built documents. 51 | # 52 | # The short X.Y version. 53 | version = '0.17.2' 54 | # The full version, including alpha/beta/rc tags. 55 | release = '0.17.2' 56 | 57 | # The language for content autogenerated by Sphinx. Refer to documentation 58 | # for a list of supported languages. 59 | #language = None 60 | 61 | # There are two options for replacing |today|: either, you set today to some 62 | # non-false value, then it is used: 63 | #today = '' 64 | # Else, today_fmt is used as the format for a strftime call. 65 | #today_fmt = '%B %d, %Y' 66 | 67 | # List of patterns, relative to source directory, that match files and 68 | # directories to ignore when looking for source files. 69 | exclude_patterns = ['_build'] 70 | 71 | # The reST default role (used for this markup: `text`) to use for all documents. 72 | #default_role = None 73 | 74 | # If true, '()' will be appended to :func: etc. cross-reference text. 75 | #add_function_parentheses = True 76 | 77 | # If true, the current module name will be prepended to all description 78 | # unit titles (such as .. function::). 79 | #add_module_names = True 80 | 81 | # If true, sectionauthor and moduleauthor directives will be shown in the 82 | # output. They are ignored by default. 83 | #show_authors = False 84 | 85 | # The name of the Pygments (syntax highlighting) style to use. 86 | pygments_style = 'sphinx' 87 | 88 | # A list of ignored prefixes for module index sorting. 89 | #modindex_common_prefix = [] 90 | 91 | # If true, keep warnings as "system message" paragraphs in the built documents. 92 | #keep_warnings = False 93 | 94 | 95 | # -- Options for HTML output --------------------------------------------------- 96 | 97 | # The theme to use for HTML and HTML Help pages. See the documentation for 98 | # a list of builtin themes. 99 | html_theme = 'default' 100 | 101 | # Theme options are theme-specific and customize the look and feel of a theme 102 | # further. For a list of options available for each theme, see the 103 | # documentation. 104 | #html_theme_options = {} 105 | 106 | # Add any paths that contain custom themes here, relative to this directory. 107 | #html_theme_path = [] 108 | 109 | # The name for this set of Sphinx documents. If None, it defaults to 110 | # " v documentation". 111 | #html_title = None 112 | 113 | # A shorter title for the navigation bar. Default is the same as html_title. 114 | #html_short_title = None 115 | 116 | # The name of an image file (relative to this directory) to place at the top 117 | # of the sidebar. 118 | #html_logo = None 119 | 120 | # The name of an image file (within the static path) to use as favicon of the 121 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 122 | # pixels large. 123 | #html_favicon = None 124 | 125 | # Add any paths that contain custom static files (such as style sheets) here, 126 | # relative to this directory. They are copied after the builtin static files, 127 | # so a file named "default.css" will overwrite the builtin "default.css". 128 | html_static_path = ['_static'] 129 | 130 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 131 | # using the given strftime format. 132 | #html_last_updated_fmt = '%b %d, %Y' 133 | 134 | # If true, SmartyPants will be used to convert quotes and dashes to 135 | # typographically correct entities. 136 | #html_use_smartypants = True 137 | 138 | # Custom sidebar templates, maps document names to template names. 139 | #html_sidebars = {} 140 | 141 | # Additional templates that should be rendered to pages, maps page names to 142 | # template names. 143 | #html_additional_pages = {} 144 | 145 | # If false, no module index is generated. 146 | #html_domain_indices = True 147 | 148 | # If false, no index is generated. 149 | #html_use_index = True 150 | 151 | # If true, the index is split into individual pages for each letter. 152 | #html_split_index = False 153 | 154 | # If true, links to the reST sources are added to the pages. 155 | #html_show_sourcelink = True 156 | 157 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 158 | #html_show_sphinx = True 159 | 160 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 161 | #html_show_copyright = True 162 | 163 | # If true, an OpenSearch description file will be output, and all pages will 164 | # contain a tag referring to it. The value of this option must be the 165 | # base URL from which the finished HTML is served. 166 | #html_use_opensearch = '' 167 | 168 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 169 | #html_file_suffix = None 170 | 171 | # Output file base name for HTML help builder. 172 | htmlhelp_basename = 'node-gittehdoc' 173 | 174 | 175 | # -- Options for LaTeX output -------------------------------------------------- 176 | 177 | latex_elements = { 178 | # The paper size ('letterpaper' or 'a4paper'). 179 | #'papersize': 'letterpaper', 180 | 181 | # The font size ('10pt', '11pt' or '12pt'). 182 | #'pointsize': '10pt', 183 | 184 | # Additional stuff for the LaTeX preamble. 185 | #'preamble': '', 186 | } 187 | 188 | # Grouping the document tree into LaTeX files. List of tuples 189 | # (source start file, target name, title, author, documentclass [howto/manual]). 190 | latex_documents = [ 191 | ('index', 'node-gitteh.tex', u'node-gitteh Documentation', 192 | u'Sam Day', 'manual'), 193 | ] 194 | 195 | # The name of an image file (relative to this directory) to place at the top of 196 | # the title page. 197 | #latex_logo = None 198 | 199 | # For "manual" documents, if this is true, then toplevel headings are parts, 200 | # not chapters. 201 | #latex_use_parts = False 202 | 203 | # If true, show page references after internal links. 204 | #latex_show_pagerefs = False 205 | 206 | # If true, show URL addresses after external links. 207 | #latex_show_urls = False 208 | 209 | # Documents to append as an appendix to all manuals. 210 | #latex_appendices = [] 211 | 212 | # If false, no module index is generated. 213 | #latex_domain_indices = True 214 | 215 | 216 | # -- Options for manual page output -------------------------------------------- 217 | 218 | # One entry per manual page. List of tuples 219 | # (source start file, name, description, authors, manual section). 220 | man_pages = [ 221 | ('index', 'node-gitteh', u'node-gitteh Documentation', 222 | [u'Sam Day'], 1) 223 | ] 224 | 225 | # If true, show URL addresses after external links. 226 | #man_show_urls = False 227 | 228 | 229 | # -- Options for Texinfo output ------------------------------------------------ 230 | 231 | # Grouping the document tree into Texinfo files. List of tuples 232 | # (source start file, target name, title, author, 233 | # dir menu entry, description, category) 234 | texinfo_documents = [ 235 | ('index', 'node-gitteh', u'node-gitteh Documentation', 236 | u'Sam Day', 'node-gitteh', 'One line description of project.', 237 | 'Miscellaneous'), 238 | ] 239 | 240 | # Documents to append as an appendix to all manuals. 241 | #texinfo_appendices = [] 242 | 243 | # If false, no module index is generated. 244 | #texinfo_domain_indices = True 245 | 246 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 247 | #texinfo_show_urls = 'footnote' 248 | 249 | # If true, do not generate a @detailmenu in the "Top" node's menu. 250 | #texinfo_no_detailmenu = False 251 | 252 | 253 | primary_domain = 'coffee' -------------------------------------------------------------------------------- /src/remote.cc: -------------------------------------------------------------------------------- 1 | #include "remote.h" 2 | #include "git2/strarray.h" 3 | 4 | using std::map; 5 | using std::pair; 6 | 7 | namespace gitteh { 8 | static Persistent class_symbol; 9 | static Persistent name_symbol; 10 | static Persistent url_symbol; 11 | static Persistent fetchspecs_symbol; 12 | static Persistent pushspecs_symbol; 13 | static Persistent progress_symbol; 14 | 15 | static Persistent refspec_src_symbol; 16 | static Persistent refspec_dst_symbol; 17 | 18 | static Persistent progress_total_objects_symbol; 19 | static Persistent progress_indexed_objects_symbol; 20 | static Persistent progress_received_objects_symbol; 21 | static Persistent progress_received_bytes_symbol; 22 | 23 | class RemoteBaton : public Baton { 24 | public: 25 | Remote *remote_; 26 | 27 | RemoteBaton(Remote *remote) : Baton(), remote_(remote) { 28 | remote_->Ref(); 29 | } 30 | 31 | ~RemoteBaton() { 32 | remote_->Unref(); 33 | } 34 | }; 35 | 36 | class UpdateTipsBaton : public RemoteBaton { 37 | public: 38 | UpdateTipsBaton(Remote *remote) : RemoteBaton(remote) { } 39 | }; 40 | 41 | class ConnectBaton : public RemoteBaton { 42 | public: 43 | git_direction direction; 44 | map refs; 45 | 46 | ConnectBaton(Remote *remote, int direction) : 47 | RemoteBaton(remote), direction((git_direction)direction) { } 48 | }; 49 | 50 | class DownloadBaton : public RemoteBaton { 51 | public: 52 | git_off_t *bytes; 53 | git_transfer_progress *stats; 54 | DownloadBaton(Remote *remote) : 55 | RemoteBaton(remote) { } 56 | }; 57 | 58 | static int SaveRemoteRef(git_remote_head *head, void *payload) { 59 | ConnectBaton *baton = static_cast(payload); 60 | baton->refs.insert(pair(string(head->name), head->oid)); 61 | return GIT_OK; 62 | } 63 | 64 | Persistent Remote::constructor_template; 65 | 66 | Remote::Remote(git_remote *remote) : ObjectWrap() { 67 | remote_ = remote; 68 | } 69 | 70 | Remote::~Remote() { 71 | if(remote_ != NULL) { 72 | git_remote_free(remote_); 73 | remote_ = NULL; 74 | } 75 | } 76 | 77 | void Remote::Init(Handle target) { 78 | NanScope(); 79 | 80 | class_symbol = NODE_PSYMBOL("NativeRemote"); 81 | name_symbol = NODE_PSYMBOL("name"); 82 | url_symbol = NODE_PSYMBOL("url"); 83 | fetchspecs_symbol = NODE_PSYMBOL("fetchSpecs"); 84 | pushspecs_symbol = NODE_PSYMBOL("pushSpecs"); 85 | progress_symbol = NODE_PSYMBOL("progress"); 86 | 87 | refspec_src_symbol = NODE_PSYMBOL("src"); 88 | refspec_dst_symbol = NODE_PSYMBOL("dst"); 89 | 90 | progress_total_objects_symbol = NODE_PSYMBOL("totalObjects"); 91 | progress_indexed_objects_symbol = NODE_PSYMBOL("indexedObjects"); 92 | progress_received_objects_symbol = NODE_PSYMBOL("receivedObjects"); 93 | progress_received_bytes_symbol = NODE_PSYMBOL("receivedBytes"); 94 | 95 | Local t = NanNew(New); 96 | NanAssignPersistent(constructor_template, t); 97 | constructor_template->SetClassName(class_symbol); 98 | t->InstanceTemplate()->SetInternalFieldCount(1); 99 | 100 | NODE_SET_PROTOTYPE_METHOD(t, "updateTips", UpdateTips); 101 | NODE_SET_PROTOTYPE_METHOD(t, "connect", Connect); 102 | NODE_SET_PROTOTYPE_METHOD(t, "download", Download); 103 | 104 | target->Set(class_symbol, constructor_template->GetFunction()); 105 | } 106 | 107 | NAN_METHOD(Remote::New) { 108 | NanEscapableScope(); 109 | REQ_EXT_ARG(0, remoteArg); 110 | Handle me = args.This(); 111 | 112 | git_remote *remote = static_cast(remoteArg->Value()); 113 | Remote *remoteObj = new Remote(remote); 114 | remoteObj->Wrap(me); 115 | 116 | // Get the fetch- and push-specs 117 | Handle fetchspecsArr = NanNew(); 118 | git_strarray fetchspecs = {NULL, 0}; 119 | if (!git_remote_get_fetch_refspecs(&fetchspecs, remote)) { 120 | for (size_t i=0; iSet(i, CastToJS(fetchspecs.strings[i])); 122 | } 123 | me->Set(fetchspecs_symbol, fetchspecsArr); 124 | 125 | Handle pushspecsArr = NanNew(); 126 | git_strarray pushspecs = {NULL, 0}; 127 | if (!git_remote_get_push_refspecs(&pushspecs, remote)) { 128 | for (size_t i=0; iSet(i, CastToJS(pushspecs.strings[i])); 130 | } 131 | me->Set(pushspecs_symbol, pushspecsArr); 132 | 133 | me->Set(name_symbol, CastToJS(git_remote_name(remote))); 134 | me->Set(url_symbol, CastToJS(git_remote_url(remote))); 135 | 136 | return NanEscapeScope(me); 137 | } 138 | 139 | NAN_METHOD(Remote::UpdateTips) { 140 | NanScope(); 141 | Remote *remote = ObjectWrap::Unwrap(args.This()); 142 | UpdateTipsBaton *baton = new UpdateTipsBaton(remote); 143 | baton->setCallback(args[0]); 144 | uv_queue_work(uv_default_loop(), &baton->req, AsyncUpdateTips, 145 | NODE_094_UV_AFTER_WORK_CAST(AsyncAfterUpdateTips)); 146 | return NanUndefined(); 147 | } 148 | 149 | void Remote::AsyncUpdateTips(uv_work_t *req) { 150 | UpdateTipsBaton *baton = GetBaton(req); 151 | // TODO: use the callback to get changed refs once fn accepts a payload 152 | AsyncLibCall(git_remote_update_tips(baton->remote_->remote_), 153 | baton); 154 | } 155 | 156 | void Remote::AsyncAfterUpdateTips(uv_work_t *req) { 157 | NanScope(); 158 | UpdateTipsBaton *baton = GetBaton(req); 159 | 160 | if(baton->isErrored()) { 161 | Handle argv[] = { baton->createV8Error() }; 162 | FireCallback(baton->callback, 1, argv); 163 | } 164 | else { 165 | Handle argv[] = { Undefined() }; 166 | FireCallback(baton->callback, 1, argv); 167 | } 168 | 169 | delete baton; 170 | } 171 | 172 | NAN_METHOD(Remote::Connect) { 173 | NanScope(); 174 | Remote *remote = ObjectWrap::Unwrap(args.This()); 175 | ConnectBaton *baton = new ConnectBaton(remote, CastFromJS(args[0])); 176 | baton->setCallback(args[1]); 177 | uv_queue_work(uv_default_loop(), &baton->req, AsyncConnect, 178 | NODE_094_UV_AFTER_WORK_CAST(AsyncAfterConnect)); 179 | return NanUndefined(); 180 | } 181 | 182 | void Remote::AsyncConnect(uv_work_t *req) { 183 | ConnectBaton *baton = GetBaton(req); 184 | if(AsyncLibCall(git_remote_connect(baton->remote_->remote_, 185 | baton->direction), baton)) { 186 | git_remote_ls(baton->remote_->remote_, SaveRemoteRef, baton); 187 | } 188 | } 189 | 190 | void Remote::AsyncAfterConnect(uv_work_t *req) { 191 | HandleScope scope; 192 | ConnectBaton *baton = GetBaton(req); 193 | 194 | if(baton->isErrored()) { 195 | Handle argv[] = { baton->createV8Error() }; 196 | FireCallback(baton->callback, 1, argv); 197 | } 198 | else { 199 | Handle argv[] = { Undefined(), CastToJS(baton->refs) }; 200 | FireCallback(baton->callback, 2, argv); 201 | } 202 | 203 | delete baton; 204 | } 205 | 206 | NAN_METHOD(Remote::Download) { 207 | NanScope(); 208 | Remote *remote = ObjectWrap::Unwrap(args.This()); 209 | DownloadBaton *baton = new DownloadBaton(remote); 210 | baton->setCallback(args[0]); 211 | baton->bytes = &remote->downloadBytes_; 212 | baton->stats = &remote->progress_; 213 | 214 | // Re-initialize stat counters. 215 | remote->downloadBytes_ = 0; 216 | memset(&remote->progress_, 0, sizeof(git_transfer_progress)); 217 | 218 | // Setup download stats accessor. 219 | remote->handle_->SetAccessor(progress_symbol, GetStats); 220 | 221 | uv_queue_work(uv_default_loop(), &baton->req, AsyncDownload, 222 | NODE_094_UV_AFTER_WORK_CAST(AsyncAfterDownload)); 223 | return NanUndefined(); 224 | } 225 | 226 | int Remote::DownloadTransferProgressCallback( 227 | const git_transfer_progress *stats, 228 | void *payload) 229 | { 230 | DownloadBaton *baton = (DownloadBaton*)payload; 231 | baton->remote_->progress_ = *stats; 232 | return 0; 233 | } 234 | 235 | void Remote::AsyncDownload(uv_work_t *req) { 236 | DownloadBaton *baton = GetBaton(req); 237 | AsyncLibCall(git_remote_download(baton->remote_->remote_, 238 | DownloadTransferProgressCallback, baton), baton); 239 | } 240 | 241 | void Remote::AsyncAfterDownload(uv_work_t *req) { 242 | HandleScope scope; 243 | DownloadBaton *baton = GetBaton(req); 244 | 245 | baton->remote_->handle_->Delete(progress_symbol); 246 | 247 | if(baton->isErrored()) { 248 | Handle argv[] = { baton->createV8Error() }; 249 | FireCallback(baton->callback, 1, argv); 250 | } 251 | else { 252 | Handle argv[] = { Undefined() }; 253 | FireCallback(baton->callback, 1, argv); 254 | } 255 | 256 | delete baton; 257 | } 258 | 259 | NAN_GETTER(Remote::GetStats) { 260 | NanEscapableScope(); 261 | Remote *remote = ObjectWrap::Unwrap(args.This()); 262 | Handle o = NanNew(); 263 | o->Set(progress_total_objects_symbol, CastToJS(remote->progress_.total_objects)); 264 | o->Set(progress_indexed_objects_symbol, CastToJS(remote->progress_.indexed_objects)); 265 | o->Set(progress_received_objects_symbol, CastToJS(remote->progress_.received_objects)); 266 | o->Set(progress_received_bytes_symbol, CastToJS(remote->progress_.received_bytes)); 267 | return NanEscapeScope(o); 268 | } 269 | 270 | }; // namespace gitteh 271 | 272 | 273 | namespace cvv8 { 274 | template<> 275 | struct NativeToJS { 276 | Handle operator() (git_refspec const *refspec) const { 277 | NanEscapableScope(); 278 | Handle o = NanNew(); 279 | o->Set(gitteh::refspec_src_symbol, CastToJS(git_refspec_src(refspec))); 280 | o->Set(gitteh::refspec_dst_symbol, CastToJS(git_refspec_dst(refspec))); 281 | return NanEscapeScope(o); 282 | } 283 | }; 284 | } 285 | -------------------------------------------------------------------------------- /deps/libgit2.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'targets': [{ 3 | 'target_name': 'libgit2', 4 | 'type': 'static_library', 5 | 6 | 'defines': [ 7 | 'GIT_THREADS', 8 | 'SRC_UTIL_H_' 9 | ], 10 | 11 | 'dependencies': [ 12 | 'zlib', 13 | 'http_parser' 14 | ], 15 | 16 | 'direct_dependent_settings': { 17 | 'include_dirs': [ 18 | 'libgit2/include' 19 | ] 20 | }, 21 | 22 | 'include_dirs': [ 23 | 'libgit2/include', 24 | 'libgit2/src', 25 | 'libgit2/deps/regex' 26 | ], 27 | 28 | 'sources': [ 29 | 'libgit2/src/array.h', 30 | 'libgit2/src/attr_file.c', 31 | 'libgit2/src/attr_file.h', 32 | 'libgit2/src/attr.c', 33 | 'libgit2/src/attr.h', 34 | 'libgit2/src/blob.c', 35 | 'libgit2/src/blob.h', 36 | 'libgit2/src/branch.c', 37 | 'libgit2/src/branch.h', 38 | 'libgit2/src/bswap.h', 39 | 'libgit2/src/buf_text.c', 40 | 'libgit2/src/buf_text.h', 41 | 'libgit2/src/buffer.c', 42 | 'libgit2/src/buffer.h', 43 | 'libgit2/src/cache.c', 44 | 'libgit2/src/cache.h', 45 | 'libgit2/src/cc-compact.h', 46 | 'libgit2/src/checkout.c', 47 | 'libgit2/src/checkout.h', 48 | 'libgit2/src/clone.c', 49 | 'libgit2/src/commit_list.c', 50 | 'libgit2/src/commit_list.h', 51 | 'libgit2/src/commit.c', 52 | 'libgit2/src/commit.h', 53 | 'libgit2/src/common.h', 54 | 'libgit2/src/compress.c', 55 | 'libgit2/src/compress.h', 56 | 'libgit2/src/config_cache.c', 57 | 'libgit2/src/config_file.c', 58 | 'libgit2/src/config_file.h', 59 | 'libgit2/src/config.c', 60 | 'libgit2/src/config.h', 61 | 'libgit2/src/crlf.c', 62 | 'libgit2/src/date.c', 63 | 'libgit2/src/delta-apply.c', 64 | 'libgit2/src/delta-apply.h', 65 | 'libgit2/src/delta.c', 66 | 'libgit2/src/delta.h', 67 | 'libgit2/src/diff_driver.c', 68 | 'libgit2/src/diff_driver.h', 69 | 'libgit2/src/diff_file.c', 70 | 'libgit2/src/diff_file.h', 71 | 'libgit2/src/diff_patch.c', 72 | 'libgit2/src/diff_patch.h', 73 | 'libgit2/src/diff_print.c', 74 | 'libgit2/src/diff_tform.c', 75 | 'libgit2/src/diff_xdiff.c', 76 | 'libgit2/src/diff_xdiff.h', 77 | 'libgit2/src/diff.c', 78 | 'libgit2/src/diff.h', 79 | 'libgit2/src/errors.c', 80 | 'libgit2/src/fetch.c', 81 | 'libgit2/src/fetch.h', 82 | 'libgit2/src/fetchhead.c', 83 | 'libgit2/src/fetchhead.h', 84 | 'libgit2/src/filebuf.c', 85 | 'libgit2/src/filebuf.h', 86 | 'libgit2/src/fileops.c', 87 | 'libgit2/src/fileops.h', 88 | 'libgit2/src/filter.c', 89 | 'libgit2/src/filter.h', 90 | 'libgit2/src/fnmatch.c', 91 | 'libgit2/src/fnmatch.h', 92 | 'libgit2/src/global.c', 93 | 'libgit2/src/global.h', 94 | 'libgit2/src/graph.c', 95 | 'libgit2/src/hash.c', 96 | 'libgit2/src/hash.h', 97 | 'libgit2/src/hashsig.c', 98 | 'libgit2/src/hashsig.h', 99 | 'libgit2/src/ignore.c', 100 | 'libgit2/src/ignore.h', 101 | 'libgit2/src/index.c', 102 | 'libgit2/src/index.h', 103 | 'libgit2/src/indexer.c', 104 | 'libgit2/src/iterator.c', 105 | 'libgit2/src/iterator.h', 106 | 'libgit2/src/khash.h', 107 | 'libgit2/src/map.h', 108 | 'libgit2/src/merge_file.c', 109 | 'libgit2/src/merge_file.h', 110 | 'libgit2/src/merge.c', 111 | 'libgit2/src/merge.h', 112 | 'libgit2/src/message.c', 113 | 'libgit2/src/message.h', 114 | 'libgit2/src/mwindow.c', 115 | 'libgit2/src/mwindow.h', 116 | 'libgit2/src/netops.c', 117 | 'libgit2/src/netops.h', 118 | 'libgit2/src/notes.c', 119 | 'libgit2/src/notes.h', 120 | 'libgit2/src/object_api.c', 121 | 'libgit2/src/object.c', 122 | 'libgit2/src/object.h', 123 | 'libgit2/src/odb_loose.c', 124 | 'libgit2/src/odb_pack.c', 125 | 'libgit2/src/odb.c', 126 | 'libgit2/src/odb.h', 127 | 'libgit2/src/offmap.h', 128 | 'libgit2/src/oid.c', 129 | 'libgit2/src/oid.h', 130 | 'libgit2/src/oidmap.h', 131 | 'libgit2/src/pack-objects.c', 132 | 'libgit2/src/pack-objects.h', 133 | 'libgit2/src/pack.c', 134 | 'libgit2/src/pack.h', 135 | 'libgit2/src/path.c', 136 | 'libgit2/src/path.h', 137 | 'libgit2/src/pathspec.c', 138 | 'libgit2/src/pathspec.h', 139 | 'libgit2/src/pool.c', 140 | 'libgit2/src/pool.h', 141 | 'libgit2/src/posix.c', 142 | 'libgit2/src/posix.h', 143 | 'libgit2/src/pqueue.c', 144 | 'libgit2/src/pqueue.h', 145 | 'libgit2/src/push.c', 146 | 'libgit2/src/push.h', 147 | 'libgit2/src/refdb_fs.c', 148 | 'libgit2/src/refdb_fs.h', 149 | 'libgit2/src/refdb.c', 150 | 'libgit2/src/refdb.h', 151 | 'libgit2/src/reflog.c', 152 | 'libgit2/src/reflog.h', 153 | 'libgit2/src/refs.c', 154 | 'libgit2/src/refs.h', 155 | 'libgit2/src/refspec.c', 156 | 'libgit2/src/refspec.h', 157 | 'libgit2/src/remote.c', 158 | 'libgit2/src/remote.h', 159 | 'libgit2/src/repo_template.h', 160 | 'libgit2/src/repository.c', 161 | 'libgit2/src/repository.h', 162 | 'libgit2/src/reset.c', 163 | 'libgit2/src/revparse.c', 164 | 'libgit2/src/revwalk.c', 165 | 'libgit2/src/revwalk.h', 166 | 'libgit2/src/sha1_lookup.c', 167 | 'libgit2/src/sha1_lookup.h', 168 | 'libgit2/src/signature.c', 169 | 'libgit2/src/signature.h', 170 | 'libgit2/src/stash.c', 171 | 'libgit2/src/status.c', 172 | 'libgit2/src/status.h', 173 | 'libgit2/src/strmap.h', 174 | 'libgit2/src/submodule.c', 175 | 'libgit2/src/submodule.h', 176 | 'libgit2/src/tag.c', 177 | 'libgit2/src/tag.h', 178 | 'libgit2/src/thread-utils.c', 179 | 'libgit2/src/thread-utils.h', 180 | 'libgit2/src/trace.c', 181 | 'libgit2/src/trace.h', 182 | 'libgit2/src/transport.c', 183 | 'libgit2/src/tree-cache.c', 184 | 'libgit2/src/tree-cache.h', 185 | 'libgit2/src/tree.c', 186 | 'libgit2/src/tree.h', 187 | 'libgit2/src/tsort.c', 188 | 'libgit2/src/util.c', 189 | 'libgit2/src/util.h', 190 | 'libgit2/src/vector.c', 191 | 'libgit2/src/vector.h', 192 | 'libgit2/src/hash/hash_generic.c', 193 | 'libgit2/src/hash/hash_generic.h', 194 | 'libgit2/src/hash/openssl.h', 195 | 'libgit2/src/transports/cred_helpers.c', 196 | 'libgit2/src/transports/cred.c', 197 | 'libgit2/src/transports/git.c', 198 | 'libgit2/src/transports/http.c', 199 | 'libgit2/src/transports/local.c', 200 | 'libgit2/src/transports/smart_pkt.c', 201 | 'libgit2/src/transports/smart_protocol.c', 202 | 'libgit2/src/transports/smart.c', 203 | 'libgit2/src/transports/smart.h', 204 | 'libgit2/src/transports/ssh.c', 205 | 'libgit2/src/transports/winhttp.c', 206 | 'libgit2/src/xdiff/xdiff.h', 207 | 'libgit2/src/xdiff/xdiffi.c', 208 | 'libgit2/src/xdiff/xdiffi.h', 209 | 'libgit2/src/xdiff/xemit.c', 210 | 'libgit2/src/xdiff/xemit.h', 211 | 'libgit2/src/xdiff/xhistogram.c', 212 | 'libgit2/src/xdiff/xinclude.h', 213 | 'libgit2/src/xdiff/xmacros.h', 214 | 'libgit2/src/xdiff/xmerge.c', 215 | 'libgit2/src/xdiff/xpatience.c', 216 | 'libgit2/src/xdiff/xprepare.c', 217 | 'libgit2/src/xdiff/xprepare.h', 218 | 'libgit2/src/xdiff/xtypes.h', 219 | 'libgit2/src/xdiff/xutils.c', 220 | 'libgit2/src/xdiff/xutils.h' 221 | ], 222 | 223 | 'conditions': [ 224 | ["OS=='linux'", { 225 | 'cflags': [ 226 | '-w' 227 | ] 228 | }], 229 | 230 | ["OS!='win'", { 231 | 'libraries': [ 232 | '-lpthread' 233 | ], 234 | 235 | 'sources': [ 236 | 'libgit2/src/unix/map.c', 237 | 'libgit2/src/unix/posix.h', 238 | 'libgit2/src/unix/realpath.c' 239 | ], 240 | 241 | 'cflags': [ 242 | '-Wno-missing-field-initializers', 243 | '-Wno-unused-variable' 244 | ], 245 | 246 | 'xcode_settings': { 247 | 'WARNING_CFLAGS': [ 248 | '-Wno-missing-field-initializers', 249 | '-Wno-unused-variable' 250 | ] 251 | } 252 | }] 253 | ] 254 | }, { 255 | 'target_name': 'zlib', 256 | 'type': 'static_library', 257 | 258 | 'defines': [ 259 | 'NO_VIZ', 260 | 'STDC', 261 | 'NO_GZIP' 262 | ], 263 | 264 | 'include_dirs': [ 265 | 'libgit2/include/', 266 | 'libgit2/deps/regex/' 267 | ], 268 | 269 | 'direct_dependent_settings': { 270 | 'include_dirs': [ 271 | 'libgit2/deps/zlib' 272 | ] 273 | }, 274 | 275 | 'sources': [ 276 | 'libgit2/deps/zlib/adler32.c', 277 | 'libgit2/deps/zlib/crc32.c', 278 | 'libgit2/deps/zlib/crc32.h', 279 | 'libgit2/deps/zlib/deflate.c', 280 | 'libgit2/deps/zlib/deflate.h', 281 | 'libgit2/deps/zlib/inffast.c', 282 | 'libgit2/deps/zlib/inffast.h', 283 | 'libgit2/deps/zlib/inffixed.h', 284 | 'libgit2/deps/zlib/inflate.c', 285 | 'libgit2/deps/zlib/inflate.h', 286 | 'libgit2/deps/zlib/inftrees.c', 287 | 'libgit2/deps/zlib/inftrees.h', 288 | 'libgit2/deps/zlib/trees.c', 289 | 'libgit2/deps/zlib/tree.h', 290 | 'libgit2/deps/zlib/zconf.h', 291 | 'libgit2/deps/zlib/zlib.h', 292 | 'libgit2/deps/zlib/zutil.c', 293 | 'libgit2/deps/zlib/zutil.h' 294 | ] 295 | }, { 296 | 'target_name': 'http_parser', 297 | 'type': 'static_library', 298 | 299 | 'direct_dependent_settings': { 300 | 'include_dirs': [ 301 | 'libgit2/deps/http-parser' 302 | ] 303 | }, 304 | 305 | 'sources': [ 306 | 'libgit2/deps/http-parser/http_parser.c', 307 | 'libgit2/deps/http-parser/http_parser.h' 308 | ], 309 | 310 | 'conditions': [ 311 | ["OS=='win'", { 312 | 'msvs_disabled_warnings': [ 313 | 4244 # conversion from 'ssize_t' to 'int32_t' , possible loss of data 314 | ] 315 | }] 316 | ] 317 | }] 318 | } 319 | -------------------------------------------------------------------------------- /docs/resources/base.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Skeleton V1.1 3 | * Copyright 2011, Dave Gamache 4 | * www.getskeleton.com 5 | * Free to use under the MIT license. 6 | * http://www.opensource.org/licenses/mit-license.php 7 | * 8/17/2011 8 | */ 9 | 10 | 11 | /* #Reset & Basics (Inspired by E. Meyers) 12 | ================================================== */ 13 | html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { 14 | margin: 0; 15 | padding: 0; 16 | border: 0; 17 | font-size: 100%; 18 | font: inherit; 19 | vertical-align: baseline; } 20 | article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { 21 | display: block; } 22 | body { 23 | line-height: 1; } 24 | ol, ul { 25 | list-style: none; } 26 | blockquote, q { 27 | quotes: none; } 28 | blockquote:before, blockquote:after, 29 | q:before, q:after { 30 | content: ''; 31 | content: none; } 32 | table { 33 | border-collapse: collapse; 34 | border-spacing: 0; } 35 | 36 | 37 | /* #Basic Styles 38 | ================================================== */ 39 | body { 40 | background: #fff; 41 | font: 14px/21px "Helvetica Neue", Helvetica, Arial, sans-serif; 42 | color: #444; 43 | -webkit-font-smoothing: antialiased; /* Fix for webkit rendering */ 44 | -webkit-text-size-adjust: 100%; 45 | } 46 | 47 | 48 | /* #Typography 49 | ================================================== */ 50 | h1, h2, h3, h4, h5, h6 { 51 | font-family: "Georgia", serif; 52 | font-weight: normal; } 53 | h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { font-weight: inherit; } 54 | h1 { font-size: 34px; line-height: 50px; margin-bottom: 14px;} 55 | h2 { font-size: 28px; line-height: 40px; margin-bottom: 10px; } 56 | h3 { font-size: 23px; line-height: 34px; margin-bottom: 8px; } 57 | h4 { font-size: 19px; line-height: 30px; margin-bottom: 4px; } 58 | h5 { font-size: 16px; line-height: 24px; } 59 | h6 { font-size: 14px; line-height: 21px; } 60 | 61 | p { margin: 0 0 20px 0; } 62 | p img { margin: 0; } 63 | 64 | em { font-style: italic; } 65 | strong { font-weight: bold; color: #333; } 66 | small { font-size: 80%; } 67 | 68 | /* Blockquotes */ 69 | blockquote, blockquote p { font-size: 17px; line-height: 24px; color: #777; font-style: italic; } 70 | blockquote { margin: 0 0 20px; padding: 9px 20px 0 19px; border-left: 1px solid #ddd; } 71 | blockquote cite { display: block; font-size: 12px; color: #555; } 72 | blockquote cite:before { content: "\2014 \0020"; } 73 | blockquote cite a, blockquote cite a:visited, blockquote cite a:visited { color: #555; } 74 | 75 | hr { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 10px 0 30px; height: 0; } 76 | 77 | 78 | /* #Links 79 | ================================================== */ 80 | a, a:visited { 81 | color: #2d81c5; 82 | text-decoration: none; outline: 0; 83 | -webkit-transition: color 250ms ease-in-out; 84 | -moz-transition: color 250ms ease-in-out; 85 | transition: color 250ms ease-in-out; 86 | } 87 | a:hover, a:focus { 88 | color: #2569a0; 89 | } 90 | p a, p a:visited { line-height: inherit; } 91 | 92 | 93 | /* #Lists 94 | ================================================== */ 95 | ul, ol { margin-bottom: 20px; } 96 | ul { list-style: none outside; } 97 | ol { list-style: decimal; } 98 | ol, ul.square, ul.circle, ul.disc { margin-left: 30px; } 99 | ul.square { list-style: square outside; } 100 | ul.circle { list-style: circle outside; } 101 | ul.disc { list-style: disc outside; } 102 | ul ul, ul ol, 103 | ol ol, ol ul { margin: 4px 0 5px 30px; font-size: 90%; } 104 | ul ul li, ul ol li, 105 | ol ol li, ol ul li { margin-bottom: 6px; } 106 | li { line-height: 18px; margin-bottom: 12px; } 107 | ul.large li { line-height: 21px; } 108 | li p { line-height: 21px; } 109 | 110 | 111 | /* #Images 112 | ================================================== */ 113 | 114 | img.scale-with-grid { 115 | max-width: 100%; 116 | height: auto; } 117 | 118 | 119 | /* #Misc 120 | ================================================== */ 121 | .remove-bottom { margin-bottom: 0 !important; } 122 | .half-bottom { margin-bottom: 10px !important; } 123 | .add-bottom { margin-bottom: 20px !important; } 124 | 125 | 126 | /* #Base 960 Grid 127 | ================================================== */ 128 | 129 | .container { position: relative; width: 960px; margin: 0 auto; padding: 0; } 130 | .container .column { float: left; display: inline; margin-left: 10px; margin-right: 10px; } 131 | .row { margin-bottom: 20px; } 132 | 133 | /* Base Grid */ 134 | .container .sidebar.column { width: 220px; } 135 | .container .content.column { width: 700px; } 136 | 137 | 138 | /* #Tablet (Portrait) 139 | ================================================== */ 140 | 141 | /* Note: Design for a width of 768px */ 142 | 143 | @media only screen and (min-width: 768px) and (max-width: 959px) { 144 | .container { width: 768px; } 145 | .container .column { margin-left: 10px; margin-right: 10px; } 146 | 147 | .container .sidebar.column { width: 172px; } 148 | .container .content.column { width: 556px; } 149 | } 150 | 151 | 152 | /* #Mobile (Portrait) 153 | ================================================== */ 154 | 155 | /* Note: Design for a width of 320px */ 156 | 157 | @media only screen and (max-width: 767px) { 158 | .container { width: 300px; } 159 | .container .column { margin: 0; } 160 | 161 | .container .sidebar.column, 162 | .container .content.column { width: 300px; } 163 | } 164 | 165 | 166 | /* #Mobile (Landscape) 167 | ================================================== */ 168 | 169 | /* Note: Design for a width of 480px */ 170 | 171 | @media only screen and (min-width: 480px) and (max-width: 767px) { 172 | .container { width: 420px; } 173 | .container .column { margin: 0; } 174 | 175 | .container .sidebar.column, 176 | .container .content.column { width: 420px; } 177 | } 178 | 179 | 180 | /* #Clearing 181 | ================================================== */ 182 | 183 | /* Self Clearing Goodness */ 184 | .container:after { content: "\0020"; display: block; height: 0; clear: both; visibility: hidden; } 185 | 186 | 187 | /* #CoffeeDoc styles 188 | ================================================== */ 189 | 190 | code { 191 | color: #000; 192 | background: #f6f6f6; 193 | padding: 2px 4px; 194 | border: 1px solid #ccc; 195 | font-size: 12px; line-height: 18px; 196 | font-family: Monaco, Consolas, "Lucida Console", monospace; 197 | border-radius: 2px; 198 | } 199 | pre code { 200 | display: block; 201 | border-radius: 4px; 202 | margin-bottom: 20px; 203 | padding: 10px; 204 | } 205 | header { 206 | width: 100%; 207 | border-bottom: 1px solid #bbb; 208 | margin-bottom: 20px; 209 | background-image: -webkit-linear-gradient(top, #fff, #d0d0d0); 210 | background-image: -moz-linear-gradient(top, #fff, #d0d0d0); 211 | background-image: linear-gradient(top, #fff, #d0d0d0); 212 | } 213 | header h1 { 214 | margin: 0; 215 | line-height: 50px; 216 | font-size: 20px; 217 | text-align: center; 218 | } 219 | h1, h2 { 220 | border-bottom: 1px solid #ccc; 221 | } 222 | h3 { 223 | border-bottom: 1px solid #ddd; 224 | } 225 | 226 | 227 | /* #Module index 228 | ================================================== */ 229 | 230 | .module { 231 | margin-bottom: 25px; 232 | } 233 | .module .header h1 { 234 | margin-bottom: 20px; 235 | border-bottom: none; 236 | box-shadow: 0 5px 5px -6px rgba(45, 129, 197, 0.4); 237 | -webkit-transition: box-shadow 250ms ease-in-out; 238 | -moz-transition: box-shadow 250ms ease-in-out; 239 | transition: box-shadow 250ms ease-in-out; 240 | } 241 | .module .header h1:hover { 242 | box-shadow: 0 5px 5px -6px rgb(45, 129, 197); 243 | } 244 | .module-content h1 { 245 | font-size: 30px; 246 | line-height: 44px; 247 | } 248 | 249 | 250 | /* #Module pages 251 | ================================================== */ 252 | 253 | .function, .class { 254 | margin-bottom: 30px; 255 | } 256 | .method { 257 | margin-bottom: 20px; 258 | } 259 | .class .header { 260 | border-bottom: 1px solid #ccc; 261 | margin-bottom: 10px; 262 | } 263 | .class .header h3 { 264 | display: inline; 265 | border: none; 266 | } 267 | .class .header .parent { 268 | color: #aaa; 269 | } 270 | .class .header .parent:hover { 271 | color: #2569a0; 272 | } 273 | 274 | 275 | /* #Syntax highlighting 276 | ============================================================== */ 277 | 278 | /* github.com style (c) Vasily Polovnyov */ 279 | 280 | pre .comment, 281 | pre .template_comment, 282 | pre .diff .header, 283 | pre .javadoc { 284 | color: #998; 285 | font-style: italic 286 | } 287 | 288 | pre .keyword, 289 | pre .css .rule .keyword, 290 | pre .winutils, 291 | pre .javascript .title, 292 | pre .lisp .title, 293 | pre .subst { 294 | color: #000; 295 | font-weight: bold 296 | } 297 | 298 | pre .number, 299 | pre .hexcolor { 300 | color: #40a070 301 | } 302 | 303 | pre .string, 304 | pre .tag .value, 305 | pre .phpdoc, 306 | pre .tex .formula { 307 | color: #d14 308 | } 309 | 310 | pre .title, 311 | pre .id { 312 | color: #900; 313 | font-weight: bold 314 | } 315 | 316 | pre .javascript .title, 317 | pre .lisp .title, 318 | pre .subst { 319 | font-weight: normal 320 | } 321 | 322 | pre .class .title, 323 | pre .haskell .label, 324 | pre .tex .command { 325 | color: #458; 326 | font-weight: bold 327 | } 328 | 329 | pre .tag, 330 | pre .tag .title, 331 | pre .rules .property, 332 | pre .django .tag .keyword { 333 | color: #000080; 334 | font-weight: normal 335 | } 336 | 337 | pre .attribute, 338 | pre .variable, 339 | pre .instancevar, 340 | pre .lisp .body { 341 | color: #008080 342 | } 343 | 344 | pre .regexp { 345 | color: #009926 346 | } 347 | 348 | pre .class { 349 | color: #458; 350 | font-weight: bold 351 | } 352 | 353 | pre .symbol, 354 | pre .ruby .symbol .string, 355 | pre .ruby .symbol .keyword, 356 | pre .ruby .symbol .keymethods, 357 | pre .lisp .keyword, 358 | pre .tex .special, 359 | pre .input_number { 360 | color: #990073 361 | } 362 | 363 | pre .builtin, 364 | pre .built_in, 365 | pre .lisp .title { 366 | color: #0086b3 367 | } 368 | 369 | pre .preprocessor, 370 | pre .pi, 371 | pre .doctype, 372 | pre .shebang, 373 | pre .cdata { 374 | color: #999; 375 | font-weight: bold 376 | } 377 | 378 | pre .deletion { 379 | background: #fdd 380 | } 381 | 382 | pre .addition { 383 | background: #dfd 384 | } 385 | 386 | pre .diff .change { 387 | background: #0086b3 388 | } 389 | 390 | pre .chunk { 391 | color: #aaa 392 | } 393 | 394 | pre .tex .formula { 395 | opacity: 0.5; 396 | } 397 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/XTo.hpp: -------------------------------------------------------------------------------- 1 | #if !defined (CVV8_TO_X_HPP_INCLUDED) 2 | #define CVV8_TO_X_HPP_INCLUDED 3 | #include "invocable.hpp" 4 | #include "properties.hpp" 5 | /** @file XTo.hpp 6 | 7 | This file provides an alternate approach to the function 8 | conversion API. It covers: 9 | 10 | - Converting functions and methods to to v8::InvocationCallback, 11 | v8::AccessorGetter, and v8::AccessorSetter. 12 | 13 | - Converting variables to v8::AccessorGetter and v8::AccessorSetter. 14 | 15 | All conversions of a given category, e.g. FunctionToXYZ or MethodToXYZ 16 | have a common template, e.g. FunctionTo or MethodTo. The first type 17 | passed to that template is a "tag" type which tells us what conversion 18 | to perform. e.g. a function can be used as an v8::InvocationCallback, 19 | v8::AccessorGetter, or v8::AccessorSetter. 20 | 21 | An example probably explains it best: 22 | 23 | @code 24 | int aBoundInt = 3; 25 | void test_to_bindings() 26 | { 27 | v8::InvocationCallback cb; 28 | v8::AccessorGetter g; 29 | v8::AccessorSetter s; 30 | 31 | using namespace cvv8; 32 | 33 | typedef FunctionTo< InCa, int(char const *), ::puts> FPuts; 34 | typedef FunctionTo< Getter, int(void), ::getchar> GetChar; 35 | typedef FunctionTo< Setter, int(int), ::putchar> SetChar; 36 | cb = FPuts::Call; 37 | g = GetChar::Get; 38 | s = SetChar::Set; 39 | 40 | typedef VarTo< Getter, int, &aBoundInt > VarGet; 41 | typedef VarTo< Setter, int, &aBoundInt > VarSet; 42 | g = VarGet::Get; 43 | s = VarSet::Set; 44 | typedef VarTo< Accessors, int, &aBoundInt > VarGetSet; 45 | g = VarGetSet::Get; 46 | s = VarGetSet::Set; 47 | 48 | typedef BoundNative T; 49 | typedef MethodTo< InCa, const T, int (), &T::getInt > MemInCa; 50 | typedef MethodTo< Getter, const T, int (), &T::getInt > MemGet; 51 | typedef MethodTo< Setter, T, void (int), &T::setInt > MemSet; 52 | cb = MemInCa::Call; 53 | g = MemGet::Get; 54 | s = MemSet::Set; 55 | } 56 | @endcode 57 | 58 | This unconventional, but nonetheless interesting and arguably 59 | very readable/writable approach was first proposed by Coen 60 | Campman. 61 | */ 62 | 63 | 64 | namespace cvv8 { 65 | 66 | /** 67 | Base (unimplemented) FunctionTo interface. 68 | 69 | Specializations act as proxies for FunctionToInCa, 70 | FunctionToGetter and FunctionToSetter. Tag must be one of 71 | (InCa, InCaVoid, Getter, Setter). The other args are as 72 | documented for the aforementioned proxied types. 73 | 74 | See FunctionToInCa for more information about the parameters. 75 | */ 76 | template ::FunctionType Func, 77 | bool UnlockV8 = SignatureIsUnlockable< FunctionSignature >::Value > 78 | struct FunctionTo DOXYGEN_FWD_DECL_KLUDGE; 79 | 80 | //! Behaves like FunctionToInCa. 81 | template ::FunctionType Func, bool UnlockV8> 82 | struct FunctionTo< InCa, Sig, Func, UnlockV8 > : FunctionToInCa 83 | {}; 84 | 85 | //! Behaves like FunctionToInCaVoid. 86 | template ::FunctionType Func, bool UnlockV8> 87 | struct FunctionTo< InCaVoid, Sig, Func, UnlockV8 > : FunctionToInCaVoid 88 | {}; 89 | 90 | //! Behaves like FunctionToGetter. 91 | template ::FunctionType Func, bool UnlockV8> 92 | struct FunctionTo< Getter, Sig, Func, UnlockV8 > : FunctionToGetter 93 | {}; 94 | 95 | //! Behaves like FunctionToSetter. 96 | template ::FunctionType Func, bool UnlockV8> 97 | struct FunctionTo< Setter, Sig, Func, UnlockV8 > : FunctionToSetter 98 | {}; 99 | 100 | /** @class VarTo 101 | 102 | Base (unimplemented) VarTo interface. 103 | 104 | Acts as a proxy for VarToGetter and VarToSetter. Tag must be 105 | one of (Getter, Setter, Accessors). The other args are as 106 | documented for VarToGetter and VarToSetter. 107 | */ 108 | template 109 | struct VarTo DOXYGEN_FWD_DECL_KLUDGE; 110 | 111 | //! Behaves like VarToGetter. 112 | template 113 | struct VarTo< Getter, PropertyType,SharedVar> : VarToGetter 114 | {}; 115 | 116 | //! Behaves like VarToSetter. 117 | template 118 | struct VarTo< Setter, PropertyType,SharedVar> : VarToSetter 119 | {}; 120 | 121 | //! Behaves like VarToAccessors. 122 | template 123 | struct VarTo< Accessors, PropertyType,SharedVar> : VarToAccessors 124 | {}; 125 | 126 | /** 127 | Base (unimplemented) type for MemberTo-xxx conversions. 128 | 129 | Acts as a proxy for MemberToGetter, MemberToSetter and 130 | MemberToAccessors. Tag must be one of (Getter, Setter, Accessors). 131 | The other args are as documented for MemberToGetter and 132 | MemberToSetter. 133 | */ 134 | template 135 | struct MemberTo DOXYGEN_FWD_DECL_KLUDGE; 136 | 137 | //! Behaves like MemberToGetter. 138 | template 139 | struct MemberTo : MemberToGetter< T, PropertyType, MemVar > {}; 140 | 141 | //! Behaves like MemberToSetter. 142 | template 143 | struct MemberTo : MemberToSetter< T, PropertyType, MemVar > {}; 144 | 145 | //! Behaves like MemberToAccessors. 146 | template 147 | struct MemberTo : MemberToAccessors< T, PropertyType, MemVar > {}; 148 | 149 | /** 150 | Base (unimplemented) MethodTo interface. 151 | 152 | Acts as a proxy for MethodToInCa, MethodToGetter and 153 | MethodToSetter (or their const cousins if T is 154 | const-qualified). Tag must be one of (InCa, InCaVoid, 155 | Getter, Setter). The other args are as documented for the 156 | aforementioned proxied types. 157 | 158 | See MethodToInCa for more information about the parameters. 159 | */ 160 | template ::FunctionType Func, 161 | bool UnlockV8 = SignatureIsUnlockable< MethodSignature >::Value> 162 | struct MethodTo DOXYGEN_FWD_DECL_KLUDGE; 163 | 164 | //! Behaves like MethodToInCa. For const methods, const-qualify T. 165 | template ::FunctionType Func, bool UnlockV8> 166 | struct MethodTo< InCa, T, Sig, Func, UnlockV8 > : MethodToInCa 167 | {}; 168 | 169 | //! Behaves like MethodToInCaVoid. For const methods, const-qualify T. 170 | template ::FunctionType Func, bool UnlockV8> 171 | struct MethodTo< InCaVoid, T, Sig, Func, UnlockV8 > : MethodToInCaVoid 172 | {}; 173 | 174 | //! Behaves like MethodToGetter. For const methods, const-qualify T. 175 | template ::FunctionType Func, bool UnlockV8> 176 | struct MethodTo< Getter, T, Sig, Func, UnlockV8 > : MethodToGetter 177 | {}; 178 | 179 | //! Behaves like MethodToSetter. For const methods, const-qualify T. 180 | template ::FunctionType Func, bool UnlockV8> 181 | struct MethodTo< Setter, T, Sig, Func, UnlockV8 > : MethodToSetter 182 | {}; 183 | 184 | /** 185 | Base (unimplemented) FunctorTo interface. 186 | 187 | Behaves like one of the following, depending on the Tag type: 188 | 189 | FunctorToInCa (Tag=InCa), FunctorToInCaVoid (Tag=InCaVoid), 190 | FunctorToGetter (Tag=Getter), FunctorToSetter (Tag=Setter) 191 | 192 | See FunctorToInCa for more information about the parameters. 193 | */ 194 | template >::Value 196 | > 197 | struct FunctorTo DOXYGEN_FWD_DECL_KLUDGE; 198 | 199 | //! Behaves like FunctorToInCa. 200 | template 201 | struct FunctorTo< InCa, FtorT, Sig, UnlockV8 > : FunctorToInCa 202 | {}; 203 | 204 | //! Behaves like FunctorToInCaVoid. 205 | template 206 | struct FunctorTo< InCaVoid, FtorT, Sig, UnlockV8 > : FunctorToInCaVoid 207 | {}; 208 | 209 | //! Behaves like FunctorToGetter. 210 | template 211 | struct FunctorTo< Getter, FtorT, Sig, UnlockV8 > : FunctorToGetter 212 | {}; 213 | 214 | //! Behaves like FunctorToSetter. 215 | template 216 | struct FunctorTo< Setter, FtorT, Sig, UnlockV8 > : FunctorToSetter 217 | {}; 218 | } 219 | /** LICENSE 220 | 221 | This software's source code, including accompanying documentation and 222 | demonstration applications, are licensed under the following 223 | conditions... 224 | 225 | The author (Stephan G. Beal [http://wanderinghorse.net/home/stephan/]) 226 | explicitly disclaims copyright in all jurisdictions which recognize 227 | such a disclaimer. In such jurisdictions, this software is released 228 | into the Public Domain. 229 | 230 | In jurisdictions which do not recognize Public Domain property 231 | (e.g. Germany as of 2011), this software is Copyright (c) 2011 232 | by Stephan G. Beal, and is released under the terms of the MIT License 233 | (see below). 234 | 235 | In jurisdictions which recognize Public Domain property, the user of 236 | this software may choose to accept it either as 1) Public Domain, 2) 237 | under the conditions of the MIT License (see below), or 3) under the 238 | terms of dual Public Domain/MIT License conditions described here, as 239 | they choose. 240 | 241 | The MIT License is about as close to Public Domain as a license can 242 | get, and is described in clear, concise terms at: 243 | 244 | http://en.wikipedia.org/wiki/MIT_License 245 | 246 | The full text of the MIT License follows: 247 | 248 | -- 249 | Copyright (c) 2011 Stephan G. Beal (http://wanderinghorse.net/home/stephan/) 250 | 251 | Permission is hereby granted, free of charge, to any person 252 | obtaining a copy of this software and associated documentation 253 | files (the "Software"), to deal in the Software without 254 | restriction, including without limitation the rights to use, 255 | copy, modify, merge, publish, distribute, sublicense, and/or sell 256 | copies of the Software, and to permit persons to whom the 257 | Software is furnished to do so, subject to the following 258 | conditions: 259 | 260 | The above copyright notice and this permission notice shall be 261 | included in all copies or substantial portions of the Software. 262 | 263 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 264 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 265 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 266 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 267 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 268 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 269 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 270 | OTHER DEALINGS IN THE SOFTWARE. 271 | 272 | --END OF MIT LICENSE-- 273 | 274 | For purposes of the above license, the term "Software" includes 275 | documentation and demonstration source code which accompanies 276 | this software. ("Accompanies" = is contained in the Software's 277 | primary public source code repository.) 278 | 279 | */ 280 | 281 | #endif /* CVV8_TO_X_HPP_INCLUDED */ 282 | -------------------------------------------------------------------------------- /deps/v8-convert/cvv8/detail/signature_core.hpp: -------------------------------------------------------------------------------- 1 | #if !defined(CODE_GOOGLE_COM_V8_CONVERT_SIGNATURE_CORE_HPP_INCLUDED) 2 | #define CODE_GOOGLE_COM_V8_CONVERT_SIGNATURE_CORE_HPP_INCLUDED 1 3 | #include "tmp.hpp" 4 | #include "doxygen_hack.hpp" 5 | 6 | namespace cvv8 { 7 | /** @file signature_core.hpp 8 | 9 | This file houses the core-most templates related to handling 10 | function/method signatures as full-fleged types. 11 | */ 12 | 13 | 14 | 15 | /** @class Signature 16 | 17 | Base (unimplemented) template for holding function-signature-style 18 | argument lists in a type-rich manner. Most implementations are 19 | script-generated and accept up to some library-build-time-defined number 20 | of types in their argument list (the interface guarantees at least 10 21 | unless the client builds a custom copy with a smaller limit). 22 | 23 | All specializations implement a "type list" interface. The sl namespace 24 | contains several different compile-time algorithms (sometimes called 25 | template metafunctions) for querying the arity and types in a signature. 26 | 27 | Sig must be a function-signature-style parameter list, e.g.: 28 | 29 | @code 30 | Signature< void (int, double) > 31 | Signature< void (MyType::*)( int double ) > 32 | Signature< void (MyType::*)( char const * ) const > 33 | @endcode 34 | 35 | This interface treates the "function parameter part" of its arguments as 36 | a "type list", and several algorithms in the sl namespace are available 37 | for fetching type information from a Signature type. This is an 38 | "extended" typelist, however, because it also remembers the return type 39 | and optionally the class containing a member function described by the 40 | signature (neither of those are counted as part of the list, but are 41 | accessible separately). 42 | 43 | Required interface for specializations: 44 | 45 | @code 46 | typedef functionSignature FunctionType; // e.g. void () or void (T::*)() const. 47 | typedef functionReturnType ReturnType; 48 | typedef T Context; // void for non-member functions, non-vp-qualified T 49 | // for all T members. const-qualified T for const members. 50 | typedef firstArgType Head; // head type of type-list. 51 | typedef Signature< RV (...)> Tail; // tail of type-list. (...)==arg types 2..N. 52 | // When Arity==0, Head and Tail must both be tmp::NilType. For Arity==1 53 | // Tail is Signature but one could argue that it should be tmp::NilType. 54 | 55 | @endcode 56 | 57 | It is intended to be used like this: 58 | 59 | @code 60 | typedef Signature< int (char const *, double) > Sig; 61 | assert( 2 == sl::Arity::Value ); 62 | assert( 2 == sl::Length::Value ) 63 | assert( (tmp::SameType< char const *, sl::At<0,Sig>::Type >::Value) ); 64 | assert( (tmp::SameType< double, sl::At<1,Sig>::Type >::Value) ); 65 | assert( 1 == sl::Index< double, Sig >::Value) ); 66 | assert( !sl::Contains< int, Sig >::Value) ); // Sig::ReturnType doesn't count here! 67 | assert( sl::IsConstMethod< Signature< void (MyType::*)() const > >::Value ); 68 | assert( sl::IsMethod< Signature< void (MyType::*)() const > >::Value ); 69 | assert( !sl::IsConstMethod< Signature< void (MyType::*)() > >::Value ); 70 | // Those can all be made into static assertions, by the way. 71 | @endcode 72 | 73 | Note that the length of the typelist does not include the return value 74 | type nor (for member methods) the containing class (the Context typedef). 75 | 76 | Functions taking one (v8::Arguments const &) argument and 77 | returning any type are considered to be 78 | "InvocationCallback-like" and are treated specially. They have 79 | an Arity value of -1, which is used as a hint by binding code 80 | that the function can accept any number of arguments when called 81 | from JS code (there is no way to create Arguments objects 82 | directly from C++, only indirectly via Call()ing or Apply()ing a 83 | v8::Function). 84 | */ 85 | template struct Signature DOXYGEN_FWD_DECL_KLUDGE; 86 | 87 | /** @def CVV8_TYPELIST 88 | 89 | CVV8_TYPELIST is a (slightly) convenience form of 90 | Signature for creating typelists where we do not care about the 91 | "return type" or "context" parts of the list. 92 | 93 | It is used like this: 94 | 95 | @code 96 | typedef CVV8_TYPELIST(( int, double, char )) MyList; 97 | @endcode 98 | 99 | NOTE the doubled parenthesis! 100 | 101 | Many members of the API which take a type-list require a 102 | Signature-compatible typelist because they need the ReturnValue and/or 103 | Context parts. CVV8_TYPELIST is intended for cases where niether the 104 | ReturnValue nor Context are evaluated (both are void for CVV8_TYPELIST). 105 | 106 | The maximum number of types the typelist can hold is limited 107 | to some build-time configuration option. 108 | */ 109 | #define CVV8_TYPELIST(X) ::cvv8::Signature< void X > 110 | 111 | /** \namespace cvv8::sl 112 | 113 | The sl namespace exclusively holds template metafunctions for working 114 | with Signature-style typelists. 115 | */ 116 | namespace sl { 117 | 118 | /** 119 | Metafunction whose Value member evaluates to the length of the 120 | given Signature. 121 | */ 122 | template < typename ListT > 123 | struct Length : tmp::IntVal< 124 | tmp::IsNil::Value ? 0 : (1 + Length::Value) 125 | > {}; 126 | 127 | //! End-of-list specialization. 128 | template <> 129 | struct Length : tmp::IntVal<0> {}; 130 | /** 131 | Metafunction whose Type member evaluates to the type of the 132 | I'th argument type in the given Signature. Fails to compile 133 | if I is out of range. 134 | */ 135 | template < unsigned short I, typename ListT > 136 | struct At : At 137 | { 138 | typedef char AssertIndex[ (I >= Length::Value) ? -1 : 1 ]; 139 | }; 140 | 141 | //! Beginning-of-list specialization. 142 | template < typename ListT > 143 | struct At<0, ListT> 144 | { 145 | typedef typename ListT::Head Type; 146 | }; 147 | /** 148 | End-of-list specialization. i don't think we need this, actually. 149 | */ 150 | template 151 | struct At : tmp::Identity 152 | {}; 153 | 154 | /** 155 | Metafunction whose Type Value member evaluates to the 0-based 156 | index of the first occurrance of the the type T in the 157 | given Signature's argument list. Evaluates to -1 if T is not 158 | contained in the argument list. Signature::ReturnType and 159 | Signature::Context are not evaluated. 160 | 161 | Clients _must not_ pass a value for the 3rd template parameter. 162 | */ 163 | template < typename T, typename ListT, unsigned short Internal = 0 > 164 | struct Index : tmp::IntVal< tmp::SameType::Value 165 | ? Internal 166 | : Index::Value> 167 | { 168 | }; 169 | 170 | //! End-of-list specialization. 171 | template < typename T, unsigned short Internal > 172 | struct Index : tmp::IntVal<-1> {}; 173 | 174 | /** 175 | Convenience form of Index which evaluates to true 176 | if Index returns a non-negative value, else it evaluates 177 | to false. 178 | */ 179 | template < typename T, typename ListT> 180 | struct Contains : tmp::BoolVal< Index::Value >= 0 > {}; 181 | 182 | 183 | /** 184 | A metatype which calculates the number of arguments in the given 185 | typelist, but evaluates to -1 if SigT's only argument is 186 | (v8::Arguments const &), as such function signatures are considered 187 | to be n-arity. 188 | */ 189 | template 190 | struct Arity 191 | { 192 | enum { 193 | Value = ((1==Length::Value) 194 | && (0==Index::Value)) 195 | ? -1 196 | : Length::Value 197 | }; 198 | }; 199 | 200 | /** 201 | This metafunction evaluates to true if SigT appears to be 202 | "InvocationCallback-like" (returns any type and takes one 203 | (v8::Arguments const &) parameter). 204 | 205 | We could implement this a number of different ways. The 206 | current impl simply checks if the arity is -1. 207 | */ 208 | template 209 | struct IsInCaLike : tmp::BoolVal< -1 == Arity::Value > {}; 210 | 211 | /** 212 | A metafunction which has a true Value if the Signature type SigT 213 | represents a non-member function. 214 | */ 215 | template 216 | struct IsFunction : tmp::BoolVal< tmp::SameType::Value > {}; 217 | 218 | /** 219 | A metafunction which has a true Value if the Signature type SigT 220 | represents a member function (const or not). 221 | */ 222 | template 223 | struct IsMethod : tmp::BoolVal< !tmp::SameType::Value > {}; 224 | 225 | /** 226 | A metafunction which has a true Value if the Signature type SigT 227 | represents a non-const member function. 228 | */ 229 | template 230 | struct IsNonConstMethod : tmp::BoolVal< !tmp::IsConst< typename SigT::Context >::Value && IsMethod::Value > {}; 231 | 232 | /** 233 | A metafunction which has a true Value if the Signature type SigT 234 | represents a const member function. 235 | */ 236 | template 237 | struct IsConstMethod : 238 | tmp::BoolVal< tmp::IsConst< typename SigT::Context >::Value && IsMethod::Value > {}; 239 | //tmp::BoolVal< SigT::IsConst && IsMethod::Value > {}; 240 | 241 | } 242 | 243 | namespace tmp { 244 | /** 245 | A metatemplate who's Type member resolves to IF if Cond is 246 | true, or ELSE if Cond is false. Its Value member evaluates 247 | to 1 or 0, accordingly. 248 | */ 249 | template 250 | struct IfElse : sl::At< Cond ? 0 : 1, Signature > 251 | { 252 | }; 253 | } 254 | 255 | #if 0 256 | //! Highly arguably specialization. 257 | template struct Signature< Signature > : Signature {}; 258 | #endif 259 | 260 | /** 261 | Specialization to give "InvacationCallback-like" functions 262 | an Arity value of -1. 263 | 264 | Reminder: we can get rid of this if we factory out the Arity definition 265 | and use sl::Arity instead. 266 | */ 267 | template 268 | struct Signature 269 | { 270 | typedef RV ReturnType; 271 | typedef RV (*FunctionType)(v8::Arguments const &); 272 | typedef void Context; 273 | typedef v8::Arguments const & Head; 274 | typedef Signature Tail; 275 | }; 276 | 277 | template 278 | struct Signature : Signature 279 | {}; 280 | 281 | template 282 | struct Signature : Signature 283 | { 284 | typedef T Context; 285 | typedef RV (Context::*FunctionType)(v8::Arguments const &); 286 | }; 287 | 288 | 289 | template 290 | struct Signature : Signature 291 | { 292 | typedef T const Context; 293 | typedef RV (Context::*FunctionType)(v8::Arguments const &) const; 294 | }; 295 | 296 | 297 | 298 | /** @class FunctionSignature 299 | Base (unimplemented) signature for FunctionSignature 300 | specializations. The type passed to it must be a function 301 | signature. 302 | 303 | All implementations must define the interface described for 304 | Signature and its Context typedef must be void for this type. 305 | 306 | Examples: 307 | 308 | @code 309 | // void func_foo(): 310 | typedef FunctionSignature< void () > NoArgsReturnsVoid; 311 | 312 | // int func_foo(double): 313 | typedef FunctionSignature< int (double) > OneArgReturnsInt; 314 | 315 | // double func_foo(int,int): 316 | typedef FunctionSignature< double (int,int) > TwoArgsReturnsDouble; 317 | @endcode 318 | 319 | */ 320 | template 321 | struct FunctionSignature : Signature< FunctionSig > {}; 322 | 323 | /** @class MethodSignature 324 | Base (unimplemented) signature for MethodSignature 325 | specializations. The Sig type passed to it must match a member method 326 | signature of a function from the class T. 327 | e.g. (void (T::*)(int)) or its equivalent (void (int)). 328 | 329 | All implementations must have the interface called for by Signature 330 | and the Context typedef must be non-cvp-qualified T. 331 | 332 | Examples: 333 | 334 | @code 335 | // void MyType::func(): 336 | typedef MethodSignature< MyType, void () > NoArgsReturnsVoid; 337 | 338 | // int MyType::func(double): 339 | typedef MethodSignature< MyType, int (double) > OneArgReturnsInt; 340 | 341 | // double MyType::func(int,int): 342 | typedef MethodSignature< MyType, double (int,int) > TwoArgsReturnsDouble; 343 | @endcode 344 | 345 | As of r2019 (20110723), MethodSignature and 346 | ConstMethodSignature are equivalent. 347 | 348 | Reminders to self: 349 | 350 | i would really like this class to simply subclass Signature and we 351 | would add in a couple typedefs we need. This would cut the specializations 352 | we generate. However, i don't know how to make this work. The problems 353 | include: 354 | 355 | - i can't "refactor" Signature::FunctionType to the proper type 356 | at this level. 357 | */ 358 | template 359 | struct MethodSignature DOXYGEN_FWD_DECL_KLUDGE; 360 | 361 | /** @class ConstMethodSignature 362 | Base (unimplemented) signature for ConstMethodSignature 363 | specializations. The Sig type passed to it must be a member 364 | method signature of a const function from the class T. 365 | e.g. (void (T::*)(int) const) 366 | 367 | All implementations must have the interface called for by Signature 368 | and the Context typedef must be non-cvp-qualified T. The IsConst 369 | member (enum or static/const boolean) must be a true value. 370 | 371 | Examples: 372 | 373 | @code 374 | // void MyType::func() const: 375 | typedef ConstMethodSignature< MyType, void () > NoArgsReturnsVoid; 376 | 377 | // int MyType::func(double) const: 378 | typedef ConstMethodSignature< MyType, int (double) > OneArgReturnsInt; 379 | 380 | // double MyType::func(int,int) const: 381 | typedef ConstMethodSignature< MyType, double (int,int) > TwoArgsReturnsDouble; 382 | @endcode 383 | 384 | As of r2019 (20110723), MethodSignature and 385 | ConstMethodSignature are equivalent. 386 | */ 387 | template 388 | struct ConstMethodSignature DOXYGEN_FWD_DECL_KLUDGE; 389 | //template 390 | //struct ConstMethodSignature : ConstMethodSignature {}; 391 | 392 | template 393 | struct MethodSignature< T, RV () > : Signature< RV () > 394 | { 395 | typedef T Context; 396 | typedef RV (Context::*FunctionType)(); 397 | }; 398 | 399 | 400 | template 401 | struct MethodSignature< T, RV (T::*)() > : MethodSignature 402 | { 403 | }; 404 | 405 | template 406 | struct MethodSignature< T const, RV () > : ConstMethodSignature< T, RV () > 407 | {}; 408 | 409 | template 410 | struct MethodSignature< T const, RV (T::*)() > : MethodSignature 411 | { 412 | }; 413 | #if 1 //msvc? 414 | template 415 | struct MethodSignature< T const, RV (T::*)() const > : MethodSignature 416 | { 417 | }; 418 | #endif 419 | 420 | template 421 | struct ConstMethodSignature< T, RV () > : Signature< RV (T::*)() const > 422 | { 423 | typedef T const Context; 424 | typedef RV (Context::*FunctionType)() const; 425 | }; 426 | template 427 | struct ConstMethodSignature< T, RV (T::*)() const > : ConstMethodSignature 428 | { 429 | }; 430 | 431 | 432 | /** 433 | A "type-rich" function pointer. 434 | 435 | Sig must be a function signature type usable in the construct 436 | FunctionSignature. FuncPtr must be a function of that type. 437 | */ 438 | template ::FunctionType FuncPtr> 439 | struct FunctionPtr : FunctionSignature 440 | { 441 | /** 442 | This type's full "signature" type. 443 | */ 444 | typedef FunctionSignature SignatureType; 445 | /** 446 | The data type of FuncPtr. 447 | */ 448 | typedef typename SignatureType::FunctionType FunctionType; 449 | 450 | /** The function specifies in the template arguments. */ 451 | static const FunctionType Function; 452 | }; 453 | template ::FunctionType FuncPtr> 454 | typename FunctionPtr::FunctionType const FunctionPtr::Function = FuncPtr; 455 | 456 | /** 457 | Used like FunctionPtr, but in conjunction with non-const 458 | member functions ("methods") of the T class. See FunctionPtr 459 | for the requirements of the Sig type. 460 | */ 461 | template ::FunctionType FuncPtr> 462 | struct MethodPtr : MethodSignature 463 | { 464 | typedef MethodSignature SignatureType; 465 | typedef typename SignatureType::FunctionType FunctionType; 466 | static const FunctionType Function; 467 | }; 468 | template ::FunctionType FuncPtr> 469 | typename MethodPtr::FunctionType const MethodPtr::Function = FuncPtr; 470 | /** 471 | Used like MethodPtr, but in conjunction with const methods of the T 472 | class. 473 | */ 474 | template ::FunctionType FuncPtr> 475 | struct ConstMethodPtr : ConstMethodSignature 476 | { 477 | typedef ConstMethodSignature SignatureType; 478 | typedef typename SignatureType::FunctionType FunctionType; 479 | static const FunctionType Function; 480 | }; 481 | template ::FunctionType FuncPtr> 482 | typename ConstMethodPtr::FunctionType const ConstMethodPtr::Function = FuncPtr; 483 | 484 | #if 0 //!msvc 485 | //! Specialization to treat (const T) as ConstMethodPtr. 486 | template ::FunctionType FuncPtr> 487 | struct MethodPtr : ConstMethodPtr 488 | { 489 | typedef MethodSignature SignatureType; 490 | typedef typename SignatureType::FunctionType FunctionType; 491 | static const FunctionType Function; 492 | }; 493 | #endif 494 | 495 | #include "signature_generated.hpp" 496 | } // namespaces 497 | 498 | #endif /* CODE_GOOGLE_COM_V8_CONVERT_SIGNATURE_CORE_HPP_INCLUDED */ 499 | --------------------------------------------------------------------------------