Permalink
Browse files

Merge branch 'incoming' into llvmsvn

  • Loading branch information...
2 parents 7645feb + 9662b11 commit 937b9b570a83f394ba7de732321ede8584d9f72e @kripken committed May 24, 2012
Showing with 44 additions and 13 deletions.
  1. +1 −1 emcc
  2. +1 −1 src/library.js
  3. +7 −1 src/library_gl.js
  4. +19 −9 src/library_sdl.js
  5. +15 −1 tests/runner.py
  6. +1 −0 tests/sdl_mouse.c
View
2 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.
'''
View
@@ -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',
View
@@ -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'],
View
@@ -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
},
View
@@ -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 @@ def test_emcc(self):
# --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', ''))
View
@@ -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);

0 comments on commit 937b9b5

Please sign in to comment.