@@ -3,18 +3,10 @@ import { https } from 'follow-redirects';
3
3
import MemoryStream from 'memorystream' ;
4
4
import assert from 'assert' ;
5
5
import * as semver from 'semver' ;
6
+ import { Callbacks } from './common/interfaces' ;
6
7
7
8
const Module = module . constructor as any ;
8
9
9
- interface ReadCallbackReply {
10
- error ?: string ;
11
- contents ?: string
12
- }
13
-
14
- interface Callbacks {
15
- import ( path : string ) : ReadCallbackReply ;
16
- }
17
-
18
10
function setupMethods ( soljson ) {
19
11
let version ;
20
12
if ( '_solidity_version' in soljson ) {
@@ -73,23 +65,23 @@ function setupMethods (soljson) {
73
65
const createWrappedLspSend = function ( ) {
74
66
const wrappedLspSend = soljson . cwrap ( 'solidity_lsp_send' , 'number' , [ 'string' ] ) ;
75
67
return function ( input : String ) {
76
- let args = [ ] ;
68
+ const args = [ ] ;
77
69
args . push ( JSON . stringify ( input ) ) ;
78
70
return wrappedLspSend . apply ( undefined , args ) ;
79
71
} ;
80
72
} ;
81
73
82
74
// Creates a wrapper around `int solidity_lsp_start(callbacks: Callbacks)`.
83
75
const createWrappedLspStart = function ( ) {
84
- const wrappedLspStart = soljson . cwrap ( 'solidity_lsp_start' , 'number' , [ ] ) ;
85
- return function ( callbacks : Callbacks ) {
76
+ const wrappedLspStart = soljson . cwrap ( 'solidity_lsp_start' , 'number' , [ ] ) ;
77
+ return function ( callbacks : Callbacks ) {
86
78
let readCallback = callbacks . import ;
87
79
assert ( typeof readCallback === 'function' , 'Invalid callback specified.' ) ;
88
80
const copyFromCString = soljson . UTF8ToString || soljson . Pointer_stringify ;
89
81
90
82
const wrappedReadCallback = function ( path : string , contents : string , error : string ) {
91
- // Calls the user-supplied file read callback and passes the return values
92
- // accordingly to either @p contents or into @p error on failure.
83
+ // Calls the user-supplied file read callback and passes the return values
84
+ // accordingly to either @p contents or into @p error on failure.
93
85
const result = readCallback ( copyFromCString ( path ) ) ;
94
86
if ( typeof result . contents === 'string' ) {
95
87
copyToCString ( result . contents , contents ) ;
@@ -104,7 +96,7 @@ function setupMethods (soljson) {
104
96
const wrappedFunctionId = addFunction ( wrappedReadCallback , 'ii' ) ;
105
97
106
98
try {
107
- // call solidity_lsp_start(callbacks)
99
+ // call solidity_lsp_start(callbacks)
108
100
let args = [ ] ;
109
101
args . push ( wrappedFunctionId ) ;
110
102
let output = wrappedLspStart . apply ( undefined , args ) ;
@@ -119,7 +111,7 @@ function setupMethods (soljson) {
119
111
// safe to be released.
120
112
// Probably by clearly defining semantics and memory lifetimes
121
113
// of output strings.
122
- } ;
114
+ } ;
123
115
} ;
124
116
125
117
// This is to support multiple versions of Emscripten.
0 commit comments