aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js5
-rw-r--r--src/library_openal.js74
-rw-r--r--src/library_sdl.js27
-rw-r--r--src/preamble.js2
-rw-r--r--src/settings.js2
-rwxr-xr-xtests/runner.py2
6 files changed, 103 insertions, 9 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 4263618a..bc89b0c4 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -513,7 +513,9 @@ function JSify(data, functionsOnly, givenFunctions) {
item.JS = addFromLibrary(shortident);
} else if (!LibraryManager.library.hasOwnProperty(shortident + '__inline')) {
item.JS = 'var ' + item.ident + '; // stub for ' + item.ident;
- if (WARN_ON_UNDEFINED_SYMBOLS || ASM_JS) { // always warn on undefs in asm, since it breaks validation
+ if (ASM_JS) {
+ throw 'Unresolved symbol: ' + item.ident + ', this must be corrected for asm.js validation to succeed. Consider adding it to DEAD_FUNCTIONS.';
+ } else if (WARN_ON_UNDEFINED_SYMBOLS) {
warn('Unresolved symbol: ' + item.ident);
}
}
@@ -722,6 +724,7 @@ function JSify(data, functionsOnly, givenFunctions) {
ret += indent + 'label = ' + getLabelId(block.entries[0]) + '; ' + (SHOW_LABELS ? '/* ' + getOriginalLabelId(block.entries[0]) + ' */' : '') + '\n';
} // otherwise, should have been set before!
if (func.setjmpTable) {
+ assert(!ASM_JS, 'asm.js mode does not support setjmp yet');
var setjmpTable = {};
ret += indent + 'var mySetjmpIds = {};\n';
ret += indent + 'var setjmpTable = {';
diff --git a/src/library_openal.js b/src/library_openal.js
index 5511ccb7..6bd0f6b0 100644
--- a/src/library_openal.js
+++ b/src/library_openal.js
@@ -41,7 +41,9 @@ var LibraryOpenAL = {
}
if (attrList) {
+#if OPENAL_DEBUG
console.log("The attrList argument of alcCreateContext is not supported yet");
+#endif
return 0;
}
@@ -73,7 +75,9 @@ var LibraryOpenAL = {
alDeleteSources: function(count, sources)
{
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alDeleteSources called without a valid context");
+#endif
return;
}
for (var i = 0; i < count; ++i) {
@@ -84,7 +88,9 @@ var LibraryOpenAL = {
alGenSources: function(count, sources) {
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alGenSources called without a valid context");
+#endif
return;
}
for (var i = 0; i < count; ++i) {
@@ -113,11 +119,15 @@ var LibraryOpenAL = {
alSourcei: function(source, param, value) {
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alSourcei called without a valid context");
+#endif
return;
}
if (source > AL.currentContext.src.length) {
+#if OPENAL_DEBUG
console.error("alSourcei called with an invalid source");
+#endif
return;
}
switch (param) {
@@ -132,18 +142,24 @@ var LibraryOpenAL = {
}
break;
default:
+#if OPENAL_DEBUG
console.log("alSourcei with param " + param + " not implemented yet");
+#endif
break;
}
},
alSourcef: function(source, param, value) {
if (!AL.currentContext) {
- consoue.error("alSourcef called without a valid context");
+#if OPENAL_DEBUG
+ console.error("alSourcef called without a valid context");
+#endif
return;
}
if (source > AL.currentContext.src.length) {
+#if OPENAL_DEBUG
console.error("alSourcef called with an invalid source");
+#endif
return;
}
switch (param) {
@@ -151,21 +167,29 @@ var LibraryOpenAL = {
AL.currentContext.src[source - 1].gain.gain.value = value;
break;
case 0x1003 /* AL_PITCH */:
+#if OPENAL_DEBUG
console.log("alSourcef was called with AL_PITCH, but Web Audio does not support static pitch changes");
+#endif
break;
default:
+#if OPENAL_DEBUG
console.log("alSourcef with param " + param + " not implemented yet");
+#endif
break;
}
},
alSourcefv: function(source, param, value) {
if (!AL.currentContext) {
- consoue.error("alSourcefv called without a valid context");
+#if OPENAL_DEBUG
+ console.error("alSourcefv called without a valid context");
+#endif
return;
}
if (source > AL.currentContext.src.length) {
+#if OPENAL_DEBUG
console.error("alSourcefv called with an invalid source");
+#endif
return;
}
switch (param) {
@@ -184,28 +208,38 @@ var LibraryOpenAL = {
);
break;
default:
+#if OPENAL_DEBUG
console.log("alSourcefv with param " + param + " not implemented yet");
+#endif
break;
}
},
alSourceQueueBuffers: function(source, count, buffers) {
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alSourceQueueBuffers called without a valid context");
+#endif
return;
}
if (source > AL.currentContext.src.length) {
+#if OPENAL_DEBUG
console.error("alSourceQueueBuffers called with an invalid source");
+#endif
return;
}
if (count != 1) {
+#if OPENAL_DEBUG
console.error("Queuing multiple buffers using alSourceQueueBuffers is not supported yet");
+#endif
return;
}
for (var i = 0; i < count; ++i) {
var buffer = {{{ makeGetValue('buffers', 'i', 'i32') }}};
if (buffer > AL.currentContext.buf.length) {
+#if OPENAL_DEBUG
console.error("alSourceQueueBuffers called with an invalid buffer");
+#endif
return;
}
AL.currentContext.src[source - 1].buffer = AL.currentContext.buf[buffer - 1].buf;
@@ -215,15 +249,21 @@ var LibraryOpenAL = {
alSourceUnqueueBuffers: function(source, count, buffers)
{
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alSourceUnqueueBuffers called without a valid context");
+#endif
return;
}
if (source > AL.currentContext.src.length) {
+#if OPENAL_DEBUG
console.error("alSourceUnqueueBuffers called with an invalid source");
+#endif
return;
}
if (count != 1) {
+#if OPENAL_DEBUG
console.error("Queuing multiple buffers using alSourceUnqueueBuffers is not supported yet");
+#endif
return;
}
for (var i = 0; i < count; ++i) {
@@ -241,7 +281,9 @@ var LibraryOpenAL = {
alDeleteBuffers: function(count, buffers)
{
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alDeleteBuffers called without a valid context");
+#endif
return;
}
for (var i = 0; i < count; ++i) {
@@ -259,7 +301,9 @@ var LibraryOpenAL = {
alGenBuffers: function(count, buffers) {
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alGenBuffers called without a valid context");
+#endif
return;
}
for (var i = 0; i < count; ++i) {
@@ -270,11 +314,15 @@ var LibraryOpenAL = {
alBufferData: function(buffer, format, data, size, freq) {
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alBufferData called without a valid context");
+#endif
return;
}
if (buffer > AL.currentContext.buf.length) {
+#if OPENAL_DEBUG
console.error("alBufferData called with an invalid buffer");
+#endif
return;
}
var channels, bytes;
@@ -296,7 +344,9 @@ var LibraryOpenAL = {
channels = 2;
break;
default:
+#if OPENAL_DEBUG
console.error("alBufferData called with invalid format " + format);
+#endif
return;
}
AL.currentContext.buf[buffer - 1].buf = AL.currentContext.ctx.createBuffer(channels, size / (bytes * channels), freq);
@@ -323,11 +373,15 @@ var LibraryOpenAL = {
alSourcePlay__deps: ["alSourceStop"],
alSourcePlay: function(source) {
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alSourcePlay called without a valid context");
+#endif
return;
}
if (source > AL.currentContext.src.length) {
+#if OPENAL_DEBUG
console.error("alSourcePlay called with an invalid source");
+#endif
return;
}
var offset = 0;
@@ -353,11 +407,15 @@ var LibraryOpenAL = {
alSourceStop: function(source) {
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alSourceStop called without a valid context");
+#endif
return;
}
if (source > AL.currentContext.src.length) {
+#if OPENAL_DEBUG
console.error("alSourceStop called with an invalid source");
+#endif
return;
}
if ("src" in AL.currentContext.src[source - 1]) {
@@ -368,11 +426,15 @@ var LibraryOpenAL = {
alSourcePause: function(source) {
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alSourcePause called without a valid context");
+#endif
return;
}
if (source > AL.currentContext.src.length) {
+#if OPENAL_DEBUG
console.error("alSourcePause called with an invalid source");
+#endif
return;
}
if ("src" in AL.currentContext.src[source - 1] &&
@@ -387,11 +449,15 @@ var LibraryOpenAL = {
alGetSourcei: function(source, param, value) {
if (!AL.currentContext) {
+#if OPENAL_DEBUG
console.error("alGetSourcei called without a valid context");
+#endif
return;
}
if (source > AL.currentContext.src.length) {
+#if OPENAL_DEBUG
console.error("alGetSourcei called with an invalid source");
+#endif
return;
}
switch (param) {
@@ -440,12 +506,16 @@ var LibraryOpenAL = {
alDistanceModel: function(model) {
if (model != 0 /* AL_NONE */) {
+#if OPENAL_DEBUG
console.log("Only alDistanceModel(AL_NONE) is currently supported");
+#endif
}
},
alListenerfv: function(param, values) {
+#if OPENAL_DEBUG
console.log("alListenerfv is not supported yet");
+#endif
},
alIsExtensionPresent: function(extName) {
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 9fc979d2..77305609 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -443,6 +443,23 @@ var LibrarySDL = {
return false;
},
+ offsetsTemp: { left: 0, top: 0 }, // temporary object to avoid generating garbage in offsets(). assumes the object is not captured
+
+ offsets: function(element) {
+ var left = 0;
+ var top = 0;
+
+ do {
+ left += element.offsetLeft;
+ top += element.offsetTop;
+ } while (element = element.offsetParent)
+
+ var ret = SDL.offsetsTemp;
+ ret.left = left;
+ ret.top = top;
+ return ret;
+ },
+
makeCEvent: function(event, ptr) {
if (typeof event === 'number') {
// This is a pointer to a native C event that was SDL_PushEvent'ed
@@ -524,8 +541,9 @@ var LibrarySDL = {
} else {
// Otherwise, calculate the movement based on the changes
// in the coordinates.
- var x = event.pageX - Module["canvas"].offsetLeft;
- var y = event.pageY - Module["canvas"].offsetTop;
+ var offsets = SDL.offsets(Module["canvas"]);
+ var x = event.pageX - offsets.left;
+ var y = event.pageY - offsets.top;
var movementX = x - SDL.mouseX;
var movementY = y - SDL.mouseY;
}
@@ -912,10 +930,11 @@ var LibrarySDL = {
SDL_WarpMouse: function(x, y) {
return; // TODO: implement this in a non-buggy way. Need to keep relative mouse movements correct after calling this
+ var offsets = SDL.offsets(Module["canvas"]);
SDL.events.push({
type: 'mousemove',
- pageX: x + Module['canvas'].offsetLeft,
- pageY: y + Module['canvas'].offsetTop
+ pageX: x + offsets.left,
+ pageY: y + offsets.top
});
},
diff --git a/src/preamble.js b/src/preamble.js
index 6f3a969c..a1755798 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -556,7 +556,7 @@ function enlargeMemory() {
#if ASM_JS == 0
abort('Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.');
#else
- abort('Cannot enlarge memory arrays in asm.js. Compile with -s TOTAL_MEMORY=X with X higher than the current value.');
+ abort('Cannot enlarge memory arrays in asm.js. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value, or (2) set Module.TOTAL_MEMORY before the program runs.');
#endif
#else
// TOTAL_MEMORY is the current size of the actual array, and STATICTOP is the new top.
diff --git a/src/settings.js b/src/settings.js
index 37c594ac..b342ae6d 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -163,6 +163,8 @@ var LIBRARY_DEBUG = 0; // Print out when we enter a library call (library*.js).
// emscripten_run_script("Runtime.debug = ...;");
var SOCKET_DEBUG = 0; // Log out socket/network data transfer.
+var OPENAL_DEBUG = 0; // Print out debugging information from our OpenAL implementation.
+
var GL_DEBUG = 0; // Print out all calls into WebGL. As with LIBRARY_DEBUG, you can set a runtime
// option, in this case GL.debug.
var GL_TESTING = 0; // When enabled, sets preserveDrawingBuffer in the context, to allow tests to work (but adds overhead)
diff --git a/tests/runner.py b/tests/runner.py
index f2a0bd4e..9ca444fb 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -9329,7 +9329,7 @@ f.close()
filename = self.in_dir('src.cpp')
open(filename, 'w').write(src)
out, err = Popen([PYTHON, EMCC, filename, '-s', 'ASM_JS=1', '-O2'], stderr=PIPE).communicate()
- assert 'Warning: Unresolved symbol' in err, 'always warn on undefs in asm, since it breaks validation'
+ assert 'Unresolved symbol' in err, 'always warn on undefs in asm, since it breaks validation: ' + err
def test_redundant_link(self):
lib = "int mult() { return 1; }"