parent
e148e0bd08
commit
76a80a1a55
File diff suppressed because one or more lines are too long
@ -1,62 +0,0 @@ |
||||
function setupMethods (soljson){ |
||||
|
||||
var compileJSON = soljson.cwrap("compileJSON", "string", ["string", "number"]); |
||||
var compileJSONMulti = |
||||
'_compileJSONMulti' in soljson ? |
||||
soljson.cwrap("compileJSONMulti", "string", ["string", "number"]) : |
||||
null; |
||||
var compileJSONCallback = null; |
||||
if ('_compileJSONCallback' in soljson) |
||||
{ |
||||
/// TODO: Allocating memory and copying the strings over
|
||||
/// to the emscripten runtime does not seem to work.
|
||||
var copyString = function(str, ptr) { |
||||
var buffer = soljson._malloc(str.length + 1); |
||||
soljson.writeStringToMemory(str, buffer); |
||||
soljson.setValue(ptr, buffer, '*'); |
||||
}; |
||||
var wrapCallback = function(callback) { |
||||
return soljson.Runtime.addFunction(function(path, contents, error) { |
||||
// path is char*, contents is char**, error is char**
|
||||
// TODO copying the results does not seem to work.
|
||||
// This is not too bad, because most of the requests
|
||||
// cannot be answered synchronously anyway.
|
||||
var result = callback(soljson.Pointer_stringify(path)); |
||||
if (typeof(result.contents) === typeof('')) |
||||
copyString(result.contents, contents); |
||||
if (typeof(result.error) === typeof('')) |
||||
copyString(result.error, error); |
||||
}); |
||||
}; |
||||
var compileInternal = soljson.cwrap("compileJSONCallback", "string", ["string", "number", "number"]); |
||||
compileJSONCallback = function(input, optimize, readCallback) { |
||||
var cb = wrapCallback(readCallback); |
||||
var output = compileInternal(input, optimize, cb); |
||||
soljson.Runtime.removeFunction(cb); |
||||
return output; |
||||
}; |
||||
} |
||||
|
||||
var compile = function(input, optimise, readCallback) { |
||||
var result = ''; |
||||
if (readCallback !== undefined && compileJSONCallback !== null) |
||||
result = compileJSONCallback(JSON.stringify(input), optimise, readCallback); |
||||
if (typeof(input) != typeof('') && compileJSONMulti !== null) |
||||
result = compileJSONMulti(JSON.stringify(input), optimise); |
||||
else |
||||
result = compileJSON(input, optimise); |
||||
return JSON.parse(result); |
||||
} |
||||
|
||||
var version = soljson.cwrap("version", "string", []); |
||||
|
||||
return { |
||||
version: version, |
||||
compile: compile, |
||||
useVersion: function( versionString ){ |
||||
return setupMethods( require('./bin/soljson-' + versionString + '.js' ) ); |
||||
} |
||||
} |
||||
} |
||||
|
||||
module.exports = setupMethods( require('./bin/soljson-latest.js') ); |
@ -0,0 +1,4 @@ |
||||
var app = require("./app.js"); |
||||
var $ = require("jquery"); |
||||
|
||||
$(document).ready(function() { app.run(); }); |
@ -0,0 +1,11 @@ |
||||
// This mainly extracts the provider that might be
|
||||
// supplied through mist.
|
||||
|
||||
var Web3 = require("web3"); |
||||
|
||||
if (typeof web3 !== 'undefined') |
||||
web3 = new Web3(web3.currentProvider); |
||||
else |
||||
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); |
||||
|
||||
module.exports = web3; |
Loading…
Reference in new issue