Mercurial > hg > piper-vamp-js
diff quick-test.js @ 43:90bf9d9f9c95
Rearrange and rename VamPipe -> Piper as appropriate
author | Chris Cannam |
---|---|
date | Mon, 10 Oct 2016 17:05:37 +0100 |
parents | a734a7e976fa |
children |
line wrap: on
line diff
--- a/quick-test.js Fri Oct 07 16:43:18 2016 +0100 +++ b/quick-test.js Mon Oct 10 17:05:37 2016 +0100 @@ -6,20 +6,20 @@ // "string", in which case Emscripten will take care of // conversions. But it's not clear how one would manage memory for // newly-constructed returned C strings -- the returned pointer from -// vampipeRequestJson would appear (?) to be thrown away by the +// piperRequestJson would appear (?) to be thrown away by the // Emscripten string converter if we declare it as returning a string, -// so we have no opportunity to pass it to vampipeFreeJson, which +// so we have no opportunity to pass it to piperFreeJson, which // suggests this would leak memory if the string isn't static. Not // wholly sure though. Anyway, passing and returning pointers (as // numbers) means we can manage the Emscripten heap memory however we // want in our request wrapper function below. -var vampipeRequestJson = exampleModule.cwrap( - 'vampipeRequestJson', 'number', ['number'] +var piperRequestJson = exampleModule.cwrap( + 'piperRequestJson', 'number', ['number'] ); -var vampipeFreeJson = exampleModule.cwrap( - 'vampipeFreeJson', 'void', ['number'] +var piperFreeJson = exampleModule.cwrap( + 'piperFreeJson', 'void', ['number'] ); function note(blah) { @@ -38,10 +38,10 @@ // don't mention this). Note the *Cstr values are Emscripten heap // pointers var inCstr = m.allocate(m.intArrayFromString(jsonStr), 'i8', m.ALLOC_NORMAL); - var outCstr = vampipeRequestJson(inCstr); + var outCstr = piperRequestJson(inCstr); m._free(inCstr); var result = m.Pointer_stringify(outCstr); - vampipeFreeJson(outCstr); + piperFreeJson(outCstr); note("Returned JSON = " + result); return result; }