@@ -17,6 +17,8 @@ function setupMethods (soljson) {
17
17
return translate . versionToSemver ( version ( ) ) ;
18
18
} ;
19
19
20
+ var isVersion6 = semver . gt ( versionToSemver ( ) , '0.5.99' ) ;
21
+
20
22
var license ;
21
23
if ( '_solidity_license' in soljson ) {
22
24
license = soljson . cwrap ( 'solidity_license' , 'string' , [ ] ) ;
@@ -51,7 +53,7 @@ function setupMethods (soljson) {
51
53
52
54
var wrapCallbackWithKind = function ( callback ) {
53
55
assert ( typeof callback === 'function' , 'Invalid callback specified.' ) ;
54
- return function ( kind , data , contents , error ) {
56
+ return function ( context , kind , data , contents , error ) {
55
57
var result = callback ( soljson . Pointer_stringify ( kind ) , soljson . Pointer_stringify ( data ) ) ;
56
58
if ( typeof result . contents === 'string' ) {
57
59
copyString ( result . contents , contents ) ;
@@ -80,7 +82,7 @@ function setupMethods (soljson) {
80
82
}
81
83
82
84
var singleCallback ;
83
- if ( semver . gt ( versionToSemver ( ) , '0.5.99' ) ) {
85
+ if ( isVersion6 ) {
84
86
// After 0.6.x multiple kind of callbacks are supported.
85
87
var smtSolverCallback = callbacks . smtSolver ;
86
88
if ( smtSolverCallback === undefined ) {
@@ -115,6 +117,10 @@ function setupMethods (soljson) {
115
117
var output ;
116
118
try {
117
119
args . push ( cb ) ;
120
+ if ( isVersion6 ) {
121
+ // Callback context.
122
+ args . push ( null ) ;
123
+ }
118
124
output = compile . apply ( undefined , args ) ;
119
125
} catch ( e ) {
120
126
removeFunction ( cb ) ;
@@ -126,16 +132,19 @@ function setupMethods (soljson) {
126
132
127
133
var compileJSON = null ;
128
134
if ( '_compileJSON' in soljson ) {
135
+ // input (text), optimize (bool) -> output (jsontext)
129
136
compileJSON = soljson . cwrap ( 'compileJSON' , 'string' , [ 'string' , 'number' ] ) ;
130
137
}
131
138
132
139
var compileJSONMulti = null ;
133
140
if ( '_compileJSONMulti' in soljson ) {
141
+ // input (jsontext), optimize (bool) -> output (jsontext)
134
142
compileJSONMulti = soljson . cwrap ( 'compileJSONMulti' , 'string' , [ 'string' , 'number' ] ) ;
135
143
}
136
144
137
145
var compileJSONCallback = null ;
138
146
if ( '_compileJSONCallback' in soljson ) {
147
+ // input (jsontext), optimize (bool), callback (ptr) -> output (jsontext)
139
148
var compileInternal = soljson . cwrap ( 'compileJSONCallback' , 'string' , [ 'string' , 'number' , 'number' ] ) ;
140
149
compileJSONCallback = function ( input , optimize , readCallback ) {
141
150
return runWithCallbacks ( readCallback , compileInternal , [ input , optimize ] ) ;
@@ -144,13 +153,21 @@ function setupMethods (soljson) {
144
153
145
154
var compileStandard = null ;
146
155
if ( '_compileStandard' in soljson ) {
156
+ // input (jsontext), callback (ptr) -> output (jsontext)
147
157
var compileStandardInternal = soljson . cwrap ( 'compileStandard' , 'string' , [ 'string' , 'number' ] ) ;
148
158
compileStandard = function ( input , readCallback ) {
149
159
return runWithCallbacks ( readCallback , compileStandardInternal , [ input ] ) ;
150
160
} ;
151
161
}
152
162
if ( '_solidity_compile' in soljson ) {
153
- var solidityCompile = soljson . cwrap ( 'solidity_compile' , 'string' , [ 'string' , 'number' ] ) ;
163
+ var solidityCompile ;
164
+ if ( isVersion6 ) {
165
+ // input (jsontext), callback (ptr), callback_context (ptr) -> output (jsontext)
166
+ solidityCompile = soljson . cwrap ( 'solidity_compile' , 'string' , [ 'string' , 'number' , 'number' ] ) ;
167
+ } else {
168
+ // input (jsontext), callback (ptr) -> output (jsontext)
169
+ solidityCompile = soljson . cwrap ( 'solidity_compile' , 'string' , [ 'string' , 'number' ] ) ;
170
+ }
154
171
compileStandard = function ( input , callbacks ) {
155
172
return runWithCallbacks ( callbacks , solidityCompile , [ input ] ) ;
156
173
} ;
0 commit comments