aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-05-24 16:12:40 +0200
committerAlon Zakai <alonzakai@gmail.com>2012-05-24 16:12:40 +0200
commit937b9b570a83f394ba7de732321ede8584d9f72e (patch)
treeae4a6fcd401b6cb707243e3a4425d410e811f767
parent7645febb278fbd7bd4d1639c72168db9599e93f5 (diff)
parent9662b116ce446adc36d70453976989a16b8f2997 (diff)
Merge branch 'incoming' into llvmsvn
-rwxr-xr-xemcc2
-rw-r--r--src/library.js2
-rw-r--r--src/library_gl.js8
-rw-r--r--src/library_sdl.js28
-rwxr-xr-xtests/runner.py16
-rw-r--r--tests/sdl_mouse.c1
6 files changed, 44 insertions, 13 deletions
diff --git a/emcc b/emcc
index 635d6132..7db1ca3b 100755
--- a/emcc
+++ b/emcc
@@ -128,7 +128,7 @@ if len(sys.argv) == 1:
if sys.argv[1] == '--version':
print '''emcc (Emscripten GCC-like replacement) 2.0
-Copyright (C) 2011 the Emscripten authors.
+Copyright (C) 2012 the Emscripten authors.
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
'''
diff --git a/src/library.js b/src/library.js
index 2472e701..4b7b755b 100644
--- a/src/library.js
+++ b/src/library.js
@@ -2852,7 +2852,7 @@ LibraryManager.library = {
streamObj.error = true;
return -1;
} else {
- return {{{ makeGetValue('_fgetc.ret', '0', 'i8') }}};
+ return {{{ makeGetValue('_fgetc.ret', '0', 'i8', null, 1) }}};
}
},
getc: 'fgetc',
diff --git a/src/library_gl.js b/src/library_gl.js
index b5d65ee6..3eba76d0 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1828,11 +1828,17 @@ var LibraryGL = {
},
glFogf: function(){}, // TODO
+ glFogi: function(){}, // TODO
+ glFogx: function(){}, // TODO
+ glFogfv: function(){}, // TODO
glPolygonMode: function(){}, // TODO
glAlphaFunc: function(){}, // TODO
+ glNormal3f: function(){}, // TODO
+
+
// ClientState/gl*Pointer
glEnableClientState: function(cap, disable) {
@@ -2040,7 +2046,7 @@ var LibraryGL = {
};
// Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name
-[[0, 'shadeModel fogi fogfv getError* finish flush'],
+[[0, 'shadeModel getError* finish flush'],
[1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear enableVertexAttribArray disableVertexAttribArray lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation polygonOffset sampleCoverage isEnabled*'],
[2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint'],
[3, 'texParameteri texParameterf drawArrays vertexAttrib2f stencilFunc stencilOp'],
diff --git a/src/library_sdl.js b/src/library_sdl.js
index e2e199e5..85a04d27 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -27,6 +27,7 @@ var LibrarySDL = {
startTime: null,
mouseX: 0,
mouseY: 0,
+ buttonState: 0,
DOMEventToSDLEvent: {},
@@ -307,7 +308,7 @@ var LibrarySDL = {
}
return false;
},
-
+
makeCEvent: function(event, ptr) {
if (typeof event === 'number') {
// This is a pointer to a native C event that was SDL_PushEvent'ed
@@ -349,7 +350,17 @@ var LibrarySDL = {
break;
}
- case 'mousedown': case 'mouseup': case 'mousemove': {
+ case 'mousedown': case 'mouseup':
+ if (event.type == 'mousedown') {
+ // SDL_BUTTON(x) is defined as (1 << ((x)-1)). SDL buttons are 1-3,
+ // and DOM buttons are 0-2, so this means that the below formula is
+ // correct.
+ SDL.buttonState |= 1 << event.button;
+ } else if (event.type == 'mouseup') {
+ SDL.buttonState = 0;
+ }
+ // fall through
+ case 'mousemove': {
var x = event.pageX - Module['canvas'].offsetLeft;
var y = event.pageY - Module['canvas'].offsetTop;
if (event.type != 'mousemove') {
@@ -361,8 +372,7 @@ var LibrarySDL = {
{{{ makeSetValue('ptr', 'SDL.structs.MouseButtonEvent.y', 'y', 'i32') }}};
} else {
{{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.type', 'SDL.DOMEventToSDLEvent[event.type]', 'i32') }}};
- {{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.button', 'event.button', 'i8') }}};
- {{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.state', 'down ? 1 : 0', 'i8') }}};
+ {{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.state', 'SDL.buttonState', 'i8') }}};
{{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.x', 'x', 'i32') }}};
{{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.y', 'y', 'i32') }}};
{{{ makeSetValue('ptr', 'SDL.structs.MouseMotionEvent.xrel', 'Browser.getMovementX(x - SDL.mouseX, event)', 'i32') }}};
@@ -434,11 +444,11 @@ var LibrarySDL = {
SDL.keyboardState = _malloc(0x10000);
_memset(SDL.keyboardState, 0, 0x10000);
// Initialize this structure carefully for closure
- SDL.DOMEventToSDLEvent['keydown'] = 0x300;
- SDL.DOMEventToSDLEvent['keyup'] = 0x301;
- SDL.DOMEventToSDLEvent['mousedown'] = 0x401;
- SDL.DOMEventToSDLEvent['mouseup'] = 0x402;
- SDL.DOMEventToSDLEvent['mousemove'] = 0x400;
+ SDL.DOMEventToSDLEvent['keydown'] = 0x300 /* SDL_KEYDOWN */;
+ SDL.DOMEventToSDLEvent['keyup'] = 0x301 /* SDL_KEYUP */;
+ SDL.DOMEventToSDLEvent['mousedown'] = 0x401 /* SDL_MOUSEBUTTONDOWN */;
+ SDL.DOMEventToSDLEvent['mouseup'] = 0x402 /* SDL_MOUSEBUTTONUP */;
+ SDL.DOMEventToSDLEvent['mousemove'] = 0x400 /* SDL_MOUSEMOTION */;
return 0; // success
},
diff --git a/tests/runner.py b/tests/runner.py
index bf3bf119..31462a5a 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -3954,6 +3954,20 @@ def process(filename):
'''
self.do_run(src, 'isatty? 0,0,1\ngot: 35\ngot: 45\ngot: 25\ngot: 15\n', post_build=post)
+ def test_fgetc_unsigned(self):
+ if self.emcc_args is None: return self.skip('requires emcc')
+ src = r'''
+ #include <stdio.h>
+ int main() {
+ FILE *file = fopen("file_with_byte_234.txt", "rb");
+ int c = fgetc(file);
+ printf("*%d\n", c);
+ }
+ '''
+ open('file_with_byte_234.txt', 'wb').write('\xea')
+ self.emcc_args += ['--embed-file', 'file_with_byte_234.txt']
+ self.do_run(src, '*234\n')
+
def test_folders(self):
add_pre_run = '''
def process(filename):
@@ -6302,7 +6316,7 @@ TT = %s
# --version
output = Popen(['python', compiler, '--version'], stdout=PIPE, stderr=PIPE).communicate()
self.assertContained('''emcc (Emscripten GCC-like replacement) 2.0
-Copyright (C) 2011 the Emscripten authors.
+Copyright (C) 2012 the Emscripten authors.
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
''', output[0].replace('\r', ''), output[1].replace('\r', ''))
diff --git a/tests/sdl_mouse.c b/tests/sdl_mouse.c
index eb4aa425..8af87c8c 100644
--- a/tests/sdl_mouse.c
+++ b/tests/sdl_mouse.c
@@ -12,6 +12,7 @@ void one() {
switch(event.type) {
case SDL_MOUSEMOTION: {
SDL_MouseMotionEvent *m = (SDL_MouseMotionEvent*)&event;
+ assert(m->state == 0);
int x, y;
SDL_GetMouseState(&x, &y);
assert(x == m->x && y == m->y);