@@ -30,11 +30,7 @@ void GitTree::Initialize (Handle<v8::Object> target) {
3030 tpl->InstanceTemplate ()->SetInternalFieldCount (1 );
3131 tpl->SetClassName (String::NewSymbol (" Tree" ));
3232
33- NODE_SET_PROTOTYPE_METHOD (tpl, " lookup" , Lookup);
34- NODE_SET_PROTOTYPE_METHOD (tpl, " entryCount" , EntryCount);
35- NODE_SET_PROTOTYPE_METHOD (tpl, " entryByIndex" , EntryByIndex);
3633 NODE_SET_PROTOTYPE_METHOD (tpl, " entryByPath" , EntryByPath);
37- NODE_SET_PROTOTYPE_METHOD (tpl, " sortEntries" , EntryCount);
3834
3935 constructor_template = Persistent<Function>::New (tpl->GetFunction ());
4036 target->Set (String::NewSymbol (" Tree" ), constructor_template);
@@ -43,28 +39,10 @@ void GitTree::Initialize (Handle<v8::Object> target) {
4339git_tree* GitTree::GetValue () {
4440 return this ->tree ;
4541}
46-
4742void GitTree::SetValue (git_tree* tree) {
4843 this ->tree = tree;
4944}
5045
51- int GitTree::Lookup (git_repository* repo, const git_oid* id) {
52- return git_tree_lookup (&this ->tree , repo, id);
53- }
54-
55- size_t GitTree::EntryCount () {
56- return git_tree_entrycount (this ->tree );
57- }
58-
59- git_tree_entry* GitTree::EntryByIndex (int idx) {
60- return const_cast <git_tree_entry*>(git_tree_entry_byindex (this ->tree , idx));
61- }
62-
63- int GitTree::SortEntries () {
64- // return git_tree_sort_entries(this->tree);
65- return 0 ;
66- }
67-
6846Handle<Value> GitTree::New (const Arguments& args) {
6947 HandleScope scope;
7048
@@ -75,149 +53,6 @@ Handle<Value> GitTree::New(const Arguments& args) {
7553 return scope.Close (args.This ());
7654}
7755
78- Handle<Value> GitTree::Lookup (const Arguments& args) {
79- HandleScope scope;
80-
81- GitTree *tree = ObjectWrap::Unwrap<GitTree>(args.This ());
82-
83- if (args.Length () == 0 || !args[0 ]->IsObject ()) {
84- return ThrowException (Exception::Error (String::New (" Repo is required and must be an Object." )));
85- }
86-
87- if (args.Length () == 1 || !args[1 ]->IsObject ()) {
88- return ThrowException (Exception::Error (String::New (" Oid is required and must be an Object." )));
89- }
90-
91- GitRepo* repo = ObjectWrap::Unwrap<GitRepo>(args[0 ]->ToObject ());
92- GitOid* oid = ObjectWrap::Unwrap<GitOid>(args[1 ]->ToObject ());
93-
94- git_oid ref_oid = oid->GetValue ();
95- int err = tree->Lookup (repo->GetValue (), &ref_oid);
96-
97- return scope.Close ( Integer::New (err) );
98-
99- // if(args.Length() == 2 || !args[2]->IsFunction()) {
100- // return ThrowException(Exception::Error(String::New("Callback is required and must be a Function.")));
101- // }
102- //
103- // callback = Local<Function>::Cast(args[2]);
104- //
105- // lookup_request *lr = new lookup_request();
106- // lr->tree = tree;
107- // lr->repo = ObjectWrap::Unwrap<GitRepo>(args[0]->ToObject());
108- // lr->oid = ObjectWrap::Unwrap<GitOid>(args[1]->ToObject());
109- // lr->callback = Persistent<Function>::New(callback);
110- //
111- // tree->Ref();
112- //
113- // eio_custom(EIO_Lookup, EIO_PRI_DEFAULT, EIO_AfterLookup, lr);
114- // ev_ref(EV_DEFAULT_UC);
115- //
116- // return scope.Close( Undefined() );
117- }
118-
119- // void GitTree::EIO_Lookup(uv_work_t *req) {
120- // lookup_request *lr = static_cast<lookup_request *>(req->data);
121- //
122- // git_oid oid = lr->oid->GetValue();
123- // lr->err = lr->tree->Lookup(lr->repo->GetValue(), &oid);
124- //
125- // return 0;
126- // }
127-
128- // void GitTree::EIO_AfterLookup(uv_work_t *req) {
129- // lookup_request *lr = static_cast<lookup_request *>(req->data);
130- //
131- // ev_unref(EV_DEFAULT_UC);
132- // lr->tree->Unref();
133- //
134- // Handle<Value> argv[1];
135- // argv[0] = Integer::New(lr->err);
136- //
137- // TryCatch try_catch;
138- //
139- // lr->callback->Call(Context::GetCurrent()->Global(), 1, argv);
140- //
141- // if(try_catch.HasCaught())
142- // FatalException(try_catch);
143- //
144- // lr->callback.Dispose();
145- //
146- // delete lr;
147- //
148- // return 0;
149- // }
150-
151- Handle<Value> GitTree::EntryCount (const Arguments& args) {
152- HandleScope scope;
153-
154- GitTree *tree = ObjectWrap::Unwrap<GitTree>(args.This ());
155-
156- int count = tree->EntryCount ();
157-
158- return scope.Close ( Integer::New (count) );
159- }
160-
161- Handle<Value> GitTree::EntryByIndex (const Arguments& args) {
162- HandleScope scope;
163-
164- GitTree *tree = ObjectWrap::Unwrap<GitTree>(args.This ());
165- Local<Function> callback;
166-
167- if (args.Length () == 0 || !args[0 ]->IsObject ()) {
168- return ThrowException (Exception::Error (String::New (" TreeEntry is required and must be a Object." )));
169- }
170-
171- if (args.Length () == 1 || !args[1 ]->IsNumber ()) {
172- return ThrowException (Exception::Error (String::New (" Index is required and must be a Number." )));
173- }
174-
175- if (args.Length () == 2 || !args[2 ]->IsFunction ()) {
176- return ThrowException (Exception::Error (String::New (" Callback is required and must be a Function." )));
177- }
178-
179- callback = Local<Function>::Cast (args[2 ]);
180-
181- entryindex_request *er = new entryindex_request ();
182- er->tree = tree;
183- er->entry = ObjectWrap::Unwrap<GitTreeEntry>(args[0 ]->ToObject ());
184- er->idx = args[1 ]->ToInteger ()->Value ();
185- er->callback = Persistent<Function>::New (callback);
186-
187- tree->Ref ();
188-
189- uv_work_t *req = new uv_work_t ;
190- req->data = er;
191- uv_queue_work (uv_default_loop (), req, EIO_EntryByIndex, (uv_after_work_cb)EIO_AfterEntryByIndex);
192-
193- return scope.Close ( Undefined () );
194- }
195-
196- void GitTree::EIO_EntryByIndex (uv_work_t *req) {
197- entryindex_request *er = static_cast <entryindex_request *>(req->data );
198-
199- er->entry ->SetValue (er->tree ->EntryByIndex (er->idx ));
200- }
201-
202- void GitTree::EIO_AfterEntryByIndex (uv_work_t *req) {
203- entryindex_request *er = static_cast <entryindex_request *>(req->data );
204-
205- Handle<Value> argv[0 ];
206-
207- TryCatch try_catch;
208-
209- er->callback ->Call (Context::GetCurrent ()->Global (), 0 , argv);
210-
211- if (try_catch.HasCaught ())
212- FatalException (try_catch);
213-
214- er->callback .Dispose ();
215-
216- delete req;
217- er->tree ->Unref ();
218- delete er;
219- }
220-
22156Handle<Value> GitTree::EntryByPath (const Arguments& args) {
22257 HandleScope scope;
22358
@@ -276,23 +111,4 @@ void GitTree::EntryByPathAfterWork(uv_work_t *req) {
276111 delete req;
277112}
278113
279- Handle<Value> GitTree::SortEntries (const Arguments& args) {
280- HandleScope scope;
281-
282- GitTree *tree = ObjectWrap::Unwrap<GitTree>(args.This ());
283-
284- int err = tree->SortEntries ();
285-
286- return scope.Close ( Integer::New (err) );
287- }
288-
289- Handle<Value> GitTree::ClearEntries (const Arguments& args) {
290- HandleScope scope;
291-
292- // GitTree *tree = ObjectWrap::Unwrap<GitTree>(args.This());
293-
294- // tree->ClearEntries();
295-
296- return scope.Close ( Undefined () );
297- }
298114Persistent<Function> GitTree::constructor_template;
0 commit comments