FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nodegit/build/codegen/templates/asyncFunction.cc.ejs at emscripten · nodegit/nodegit · GitHub
nodegit
nodegit
Repository navigation
Code
Issues
344
(344)
Pull requests
21
(21)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
nodegit
/
build
/
codegen
/
templates
/
asyncFunction.cc.ejs
Copy path
More file actions
More file actions
Latest commit
History
History
History
143 lines (134 loc) · 4.78 KB
Breadcrumbs
nodegit
/
build
/
codegen
/
templates
/
asyncFunction.cc.ejs
Copy path
File metadata and controls
143 lines (134 loc) · 4.78 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include "../include/functions/copy.h"
/**
<%
include
doc
.
cc
.
ejs
-
%>
*/
Handle<
Value
>
<%
-
cppClassName
%>
::
<%
-
functionInfo
.
cppFunctionName
%>
(const Arguments& args) {
HandleScope scope;
<%
var
jsArg;
-
%>
<%
include
guardArguments
.
cc
.
ejs
-
%>
if (args.Length() ==
<%
-
jsArg
%>
|| !args[
<%
-
jsArg
%>
]->IsFunction()) {
return ThrowException(Exception::Error(String::New("Callback is required and must be a Function.")));
}
<%
-
functionInfo
.
cppFunctionName
%>
Baton* baton = new
<%
-
functionInfo
.
cppFunctionName
%>
Baton;
baton->error_code = GIT_OK;
baton->error = NULL;
baton->request.data = baton;
<%
for
(
var
cArg
=
0
, jsArg
=
0
; cArg
<
functionInfo
.
args
.
length
; cArg
++
) {
var
arg
=
functionInfo
.
args
[cArg];
-%
>
<
%
if
(
!
arg
.
isReturn
) {
-%
>
<
%
if
(
arg
.
isSelf
) {
-%
>
baton
-
><
%-
arg
.
name
%
>
Reference
=
Persistent
<
Value
>
::
New
(
args
.
This
());
baton
-
><
%-
arg
.
name
%
>
=
ObjectWrap
::
Unwrap
<<
%-
cppClassName
%
>>
(
args
.
This
())
-
>
GetValue
();
<
%
}
else
{
-%
>
baton
-
><
%-
arg
.
name
%
>
Reference
=
Persistent
<
Value
>
::
New
(args[
<
%-
jsArg
%
>
]);
<
%
include
convertFromV8
.
cc
.
ejs
-%
>
<
%
if
(
!
arg
.
isPayload
) {
-%
>
baton
-
><
%-
arg
.
name
%
>
=
from_
<
%-
arg
.
name
%
>
;
<
%
}
-%
>
<
%
}
-%
>
<
%
if
(
!
(
arg
.
isReturn
||
arg
.
isSelf
||
arg
.
isPayload
)) jsArg
++
;
-%
>
<
%
}
else
{
-%
>
<
%
if
(
arg
.
shouldAlloc
) {
-%
>
baton
-
><
%-
arg
.
name
%
>
=
(
<
%-
arg
.
cType
%
>
)
malloc
(
sizeof
(
<
%-
arg
.
cType
.
replace
(
'
*
'
,
'
'
)
%
>
));
<
%
}
else
{
-%
>
<
%
}
-%
>
<
%
}
-%
>
<
%
}
-
%>
baton->callback = Persistent<
Function
>::New(Local<
Function
>::Cast(args[
<%
-
jsArg
%>
]));
uv_queue_work(uv_default_loop(), &baton->request,
<%
-
functionInfo
.
cppFunctionName
%>
Work, (uv_after_work_cb)
<%
-
functionInfo
.
cppFunctionName
%>
AfterWork);
return Undefined();
}
void
<%
-
cppClassName
%>
::
<%
-
functionInfo
.
cppFunctionName
%>
Work(uv_work_t *req) {
<%
-
functionInfo
.
cppFunctionName
%>
Baton *baton = static_cast<
<%
-
functionInfo
.
cppFunctionName
%>
Baton *>(req->data);
<%
if
(
functionInfo
.
return
.
cType
!=
"
void
"
||
functionInfo
.
return
.
isErrorCode
) {
%
><
%-
functionInfo
.
return
.
cType
%
>
result
=
<
%
}
%><%
-
functionInfo
.
cFunctionName
%>
(
<%
for
(
var
i
=
0
; i
<
functionInfo
.
args
.
length
; i
++
) {
var
arg
=
functionInfo
.
args
[i];
-%
>
<
%
if
(
arg
.
isReturn
&&
/
\*\*
/
.
test
(
arg
.
cType
)) {
%
>
&
<
%
}
%
>
baton
-
><
%-
arg
.
name
%
><
%
if
(i
<
functionInfo
.
args
.
length
-
1
) {
%
>
,
<
%
}
%
>
<
%
}
-
%>
);
<%
if
(
functionInfo
.
return
.
isErrorCode
) {
-%
>
baton
-
>
error_code
=
result;
if
(result
!=
GIT_OK
&&
giterr_last
()
!=
NULL
) {
baton
-
>
error
=
git_error_dup
(
giterr_last
());
}
<
%
}
else
if
(
functionInfo
.
return
.
cType
!=
"
void
"
) {
-%
>
baton
-
>
result
=
result;
<
%
}
-
%>
}
void
<%
-
cppClassName
%>
::
<%
-
functionInfo
.
cppFunctionName
%>
AfterWork(uv_work_t *req) {
HandleScope scope;
<%
-
functionInfo
.
cppFunctionName
%>
Baton *baton = static_cast<
<%
-
functionInfo
.
cppFunctionName
%>
Baton *>(req->data);
TryCatch try_catch;
if (baton->error_code == GIT_OK) {
<%
if
(
!
returns
.
length
) {
-%
>
Handle
<
Value
>
result
=
Local
<
Value
>
::
New
(
Undefined
());
<
%
}
else
if
(
returns
.
length
==
1
) {
-%
>
<
%
var
to
=
{};
to
.
__proto__
=
returns[
0
];
to
.
name
=
"
baton->
"
+
to
.
name
;
-%
>
Handle
<
Value
>
to;
<
%
include
convertToV8
.
cc
.
ejs
-%
>
Handle
<
Value
>
result
=
to;
<
%
}
else
{
-%
>
Handle
<
Object
>
result
=
Object
::
New
();
Handle
<
Value
>
to;
<
%
for
(r
in
returns) {
var
to
=
returns[r];
-%
>
<
%
include
convertToV8
.
cc
.
ejs
-%
>
result
-
>
Set
(
String
::
NewSymbol
(
"
<%- to.jsName || to.name %>
"
), to);
<
%
}
-%
>
<
%
}
-
%>
Handle<
Value
> argv[2] = {
Local<
Value
>::New(Null()),
result
};
baton->callback->Call(Context::GetCurrent()->Global(), 2, argv);
} else {
if (baton->error) {
Handle<
Value
> argv[1] = {
Exception::Error(String::New(baton->error->message))
};
baton->callback->Call(Context::GetCurrent()->Global(), 1, argv);
if (baton->error->message)
free((void *)baton->error->message);
free((void *)baton->error);
} else {
baton->callback->Call(Context::GetCurrent()->Global(), 0, NULL);
}
<%
for
(
var
i
=
0
; i
<
functionInfo
.
args
.
length
; i
++
) {
var
arg
=
functionInfo
.
args
[i];
if
(
!
arg
.
shouldAlloc
)
continue
;
-%
>
free
(baton
-
><
%=
arg
.
name
%
>
);
<
%
}
-
%>
}
if (try_catch.HasCaught()) {
node::FatalException(try_catch);
}
<%
for
(
var
i
=
0
, j
=
0
; i
<
functionInfo
.
args
.
length
; i
++
) {
var
arg
=
functionInfo
.
args
[i];
if
(
arg
.
isReturn
)
continue
;
-%
>
baton
-
><
%-
arg
.
name
%
>
Reference
.
Dispose
();
<
%
}
-
%>
baton->callback.Dispose();
<%
for
(
var
i
=
0
; i
<
functionInfo
.
args
.
length
; i
++
) {
var
arg
=
functionInfo
.
args
[i];
-%
>
<
%
if
([
'
String
'
,
'
Array
'
].
indexOf
(
arg
.
cppClassName
)
>
-
1
) {
-%
>
<
%
if
(
arg
.
freeFunctionName
) {
%
>
<
%-
arg
.
freeFunctionName
%
>
(baton
-
><
%-
arg
.
name
%
>
);
<
%
}
else
{
-%
>
free
((
void
*
)baton
-
><
%-
arg
.
name
%
>
);
<
%
}
-%
>
<
%
}
-%
>
<
%
}
-
%>
delete baton;
}
Back
|
FazBrowse Home
|
New Git URL