[前][次][番号順一覧][スレッド一覧]

ruby-changes:39235

From: nobu <ko1@a...>
Date: Tue, 21 Jul 2015 19:52:23 +0900 (JST)
Subject: [ruby-changes:39235] nobu:r51316 (trunk): console.c: undefined vk

nobu	2015-07-21 19:52:19 +0900 (Tue, 21 Jul 2015)

  New Revision: 51316

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51316

  Log:
    console.c: undefined vk
    
    * ext/io/console/console.c (console_key_pressed_p): raise
      undefined virtual key code.

  Added files:
    trunk/ext/io/console/win32_vk.h
  Modified files:
    trunk/ext/io/console/console.c
    trunk/ext/io/console/depend
Index: ext/io/console/depend
===================================================================
--- ext/io/console/depend	(revision 51315)
+++ ext/io/console/depend	(revision 51316)
@@ -1,16 +1,24 @@ https://github.com/ruby/ruby/blob/trunk/ext/io/console/depend#L1
 $(OBJS): $(HDRS) $(ruby_headers) \
-  $(VK_HEADER) \
+  $(VK_HEADER) $(VK_HEADER:.chksum=.h) \
   $(hdrdir)/ruby/io.h \
   $(hdrdir)/ruby/encoding.h \
   $(hdrdir)/ruby/oniguruma.h
 
 win32_vk.inc: win32_vk.list
 
+win32_vk.h: win32_vk.list
+
 .list.inc:
 	gperf --ignore-case -E -C -P -p -j1 -i 1 -g -o -t -K ofs -N console_win32_vk -k* $< \
 	| sed 's/(int)(long)&((\(struct stringpool_t\) *\*)0)->\(stringpool_[a-z0-9]*\)/offsetof(\1, \2)/g' \
 	> $(@F)
 
+.list.h:
+	$(RUBY) -anF, \
+	-e '(n=$$F[1]) and (n.strip!; /\AVK_/=~n) and' \
+	-e   'puts %[#ifndef #{n}\n# define #{n} (unsigned short)-1\n#endif]' \
+	$< > $@
+
 .SUFFIXES: .chksum .list .inc
 
 .list.chksum:
Index: ext/io/console/console.c
===================================================================
--- ext/io/console/console.c	(revision 51315)
+++ ext/io/console/console.c	(revision 51316)
@@ -698,6 +698,7 @@ console_cursor_set(VALUE io, VALUE cpos) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L698
     return console_goto(io, RARRAY_AREF(cpos, 0), RARRAY_AREF(cpos, 1));
 }
 
+#include "win32_vk.h"
 #include "win32_vk.inc"
 
 static VALUE
@@ -717,8 +718,9 @@ console_key_pressed_p(VALUE io, VALUE k) https://github.com/ruby/ruby/blob/trunk/ext/io/console/console.c#L718
 	    StringValueCStr(k);
 	}
 	t = console_win32_vk(RSTRING_PTR(k), RSTRING_LEN(k));
-	if (!t) rb_raise(rb_eArgError, "unknown virtual key code: %"PRIsVALUE, k);
-	vk = t->vk;
+	if (!t || (vk = (short)t->vk) == -1) {
+	    rb_raise(rb_eArgError, "unknown virtual key code: %"PRIsVALUE, k);
+	}
     }
     return GetKeyState(vk) & 0x80 ? Qtrue : Qfalse;
 }
Index: ext/io/console/win32_vk.h
===================================================================
--- ext/io/console/win32_vk.h	(revision 0)
+++ ext/io/console/win32_vk.h	(revision 51316)
@@ -0,0 +1,480 @@ https://github.com/ruby/ruby/blob/trunk/ext/io/console/win32_vk.h#L1
+#ifndef VK_LBUTTON
+# define VK_LBUTTON (unsigned short)-1
+#endif
+#ifndef VK_RBUTTON
+# define VK_RBUTTON (unsigned short)-1
+#endif
+#ifndef VK_CANCEL
+# define VK_CANCEL (unsigned short)-1
+#endif
+#ifndef VK_MBUTTON
+# define VK_MBUTTON (unsigned short)-1
+#endif
+#ifndef VK_XBUTTON1
+# define VK_XBUTTON1 (unsigned short)-1
+#endif
+#ifndef VK_XBUTTON2
+# define VK_XBUTTON2 (unsigned short)-1
+#endif
+#ifndef VK_BACK
+# define VK_BACK (unsigned short)-1
+#endif
+#ifndef VK_TAB
+# define VK_TAB (unsigned short)-1
+#endif
+#ifndef VK_CLEAR
+# define VK_CLEAR (unsigned short)-1
+#endif
+#ifndef VK_RETURN
+# define VK_RETURN (unsigned short)-1
+#endif
+#ifndef VK_SHIFT
+# define VK_SHIFT (unsigned short)-1
+#endif
+#ifndef VK_CONTROL
+# define VK_CONTROL (unsigned short)-1
+#endif
+#ifndef VK_MENU
+# define VK_MENU (unsigned short)-1
+#endif
+#ifndef VK_PAUSE
+# define VK_PAUSE (unsigned short)-1
+#endif
+#ifndef VK_CAPITAL
+# define VK_CAPITAL (unsigned short)-1
+#endif
+#ifndef VK_KANA
+# define VK_KANA (unsigned short)-1
+#endif
+#ifndef VK_HANGEUL
+# define VK_HANGEUL (unsigned short)-1
+#endif
+#ifndef VK_HANGUL
+# define VK_HANGUL (unsigned short)-1
+#endif
+#ifndef VK_JUNJA
+# define VK_JUNJA (unsigned short)-1
+#endif
+#ifndef VK_FINAL
+# define VK_FINAL (unsigned short)-1
+#endif
+#ifndef VK_HANJA
+# define VK_HANJA (unsigned short)-1
+#endif
+#ifndef VK_KANJI
+# define VK_KANJI (unsigned short)-1
+#endif
+#ifndef VK_ESCAPE
+# define VK_ESCAPE (unsigned short)-1
+#endif
+#ifndef VK_CONVERT
+# define VK_CONVERT (unsigned short)-1
+#endif
+#ifndef VK_NONCONVERT
+# define VK_NONCONVERT (unsigned short)-1
+#endif
+#ifndef VK_ACCEPT
+# define VK_ACCEPT (unsigned short)-1
+#endif
+#ifndef VK_MODECHANGE
+# define VK_MODECHANGE (unsigned short)-1
+#endif
+#ifndef VK_SPACE
+# define VK_SPACE (unsigned short)-1
+#endif
+#ifndef VK_PRIOR
+# define VK_PRIOR (unsigned short)-1
+#endif
+#ifndef VK_NEXT
+# define VK_NEXT (unsigned short)-1
+#endif
+#ifndef VK_END
+# define VK_END (unsigned short)-1
+#endif
+#ifndef VK_HOME
+# define VK_HOME (unsigned short)-1
+#endif
+#ifndef VK_LEFT
+# define VK_LEFT (unsigned short)-1
+#endif
+#ifndef VK_UP
+# define VK_UP (unsigned short)-1
+#endif
+#ifndef VK_RIGHT
+# define VK_RIGHT (unsigned short)-1
+#endif
+#ifndef VK_DOWN
+# define VK_DOWN (unsigned short)-1
+#endif
+#ifndef VK_SELECT
+# define VK_SELECT (unsigned short)-1
+#endif
+#ifndef VK_PRINT
+# define VK_PRINT (unsigned short)-1
+#endif
+#ifndef VK_EXECUTE
+# define VK_EXECUTE (unsigned short)-1
+#endif
+#ifndef VK_SNAPSHOT
+# define VK_SNAPSHOT (unsigned short)-1
+#endif
+#ifndef VK_INSERT
+# define VK_INSERT (unsigned short)-1
+#endif
+#ifndef VK_DELETE
+# define VK_DELETE (unsigned short)-1
+#endif
+#ifndef VK_HELP
+# define VK_HELP (unsigned short)-1
+#endif
+#ifndef VK_LWIN
+# define VK_LWIN (unsigned short)-1
+#endif
+#ifndef VK_RWIN
+# define VK_RWIN (unsigned short)-1
+#endif
+#ifndef VK_APPS
+# define VK_APPS (unsigned short)-1
+#endif
+#ifndef VK_SLEEP
+# define VK_SLEEP (unsigned short)-1
+#endif
+#ifndef VK_NUMPAD0
+# define VK_NUMPAD0 (unsigned short)-1
+#endif
+#ifndef VK_NUMPAD1
+# define VK_NUMPAD1 (unsigned short)-1
+#endif
+#ifndef VK_NUMPAD2
+# define VK_NUMPAD2 (unsigned short)-1
+#endif
+#ifndef VK_NUMPAD3
+# define VK_NUMPAD3 (unsigned short)-1
+#endif
+#ifndef VK_NUMPAD4
+# define VK_NUMPAD4 (unsigned short)-1
+#endif
+#ifndef VK_NUMPAD5
+# define VK_NUMPAD5 (unsigned short)-1
+#endif
+#ifndef VK_NUMPAD6
+# define VK_NUMPAD6 (unsigned short)-1
+#endif
+#ifndef VK_NUMPAD7
+# define VK_NUMPAD7 (unsigned short)-1
+#endif
+#ifndef VK_NUMPAD8
+# define VK_NUMPAD8 (unsigned short)-1
+#endif
+#ifndef VK_NUMPAD9
+# define VK_NUMPAD9 (unsigned short)-1
+#endif
+#ifndef VK_MULTIPLY
+# define VK_MULTIPLY (unsigned short)-1
+#endif
+#ifndef VK_ADD
+# define VK_ADD (unsigned short)-1
+#endif
+#ifndef VK_SEPARATOR
+# define VK_SEPARATOR (unsigned short)-1
+#endif
+#ifndef VK_SUBTRACT
+# define VK_SUBTRACT (unsigned short)-1
+#endif
+#ifndef VK_DECIMAL
+# define VK_DECIMAL (unsigned short)-1
+#endif
+#ifndef VK_DIVIDE
+# define VK_DIVIDE (unsigned short)-1
+#endif
+#ifndef VK_F1
+# define VK_F1 (unsigned short)-1
+#endif
+#ifndef VK_F2
+# define VK_F2 (unsigned short)-1
+#endif
+#ifndef VK_F3
+# define VK_F3 (unsigned short)-1
+#endif
+#ifndef VK_F4
+# define VK_F4 (unsigned short)-1
+#endif
+#ifndef VK_F5
+# define VK_F5 (unsigned short)-1
+#endif
+#ifndef VK_F6
+# define VK_F6 (unsigned short)-1
+#endif
+#ifndef VK_F7
+# define VK_F7 (unsigned short)-1
+#endif
+#ifndef VK_F8
+# define VK_F8 (unsigned short)-1
+#endif
+#ifndef VK_F9
+# define VK_F9 (unsigned short)-1
+#endif
+#ifndef VK_F10
+# define VK_F10 (unsigned short)-1
+#endif
+#ifndef VK_F11
+# define VK_F11 (unsigned short)-1
+#endif
+#ifndef VK_F12
+# define VK_F12 (unsigned short)-1
+#endif
+#ifndef VK_F13
+# define VK_F13 (unsigned short)-1
+#endif
+#ifndef VK_F14
+# define VK_F14 (unsigned short)-1
+#endif
+#ifndef VK_F15
+# define VK_F15 (unsigned short)-1
+#endif
+#ifndef VK_F16
+# define VK_F16 (unsigned short)-1
+#endif
+#ifndef VK_F17
+# define VK_F17 (unsigned short)-1
+#endif
+#ifndef VK_F18
+# define VK_F18 (unsigned short)-1
+#endif
+#ifndef VK_F19
+# define VK_F19 (unsigned short)-1
+#endif
+#ifndef VK_F20
+# define VK_F20 (unsigned short)-1
+#endif
+#ifndef VK_F21
+# define VK_F21 (unsigned short)-1
+#endif
+#ifndef VK_F22
+# define VK_F22 (unsigned short)-1
+#endif
+#ifndef VK_F23
+# define VK_F23 (unsigned short)-1
+#endif
+#ifndef VK_F24
+# define VK_F24 (unsigned short)-1
+#endif
+#ifndef VK_NUMLOCK
+# define VK_NUMLOCK (unsigned short)-1
+#endif
+#ifndef VK_SCROLL
+# define VK_SCROLL (unsigned short)-1
+#endif
+#ifndef VK_OEM_NEC_EQUAL
+# define VK_OEM_NEC_EQUAL (unsigned short)-1
+#endif
+#ifndef VK_OEM_FJ_JISHO
+# define VK_OEM_FJ_JISHO (unsigned short)-1
+#endif
+#ifndef VK_OEM_FJ_MASSHOU
+# define VK_OEM_FJ_MASSHOU (unsigned short)-1
+#endif
+#ifndef VK_OEM_FJ_TOUROKU
+# define VK_OEM_FJ_TOUROKU (unsigned short)-1
+#endif
+#ifndef VK_OEM_FJ_LOYA
+# define VK_OEM_FJ_LOYA (unsigned short)-1
+#endif
+#ifndef VK_OEM_FJ_ROYA
+# define VK_OEM_FJ_ROYA (unsigned short)-1
+#endif
+#ifndef VK_LSHIFT
+# define VK_LSHIFT (unsigned short)-1
+#endif
+#ifndef VK_RSHIFT
+# define VK_RSHIFT (unsigned short)-1
+#endif
+#ifndef VK_LCONTROL
+# define VK_LCONTROL (unsigned short)-1
+#endif
+#ifndef VK_RCONTROL
+# define VK_RCONTROL (unsigned short)-1
+#endif
+#ifndef VK_LMENU
+# define VK_LMENU (unsigned short)-1
+#endif
+#ifndef VK_RMENU
+# define VK_RMENU (unsigned short)-1
+#endif
+#ifndef VK_BROWSER_BACK
+# define VK_BROWSER_BACK (unsigned short)-1
+#endif
+#ifndef VK_BROWSER_FORWARD
+# define VK_BROWSER_FORWARD (unsigned short)-1
+#endif
+#ifndef VK_BROWSER_REFRESH
+# define VK_BROWSER_REFRESH (unsigned short)-1
+#endif
+#ifndef VK_BROWSER_STOP
+# define VK_BROWSER_STOP (unsigned short)-1
+#endif
+#ifndef VK_BROWSER_SEARCH
+# define VK_BROWSER_SEARCH (unsigned short)-1
+#endif
+#ifndef VK_BROWSER_FAVORITES
+# define VK_BROWSER_FAVORITES (unsigned short)-1
+#endif
+#ifndef VK_BROWSER_HOME
+# define VK_BROWSER_HOME (unsigned short)-1
+#endif
+#ifndef VK_VOLUME_MUTE
+# define VK_VOLUME_MUTE (unsigned short)-1
+#endif
+#ifndef VK_VOLUME_DOWN
+# define VK_VOLUME_DOWN (unsigned short)-1
+#endif
+#ifndef VK_VOLUME_UP
+# define VK_VOLUME_UP (unsigned short)-1
+#endif
+#ifndef VK_MEDIA_NEXT_TRACK
+# define VK_MEDIA_NEXT_TRACK (unsigned short)-1
+#endif
+#ifndef VK_MEDIA_PREV_TRACK
+# define VK_MEDIA_PREV_TRACK (unsigned short)-1
+#endif
+#ifndef VK_MEDIA_STOP
+# define VK_MEDIA_STOP (unsigned short)-1
+#endif
+#ifndef VK_MEDIA_PLAY_PAUSE
+# define VK_MEDIA_PLAY_PAUSE (unsigned short)-1
+#endif
+#ifndef VK_LAUNCH_MAIL
+# define VK_LAUNCH_MAIL (unsigned short)-1
+#endif
+#ifndef VK_LAUNCH_MEDIA_SELECT
+# define VK_LAUNCH_MEDIA_SELECT (unsigned short)-1
+#endif
+#ifndef VK_LAUNCH_APP1
+# define VK_LAUNCH_APP1 (unsigned short)-1
+#endif
+#ifndef VK_LAUNCH_APP2
+# define VK_LAUNCH_APP2 (unsigned short)-1
+#endif
+#ifndef VK_OEM_1
+# define VK_OEM_1 (unsigned short)-1
+#endif
+#ifndef VK_OEM_PLUS
+# define VK_OEM_PLUS (unsigned short)-1
+#endif
+#ifndef VK_OEM_COMMA
+# define VK_OEM_COMMA (unsigned short)-1
+#endif
+#ifndef VK_OEM_MINUS
+# define VK_OEM_MINUS (unsigned short)-1
+#endif
+#ifndef VK_OEM_PERIOD
+# define VK_OEM_PERIOD (unsigned short)-1
+#endif
+#ifndef VK_OEM_2
+# define VK_OEM_2 (unsigned short)-1
+#endif
+#ifndef VK_OEM_3
+# define VK_OEM_3 (unsigned short)-1
+#endif
+#ifndef VK_OEM_4
+# define VK_OEM_4 (unsigned short)-1
+#endif
+#ifndef VK_OEM_5
+# define VK_OEM_5 (unsigned short)-1
+#endif
+#ifndef VK_OEM_6
+# define VK_OEM_6 (unsigned short)-1
+#endif
+#ifndef VK_OEM_7
+# define VK_OEM_7 (unsigned short)-1
+#endif
+#ifndef VK_OEM_8
+# define VK_OEM_8 (unsigned short)-1
+#endif
+#ifndef VK_OEM_AX
+# define VK_OEM_AX (unsigned short)-1
+#endif
+#ifndef VK_OEM_102
+# define VK_OEM_102 (unsigned short)-1
+#endif
+#ifndef VK_ICO_HELP
+# define VK_ICO_HELP (unsigned short)-1
+#endif
+#ifndef VK_ICO_00
+# define VK_ICO_00 (unsigned short)-1
+#endif
+#ifndef VK_PROCESSKEY
+# define VK_PROCESSKEY (unsigned short)-1
+#endif
+#ifndef VK_ICO_CLEAR
+# define VK_ICO_CLEAR (unsigned short)-1
+#endif
+#ifndef VK_PACKET
+# define VK_PACKET (unsigned short)-1
+#endif
+#ifndef VK_OEM_RESET
+# define VK_OEM_RESET (unsigned short)-1
+#endif
+#ifndef VK_OEM_JUMP
+# define VK_OEM_JUMP (unsigned short)-1
+#endif
+#ifndef VK_OEM_PA1
+# define VK_OEM_PA1 (unsigned short)-1
+#endif
+#ifndef VK_OEM_PA2
+# define VK_OEM_PA2 (unsigned short)-1
+#endif
+#ifndef VK_OEM_PA3
+# define VK_OEM_PA3 (unsigned short)-1
+#endif
+#ifndef VK_OEM_WSCTRL
+# define VK_OEM_WSCTRL (unsigned short)-1
+#endif
+#ifndef VK_OEM_CUSEL
+# define VK_OEM_CUSEL (unsigned short)-1
+#endif
+#ifndef VK_OEM_ATTN
+# define VK_OEM_ATTN (unsigned short)-1
+#endif
+#ifndef VK_OEM_FINISH
+# define VK_OEM_FINISH (unsigned short)-1
+#endif
+#ifndef VK_OEM_COPY
+# define VK_OEM_COPY (unsigned short)-1
+#endif
+#ifndef VK_OEM_AUTO
+# define VK_OEM_AUTO (unsigned short)-1
+#endif
+#ifndef VK_OEM_ENLW
+# define VK_OEM_ENLW (unsigned short)-1
+#endif
+#ifndef VK_OEM_BACKTAB
+# define VK_OEM_BACKTAB (unsigned short)-1
+#endif
+#ifndef VK_ATTN
+# define VK_ATTN (unsigned short)-1
+#endif
+#ifndef VK_CRSEL
+# define VK_CRSEL (unsigned short)-1
+#endif
+#ifndef VK_EXSEL
+# define VK_EXSEL (unsigned short)-1
+#endif
+#ifndef VK_EREOF
+# define VK_EREOF (unsigned short)-1
+#endif
+#ifndef VK_PLAY
+# define VK_PLAY (unsigned short)-1
+#endif
+#ifndef VK_ZOOM
+# define VK_ZOOM (unsigned short)-1
+#endif
+#ifndef VK_NONAME
+# define VK_NONAME (unsigned short)-1
+#endif
+#ifndef VK_PA1
+# define VK_PA1 (unsigned short)-1
+#endif
+#ifndef VK_OEM_CLEAR
+# define VK_OEM_CLEAR (unsigned short)-1
+#endif

Property changes on: ext/io/console/win32_vk.h
___________________________________________________________________
Added: svn:eol-style
   + LF


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]