Skip to content

Commit 67b2693

Browse files
committed
Support callback context in 0.6.x
1 parent cfe1713 commit 67b2693

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

wrapper.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function setupMethods (soljson) {
5353

5454
var wrapCallbackWithKind = function (callback) {
5555
assert(typeof callback === 'function', 'Invalid callback specified.');
56-
return function (kind, data, contents, error) {
56+
return function (context, kind, data, contents, error) {
5757
var result = callback(soljson.Pointer_stringify(kind), soljson.Pointer_stringify(data));
5858
if (typeof result.contents === 'string') {
5959
copyString(result.contents, contents);
@@ -117,6 +117,10 @@ function setupMethods (soljson) {
117117
var output;
118118
try {
119119
args.push(cb);
120+
if (isVersion6) {
121+
// Callback context.
122+
args.push(null);
123+
}
120124
output = compile.apply(undefined, args);
121125
} catch (e) {
122126
removeFunction(cb);
@@ -152,7 +156,12 @@ function setupMethods (soljson) {
152156
};
153157
}
154158
if ('_solidity_compile' in soljson) {
155-
var solidityCompile = soljson.cwrap('solidity_compile', 'string', ['string', 'number']);
159+
var solidityCompile;
160+
if (isVersion6) {
161+
solidityCompile = soljson.cwrap('solidity_compile', 'string', ['string', 'number', 'number']);
162+
} else {
163+
solidityCompile = soljson.cwrap('solidity_compile', 'string', ['string', 'number']);
164+
}
156165
compileStandard = function (input, callbacks) {
157166
return runWithCallbacks(callbacks, solidityCompile, [ input ]);
158167
};

0 commit comments

Comments
 (0)