| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,7 +74,7 @@ class GitTreeEntry : ObjectWrap { | |||
| 74 | 74 | uv_work_t request; | |
| 75 | 75 | ||
| 76 | 76 | git_tree_entry* rawEntry; | |
| 77 | - int fileMode; | ||
| 77 | + git_filemode_t fileMode; | ||
| 78 | 78 | ||
| 79 | 79 | Persistent<Function> callback; | |
| 80 | 80 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -145,19 +145,41 @@ void GitTreeEntry::NameAfterWork(uv_work_t* req) { | |||
| 145 | 145 | } | |
| 146 | 146 | ||
| 147 | 147 | Handle<Value> GitTreeEntry::FileMode(const Arguments& args) { | |
| 148 | - // HandleScope scope; | ||
| 148 | + HandleScope scope; | ||
| 149 | 149 | ||
| 150 | - // GitTreeEntry *entry = ObjectWrap::Unwrap<GitTreeEntry>(args.This()); | ||
| 150 | + if(args.Length() == 0 || !args[0]->IsFunction()) { | ||
| 151 | + return ThrowException(Exception::Error(String::New("Callback is required and must be a Function."))); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + FileModeBaton *baton = new FileModeBaton; | ||
| 155 | + baton->request.data = baton; | ||
| 156 | + baton->rawEntry = ObjectWrap::Unwrap<GitTreeEntry>(args.This())->GetValue(); | ||
| 157 | + baton->callback = Persistent<Function>::New(Local<Function>::Cast(args[0])); | ||
| 158 | + | ||
| 159 | + uv_queue_work(uv_default_loop(), &baton->request, FileModeWork, (uv_after_work_cb)FileModeAfterWork); | ||
| 151 | 160 | ||
| 152 | - // return scope.Close(Number::New(git_tree_entry_filemode(entry->entry))); | ||
| 153 | 161 | return Undefined(); | |
| 154 | 162 | } | |
| 155 | 163 | void GitTreeEntry::FileModeWork(uv_work_t* req) { | |
| 164 | + FileModeBaton *baton = static_cast<FileModeBaton *>(req->data); | ||
| 156 | 165 | ||
| 157 | - | ||
| 166 | + baton->fileMode = git_tree_entry_filemode(baton->rawEntry); | ||
| 158 | 167 | } | |
| 159 | 168 | void GitTreeEntry::FileModeAfterWork(uv_work_t* req) { | |
| 169 | + HandleScope scope; | ||
| 170 | + FileModeBaton *baton = static_cast<FileModeBaton *>(req->data); | ||
| 160 | 171 | ||
| 172 | + Handle<Value> argv[2] = { | ||
| 173 | + Local<Value>::New(Null()), | ||
| 174 | + Integer::New(baton->fileMode) | ||
| 175 | + }; | ||
| 176 | + | ||
| 177 | + TryCatch try_catch; | ||
| 178 | + baton->callback->Call(Context::GetCurrent()->Global(), 2, argv); | ||
| 179 | + if (try_catch.HasCaught()) { | ||
| 180 | + node::FatalException(try_catch); | ||
| 181 | + } | ||
| 182 | + delete req; | ||
| 161 | 183 | } | |
| 162 | 184 | ||
| 163 | 185 | Handle<Value> GitTreeEntry::Oid(const Arguments& args) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments