exerb 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/ChangeLog.ja.rd +305 -0
  4. data/README.en.txt +12 -0
  5. data/README.ja.html +143 -0
  6. data/README.ja.txt +6 -0
  7. data/README.md +50 -0
  8. data/Rakefile +205 -0
  9. data/bin/exerb +185 -0
  10. data/bin/mkexy +47 -0
  11. data/doc/LGPL +513 -0
  12. data/doc/class.ja.html +92 -0
  13. data/doc/command.ja.html +109 -0
  14. data/doc/core.ja.html +72 -0
  15. data/doc/example.ja.html +89 -0
  16. data/doc/faq.ja.html +59 -0
  17. data/doc/inside.ja.rd +404 -0
  18. data/doc/license.ja.html +62 -0
  19. data/doc/logo.gif +0 -0
  20. data/doc/misc.ja.html +72 -0
  21. data/doc/navi.gif +0 -0
  22. data/doc/recipe.ja.html +317 -0
  23. data/doc/style.css +187 -0
  24. data/doc/tutorial.ja.html +182 -0
  25. data/example/Makefile +54 -0
  26. data/example/cat_n.rb +14 -0
  27. data/example/exception.rb +9 -0
  28. data/example/ext/Win32API.so +0 -0
  29. data/example/ext/swin.so +0 -0
  30. data/example/msgbox.rb +14 -0
  31. data/example/rubytk.rb +22 -0
  32. data/example/runtime.ico +0 -0
  33. data/example/runtime.rb +19 -0
  34. data/example/vr/clipboard.rb +106 -0
  35. data/example/vr/compat/rubycompat.rb +18 -0
  36. data/example/vr/compat/vrcomctl.rb +12 -0
  37. data/example/vr/compat/vrcontrol.rb +50 -0
  38. data/example/vr/compat/vrmmedia.rb +24 -0
  39. data/example/vr/contrib/inifile.rb +116 -0
  40. data/example/vr/contrib/msgboxconst.rb +55 -0
  41. data/example/vr/contrib/toolbar.rb +371 -0
  42. data/example/vr/contrib/vrctlcolor.rb +110 -0
  43. data/example/vr/contrib/vrhotkey.rb +35 -0
  44. data/example/vr/contrib/vrlistviewex.rb +71 -0
  45. data/example/vr/contrib/vrstdscrollbar.rb +414 -0
  46. data/example/vr/contrib/vrwincomponent.rb +54 -0
  47. data/example/vr/dragdropformat.rb +209 -0
  48. data/example/vr/rscutil.rb +168 -0
  49. data/example/vr/sysmod.rb +249 -0
  50. data/example/vr/vractivex.rb +56 -0
  51. data/example/vr/vrclipboard.rb +53 -0
  52. data/example/vr/vrcomctl.rb +1819 -0
  53. data/example/vr/vrcontrol.rb +1374 -0
  54. data/example/vr/vrdde.rb +623 -0
  55. data/example/vr/vrddrop.rb +190 -0
  56. data/example/vr/vrdialog.rb +406 -0
  57. data/example/vr/vrhandler.rb +195 -0
  58. data/example/vr/vrlayout.old.rb +209 -0
  59. data/example/vr/vrlayout.rb +173 -0
  60. data/example/vr/vrlayout2.rb +340 -0
  61. data/example/vr/vrmargin.rb +141 -0
  62. data/example/vr/vrmgdlayout.rb +381 -0
  63. data/example/vr/vrmmedia.rb +287 -0
  64. data/example/vr/vrolednd.rb +192 -0
  65. data/example/vr/vrowndraw.rb +108 -0
  66. data/example/vr/vrrichedit.rb +366 -0
  67. data/example/vr/vrtimer.rb +148 -0
  68. data/example/vr/vrtooltip.rb +273 -0
  69. data/example/vr/vrtray.rb +143 -0
  70. data/example/vr/vrtvitem.rb +118 -0
  71. data/example/vr/vrtwopane.rb +223 -0
  72. data/example/vr/vruby.rb +1051 -0
  73. data/example/vr/winconst.rb +158 -0
  74. data/example/vruby.rb +38 -0
  75. data/exerb.gemspec +26 -0
  76. data/extconf.rb +7 -0
  77. data/lib/exerb/archive.rb +143 -0
  78. data/lib/exerb/config.rb +51 -0
  79. data/lib/exerb/error.rb +15 -0
  80. data/lib/exerb/executable.rb +68 -0
  81. data/lib/exerb/file_table.rb +189 -0
  82. data/lib/exerb/mkexy.rb +81 -0
  83. data/lib/exerb/name_table.rb +120 -0
  84. data/lib/exerb/recipe.rb +465 -0
  85. data/lib/exerb/resource.rb +190 -0
  86. data/lib/exerb/resource/base.rb +29 -0
  87. data/lib/exerb/resource/binary.rb +31 -0
  88. data/lib/exerb/resource/dialog.rb +30 -0
  89. data/lib/exerb/resource/group_icon.rb +85 -0
  90. data/lib/exerb/resource/icon.rb +52 -0
  91. data/lib/exerb/resource/version_info.rb +155 -0
  92. data/lib/exerb/resource_library.rb +120 -0
  93. data/lib/exerb/utility.rb +95 -0
  94. data/lib/exerb/utility2.rb +122 -0
  95. data/lib/exerb/version.rb +13 -0
  96. data/lib/exerb/win32/const/resource.rb +51 -0
  97. data/lib/exerb/win32/icon_file.rb +78 -0
  98. data/lib/exerb/win32/pe_file.rb +59 -0
  99. data/lib/exerb/win32/resource_directory.rb +105 -0
  100. data/lib/exerb/win32/resource_directory_root.rb +67 -0
  101. data/lib/exerb/win32/resource_entry.rb +98 -0
  102. data/lib/exerb/win32/struct/base.rb +43 -0
  103. data/lib/exerb/win32/struct/icon_dir_entry.rb +83 -0
  104. data/lib/exerb/win32/struct/icon_header.rb +43 -0
  105. data/lib/exerb/win32/struct/icon_res_entry.rb +48 -0
  106. data/lib/exerb/win32/struct/image_dos_header.rb +73 -0
  107. data/lib/exerb/win32/struct/image_file_header.rb +47 -0
  108. data/lib/exerb/win32/struct/image_nt_headers32.rb +53 -0
  109. data/lib/exerb/win32/struct/image_optional_header32.rb +107 -0
  110. data/lib/exerb/win32/struct/image_resource_data_entry.rb +45 -0
  111. data/lib/exerb/win32/struct/image_resource_directory.rb +47 -0
  112. data/lib/exerb/win32/struct/image_resource_directory_entry.rb +72 -0
  113. data/lib/exerb/win32/struct/image_section_header.rb +53 -0
  114. data/lib/exerb/win32/struct/version_info_block.rb +75 -0
  115. data/lib/exerb/win32/struct/vs_fixed_file_info.rb +62 -0
  116. data/src/exerb/cui.c +48 -0
  117. data/src/exerb/default.rb +1 -0
  118. data/src/exerb/exerb.c +877 -0
  119. data/src/exerb/exerb.h +92 -0
  120. data/src/exerb/gui.c +176 -0
  121. data/src/exerb/module.c +138 -0
  122. data/src/exerb/module.h +7 -0
  123. data/src/exerb/patch.c +27 -0
  124. data/src/exerb/resource.h +22 -0
  125. data/src/exerb/resource.rc +121 -0
  126. data/src/exerb/ruby.ico +0 -0
  127. data/src/exerb/utility.c +263 -0
  128. data/src/exerb/utility.h +33 -0
  129. data/test/alltests.rb +16 -0
  130. data/test/test-argv.rb +26 -0
  131. data/test/test-argv/test-argv.rb +9 -0
  132. data/test/test-argv/test-argv.ret +1 -0
  133. data/test/test-dollarzero.rb +26 -0
  134. data/test/test-dollarzero/test-dollarzero.rb +10 -0
  135. data/test/test-dollarzero/test-dollarzero.ret +2 -0
  136. data/test/test-dot.rb +26 -0
  137. data/test/test-dot/dot.dot.dot.rb +9 -0
  138. data/test/test-dot/dot.dot.rb +9 -0
  139. data/test/test-dot/test-dot.rb +13 -0
  140. data/test/test-dot/test-dot.ret +5 -0
  141. data/test/test-exitcode.rb +28 -0
  142. data/test/test-exitcode/test-exitcode.rb +9 -0
  143. data/test/test-kcode.rb +43 -0
  144. data/test/test-kcode/euc.rb +10 -0
  145. data/test/test-kcode/euc.ret +2 -0
  146. data/test/test-kcode/none.rb +10 -0
  147. data/test/test-kcode/none.ret +2 -0
  148. data/test/test-kcode/sjis.rb +10 -0
  149. data/test/test-kcode/sjis.ret +2 -0
  150. data/test/test-kcode/utf8.rb +10 -0
  151. data/test/test-kcode/utf8.ret +2 -0
  152. data/test/test-loadpath.rb +24 -0
  153. data/test/test-loadpath/test-loadpath.rb +9 -0
  154. data/test/test-nest.rb +18 -0
  155. data/test/test-nest/foo.rb +1 -0
  156. data/test/test-nest/foo/bar.rb +2 -0
  157. data/test/test-nest/foo/foo.rb +1 -0
  158. data/test/test-nest/test-nest.rb +1 -0
  159. data/test/test-nest/test-nest.ret +1 -0
  160. data/test/test-preload.rb +24 -0
  161. data/test/test-preload/test-preload.rb +9 -0
  162. data/test/test-regexp.rb +26 -0
  163. data/test/test-regexp/test-regexp.rb +23 -0
  164. data/test/test-regexp/test-regexp.ret +13 -0
  165. data/test/test-require1.rb +26 -0
  166. data/test/test-require1/require1.rb +9 -0
  167. data/test/test-require1/require2.rb +9 -0
  168. data/test/test-require1/require3.rb +9 -0
  169. data/test/test-require1/require4.rb +9 -0
  170. data/test/test-require1/require5.rb +9 -0
  171. data/test/test-require1/require6.rb +9 -0
  172. data/test/test-require1/test-require1.rb +41 -0
  173. data/test/test-require1/test-require1.ret +27 -0
  174. data/test/test-socket.rb +26 -0
  175. data/test/test-socket/test-socket.rb +7 -0
  176. data/test/test-socket/test-socket.ret +1 -0
  177. data/test/testcase.rb +66 -0
  178. data/vendor/mkexports.rb +167 -0
  179. metadata +352 -0
@@ -0,0 +1,92 @@
1
+ // $Id: exerb.h,v 1.42 2007/02/26 10:20:44 yuya Exp $
2
+ #ifndef EXERB_H
3
+ #define EXERB_H 1
4
+
5
+ #include <windows.h>
6
+
7
+ #pragma pack(push, 1)
8
+
9
+ typedef struct {
10
+ DWORD signature1;
11
+ DWORD signature2;
12
+ union {
13
+ DWORD options;
14
+ struct {
15
+ DWORD kcode:2;
16
+ DWORD reserved:30;
17
+ };
18
+ };
19
+ DWORD offset_of_name_table;
20
+ DWORD offset_of_file_table;
21
+ } ARCHIVE_HEADER;
22
+
23
+ typedef struct {
24
+ DWORD signature;
25
+ WORD number_of_headers;
26
+ DWORD offset_of_headers;
27
+ DWORD offset_of_pool;
28
+ } NAME_TABLE_HEADER;
29
+
30
+ typedef struct {
31
+ WORD id;
32
+ DWORD offset_of_name;
33
+ } NAME_ENTRY_HEADER;
34
+
35
+ typedef struct {
36
+ DWORD signature;
37
+ WORD number_of_headers;
38
+ DWORD offset_of_headers;
39
+ DWORD offset_of_pool;
40
+ } FILE_TABLE_HEADER;
41
+
42
+ typedef struct {
43
+ WORD id;
44
+ DWORD offset_of_file;
45
+ DWORD size_of_file;
46
+ union {
47
+ BYTE flag_of_file;
48
+ struct {
49
+ BYTE type_of_file:3;
50
+ BYTE flag_no_replace_function:1;
51
+ BYTE flag_reserved:4;
52
+ };
53
+ };
54
+ BYTE zipd;
55
+ } FILE_ENTRY_HEADER;
56
+
57
+ #pragma pack(pop)
58
+
59
+ //typedef VALUE (*RUBY_PROC)(...);
60
+
61
+ #define ARCHIVE_HEADER_SIGNATURE1 0x52455845
62
+ #define ARCHIVE_HEADER_SIGNATURE2 0x04000042
63
+ #define ARCHIVE_HEADER_OPTIONS_KCODE_NONE 0
64
+ #define ARCHIVE_HEADER_OPTIONS_KCODE_EUC 1
65
+ #define ARCHIVE_HEADER_OPTIONS_KCODE_SJIS 2
66
+ #define ARCHIVE_HEADER_OPTIONS_KCODE_UTF8 3
67
+
68
+ #define NAME_TABLE_HEADER_SIGNATURE 0x0100544E
69
+ #define FILE_TABLE_HEADER_SIGNATURE 0x04005446
70
+
71
+ #define FILE_ENTRY_HEADER_TYPE_RUBY_SCRIPT 1
72
+ #define FILE_ENTRY_HEADER_TYPE_EXTENSION_LIBRARY 2
73
+ #define FILE_ENTRY_HEADER_TYPE_DYNAMIC_LIBRARY 3
74
+ #define FILE_ENTRY_HEADER_TYPE_RESOURCE_LIBRARY 4
75
+ #define FILE_ENTRY_HEADER_TYPE_DATA_BINARY 5
76
+ #define FILE_ENTRY_HEADER_TYPE_COMPILED_SCRIPT 6
77
+
78
+ #ifndef RSTRING_PTR
79
+ #define RSTRING_PTR(value) RSTRING(value)->ptr
80
+ #endif
81
+
82
+ #ifndef RSTRING_LEN
83
+ #define RSTRING_LEN(value) RSTRING(value)->len
84
+ #endif
85
+
86
+ VALUE exerb_rb_f_require(VALUE obj, VALUE fname);
87
+ VALUE exerb_require(VALUE fname);
88
+ #ifdef RUBY19
89
+ VALUE exerb_require_safe(VALUE fname, int safe);
90
+ #endif
91
+
92
+ #endif /* EXERB_H */
@@ -0,0 +1,176 @@
1
+ // $Id: gui.cpp,v 1.15 2008/12/19 12:17:50 arton Exp $
2
+
3
+ #include <ruby.h>
4
+ #include <windowsx.h>
5
+ #include "exerb.h"
6
+ #include "resource.h"
7
+
8
+ ////////////////////////////////////////////////////////////////////////////////
9
+
10
+ int exerb_main(int argc, char** argv, void (*on_init)(VALUE, VALUE, VALUE), void (*on_fail)(VALUE)); // exerb.cpp
11
+
12
+ int WINAPI WinMain(HINSTANCE current_instance, HINSTANCE prev_instance, LPSTR cmd_line, int show_cmd);
13
+ static void on_init(VALUE io_stdin, VALUE io_stdout, VALUE io_stderr);
14
+ static void on_fail(VALUE errinfo);
15
+
16
+ static void exerb_replace_io_methods(const VALUE io);
17
+ static VALUE rb_exerbio_write(VALUE self, VALUE str);
18
+ static VALUE rb_exerbio_return_nil(int argc, VALUE *argv, VALUE self);
19
+
20
+ static LRESULT CALLBACK dialog_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
21
+
22
+ ////////////////////////////////////////////////////////////////////////////////
23
+
24
+ int WINAPI
25
+ WinMain(HINSTANCE current_instance, HINSTANCE prev_instance, LPSTR cmd_line, int show_cmd)
26
+ {
27
+ #ifdef _DEBUG
28
+ __asm { int 3 }
29
+ #endif
30
+ return exerb_main(0, NULL, on_init, on_fail);
31
+ }
32
+
33
+ static void
34
+ on_init(VALUE io_stdin, VALUE io_stdout, VALUE io_stderr)
35
+ {
36
+ exerb_replace_io_methods(io_stdin);
37
+ exerb_replace_io_methods(io_stdout);
38
+ exerb_replace_io_methods(io_stderr);
39
+
40
+ rb_define_global_function("gets", rb_exerbio_return_nil, -1);
41
+ rb_define_global_function("readline", rb_exerbio_return_nil, -1);
42
+ rb_define_global_function("getc", rb_exerbio_return_nil, -1);
43
+ rb_define_global_function("readlines", rb_exerbio_return_nil, -1);
44
+ }
45
+
46
+ static void
47
+ on_fail(VALUE errinfo)
48
+ {
49
+ DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_EXCEPTION), NULL, (DLGPROC)dialog_proc, (LPARAM)errinfo);
50
+ }
51
+
52
+ ////////////////////////////////////////////////////////////////////////////////
53
+
54
+ static void
55
+ exerb_replace_io_methods(const VALUE io)
56
+ {
57
+ rb_define_singleton_method(io, "reopen", rb_exerbio_return_nil, -1);
58
+ rb_define_singleton_method(io, "each", rb_exerbio_return_nil, -1);
59
+ rb_define_singleton_method(io, "each_line", rb_exerbio_return_nil, -1);
60
+ rb_define_singleton_method(io, "each_byte", rb_exerbio_return_nil, -1);
61
+ rb_define_singleton_method(io, "syswrite", rb_exerbio_return_nil, -1);
62
+ rb_define_singleton_method(io, "sysread", rb_exerbio_return_nil, -1);
63
+ rb_define_singleton_method(io, "fileno", rb_exerbio_return_nil, -1);
64
+ rb_define_singleton_method(io, "to_i", rb_exerbio_return_nil, -1);
65
+ rb_define_singleton_method(io, "to_io", rb_exerbio_return_nil, -1);
66
+ rb_define_singleton_method(io, "fsync", rb_exerbio_return_nil, -1);
67
+ rb_define_singleton_method(io, "sync", rb_exerbio_return_nil, -1);
68
+ rb_define_singleton_method(io, "sync=", rb_exerbio_return_nil, -1);
69
+ rb_define_singleton_method(io, "lineno", rb_exerbio_return_nil, -1);
70
+ rb_define_singleton_method(io, "lineno=", rb_exerbio_return_nil, -1);
71
+ rb_define_singleton_method(io, "readlines", rb_exerbio_return_nil, -1);
72
+ rb_define_singleton_method(io, "read", rb_exerbio_return_nil, -1);
73
+ rb_define_singleton_method(io, "write", rb_exerbio_write, 1);
74
+ rb_define_singleton_method(io, "gets", rb_exerbio_return_nil, -1);
75
+ rb_define_singleton_method(io, "readline", rb_exerbio_return_nil, -1);
76
+ rb_define_singleton_method(io, "getc", rb_exerbio_return_nil, -1);
77
+ rb_define_singleton_method(io, "readchar", rb_exerbio_return_nil, -1);
78
+ rb_define_singleton_method(io, "ungetc", rb_exerbio_return_nil, -1);
79
+ rb_define_singleton_method(io, "flush", rb_exerbio_return_nil, -1);
80
+ rb_define_singleton_method(io, "tell", rb_exerbio_return_nil, -1);
81
+ rb_define_singleton_method(io, "seek", rb_exerbio_return_nil, -1);
82
+ rb_define_singleton_method(io, "rewind", rb_exerbio_return_nil, -1);
83
+ rb_define_singleton_method(io, "pos", rb_exerbio_return_nil, -1);
84
+ rb_define_singleton_method(io, "pos=", rb_exerbio_return_nil, -1);
85
+ rb_define_singleton_method(io, "eof", rb_exerbio_return_nil, -1);
86
+ rb_define_singleton_method(io, "eof?", rb_exerbio_return_nil, -1);
87
+ rb_define_singleton_method(io, "close", rb_exerbio_return_nil, -1);
88
+ rb_define_singleton_method(io, "closed?", rb_exerbio_return_nil, -1);
89
+ rb_define_singleton_method(io, "close_read", rb_exerbio_return_nil, -1);
90
+ rb_define_singleton_method(io, "close_write", rb_exerbio_return_nil, -1);
91
+ rb_define_singleton_method(io, "isatty", rb_exerbio_return_nil, -1);
92
+ rb_define_singleton_method(io, "tty?", rb_exerbio_return_nil, -1);
93
+ rb_define_singleton_method(io, "binmode", rb_exerbio_return_nil, -1);
94
+ rb_define_singleton_method(io, "sysseek", rb_exerbio_return_nil, -1);
95
+ rb_define_singleton_method(io, "ioctl", rb_exerbio_return_nil, -1);
96
+ rb_define_singleton_method(io, "fcntl", rb_exerbio_return_nil, -1);
97
+ rb_define_singleton_method(io, "pid", rb_exerbio_return_nil, -1);
98
+ }
99
+
100
+ static VALUE
101
+ rb_exerbio_write(VALUE self, VALUE str)
102
+ {
103
+ rb_secure(1);
104
+ if ( TYPE(str) != T_STRING ) str = rb_obj_as_string(str);
105
+ if ( RSTRING_LEN(str) > 0 ) OutputDebugString(RSTRING_PTR(str));
106
+ return Qnil;
107
+ }
108
+
109
+ static VALUE
110
+ rb_exerbio_return_nil(int argc, VALUE *argv, VALUE self)
111
+ {
112
+ return Qnil;
113
+ }
114
+
115
+ ////////////////////////////////////////////////////////////////////////////////
116
+
117
+ static LRESULT CALLBACK
118
+ dialog_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
119
+ {
120
+ static HFONT font = NULL;
121
+
122
+ switch ( message ) {
123
+ case WM_INITDIALOG:
124
+ if ( lparam ) {
125
+ const VALUE errinfo = (VALUE)lparam;
126
+ const VALUE message = rb_funcall(errinfo, rb_intern("message"), 0);
127
+ const VALUE message_str = rb_funcall(message, rb_intern("gsub"), 2, rb_str_new2("\n"), rb_str_new2("\r\n"));
128
+ const VALUE backtrace = rb_funcall(errinfo, rb_intern("backtrace"), 0);
129
+ const VALUE backtrace_str = rb_str_concat(rb_ary_join(backtrace, rb_str_new2("\r\n")), rb_str_new2("\r\n"));
130
+
131
+ SetDlgItemText(hwnd, IDC_EDIT_TYPE, rb_obj_classname(errinfo));
132
+ #ifdef RUBY19
133
+ SetDlgItemText(hwnd, IDC_EDIT_MESSAGE, rb_string_value_ptr((volatile VALUE*) &message_str));
134
+ SetDlgItemText(hwnd, IDC_EDIT_BACKTRACE, rb_string_value_ptr((volatile VALUE*) &backtrace_str));
135
+ #else
136
+ SetDlgItemText(hwnd, IDC_EDIT_MESSAGE, STR2CSTR(message_str));
137
+ SetDlgItemText(hwnd, IDC_EDIT_BACKTRACE, STR2CSTR(backtrace_str));
138
+ #endif
139
+ }
140
+
141
+ {
142
+ char self_filename[MAX_PATH] = "";
143
+ char window_title_format[MAX_PATH] = "";
144
+ char window_title[MAX_PATH] = "";
145
+ GetModuleFileName(NULL, self_filename, sizeof(self_filename));
146
+ GetWindowText(hwnd, window_title_format, sizeof(window_title_format));
147
+ wsprintf(window_title, window_title_format, self_filename);
148
+ SetWindowText(hwnd, window_title);
149
+ }
150
+
151
+ font = CreateFont(14, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FIXED_PITCH | FF_MODERN, "Terminal");
152
+ SetWindowFont(GetDlgItem(hwnd, IDC_EDIT_TYPE), font, FALSE);
153
+ SetWindowFont(GetDlgItem(hwnd, IDC_EDIT_MESSAGE), font, FALSE);
154
+ SetWindowFont(GetDlgItem(hwnd, IDC_EDIT_BACKTRACE), font, FALSE);
155
+
156
+ MessageBeep(MB_ICONHAND);
157
+
158
+ return TRUE;
159
+ case WM_DESTROY:
160
+ DeleteObject(font);
161
+ return TRUE;
162
+ case WM_CLOSE:
163
+ EndDialog(hwnd, ID_CLOSE);
164
+ return TRUE;
165
+ case WM_COMMAND:
166
+ if ( LOWORD(wparam) == ID_CLOSE ) {
167
+ EndDialog(hwnd, ID_CLOSE);
168
+ return TRUE;
169
+ }
170
+ break;
171
+ }
172
+
173
+ return FALSE;
174
+ }
175
+
176
+ ////////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,138 @@
1
+ // $Id: module.cpp,v 1.11 2007/02/25 16:44:51 yuya Exp $
2
+
3
+ #include <ruby.h>
4
+ #include "exerb.h"
5
+ #include "module.h"
6
+ #include "utility.h"
7
+
8
+ ////////////////////////////////////////////////////////////////////////////////
9
+
10
+ extern VALUE rb_mExerbRuntime;
11
+ extern VALUE rb_eExerbRuntimeError;
12
+
13
+ extern FILE_TABLE_HEADER *g_file_table_header;
14
+
15
+ extern int g_loaded_resource_count;
16
+ extern HMODULE g_loaded_resource_table[];
17
+
18
+ ////////////////////////////////////////////////////////////////////////////////
19
+
20
+ static VALUE rb_exerbruntime_s_filepath(VALUE self);
21
+ static VALUE rb_exerbruntime_s_filename(VALUE self);
22
+ static VALUE rb_exerbruntime_s_open(VALUE self, VALUE filename);
23
+ static VALUE rb_exerbruntime_s_load_string(VALUE self, VALUE id);
24
+ static VALUE rb_exerbruntime_s_load_icon(VALUE self, VALUE id);
25
+ static VALUE rb_exerbruntime_s_load_cursor(VALUE self, VALUE id);
26
+ static LPCTSTR exerb_convert_resource_id(VALUE value);
27
+
28
+ ////////////////////////////////////////////////////////////////////////////////
29
+
30
+ void
31
+ Init_ExerbRuntime()
32
+ {
33
+ static VALUE gv_exerb = Qtrue;
34
+ rb_define_readonly_variable("$Exerb", &gv_exerb);
35
+
36
+ rb_mExerbRuntime = rb_define_module("ExerbRuntime");
37
+
38
+ rb_define_singleton_method(rb_mExerbRuntime, "filepath", rb_exerbruntime_s_filepath, 0);
39
+ rb_define_singleton_method(rb_mExerbRuntime, "filename", rb_exerbruntime_s_filename, 0);
40
+ rb_define_singleton_method(rb_mExerbRuntime, "open", rb_exerbruntime_s_open, 1);
41
+ rb_define_singleton_method(rb_mExerbRuntime, "load_string", rb_exerbruntime_s_load_string, 1);
42
+ rb_define_singleton_method(rb_mExerbRuntime, "load_icon", rb_exerbruntime_s_load_icon, 1);
43
+ rb_define_singleton_method(rb_mExerbRuntime, "load_cursor", rb_exerbruntime_s_load_cursor, 1);
44
+
45
+ rb_eExerbRuntimeError = rb_define_class_under(rb_mExerbRuntime, "Error", rb_eException);
46
+ }
47
+
48
+ static VALUE
49
+ rb_exerbruntime_s_filepath(VALUE self)
50
+ {
51
+ char filepath[MAX_PATH] = "";
52
+ exerb_get_self_filepath(filepath, sizeof(filepath));
53
+ return rb_str_new2(filepath);
54
+ }
55
+
56
+ static VALUE
57
+ rb_exerbruntime_s_filename(VALUE self)
58
+ {
59
+ char filepath[MAX_PATH] = "";
60
+ const char *filename = exerb_get_self_filepath(filepath, sizeof(filepath));
61
+ return rb_str_new2(filename);
62
+ }
63
+
64
+ static VALUE
65
+ rb_exerbruntime_s_open(VALUE self, VALUE filename)
66
+ {
67
+ #ifdef RUBY19
68
+ SafeStringValue(filename);
69
+ #else
70
+ Check_SafeStr(filename);
71
+ #endif
72
+ rb_require("stringio");
73
+
74
+ NAME_ENTRY_HEADER *name_entry = exerb_find_name_entry_by_filename(RSTRING_PTR(filename), NULL);
75
+ if ( !name_entry ) rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING_PTR(filename));
76
+
77
+ FILE_ENTRY_HEADER *file_entry = exerb_find_file_entry(name_entry->id);
78
+ VALUE file = exerb_get_file_from_entry2(file_entry);
79
+
80
+ return rb_funcall(rb_path2class("StringIO"), rb_intern("new"), 2, file, rb_str_new2("r"));
81
+ }
82
+
83
+ static VALUE
84
+ rb_exerbruntime_s_load_string(VALUE self, VALUE id)
85
+ {
86
+ LPCSTR res_id = exerb_convert_resource_id(id);
87
+ char buffer[512] = "";
88
+
89
+ for ( int i = 0; i < g_loaded_resource_count; i++ ) {
90
+ if ( LoadString(g_loaded_resource_table[i], (unsigned int)res_id, buffer, sizeof(buffer)) ) {
91
+ return rb_str_new2(buffer);
92
+ }
93
+ }
94
+
95
+ return Qnil;
96
+ }
97
+
98
+ static VALUE
99
+ rb_exerbruntime_s_load_icon(VALUE self, VALUE id)
100
+ {
101
+ LPCSTR res_id = exerb_convert_resource_id(id);
102
+
103
+ for ( int i = 0; i < g_loaded_resource_count; i++ ) {
104
+ HICON icon = LoadIcon(g_loaded_resource_table[i], res_id);
105
+ if ( icon ) return INT2NUM((int)icon);
106
+ }
107
+
108
+ return Qnil;
109
+ }
110
+
111
+ static VALUE
112
+ rb_exerbruntime_s_load_cursor(VALUE self, VALUE id)
113
+ {
114
+ LPCSTR res_id = exerb_convert_resource_id(id);
115
+
116
+ for ( int i = 0; i < g_loaded_resource_count; i++ ) {
117
+ HCURSOR icon = LoadCursor(g_loaded_resource_table[i], res_id);
118
+ if ( icon ) return INT2NUM((int)icon);
119
+ }
120
+
121
+ return Qnil;
122
+ }
123
+
124
+ static LPCTSTR
125
+ exerb_convert_resource_id(VALUE value)
126
+ {
127
+ switch ( TYPE(value) ) {
128
+ case T_FIXNUM:
129
+ return MAKEINTRESOURCE(FIX2INT(value));
130
+ case T_STRING:
131
+ return RSTRING_PTR(value);
132
+ default:
133
+ rb_raise(rb_eArgError, "argument needs to be integer or string");
134
+ return NULL;
135
+ }
136
+ }
137
+
138
+ ////////////////////////////////////////////////////////////////////////////////
@@ -0,0 +1,7 @@
1
+ // $Id: module.h,v 1.4 2005/04/25 16:40:45 yuya Exp $
2
+ #ifndef MODULE_H
3
+ #define MODULE_H 1
4
+
5
+ void Init_ExerbRuntime();
6
+
7
+ #endif /* MODULE_H */
@@ -0,0 +1,27 @@
1
+ #include <stdio.h>
2
+
3
+ #include "ruby.h"
4
+ #include "exerb.h"
5
+
6
+ VALUE __real_rb_require(const char *);
7
+ #ifdef RUBY19
8
+ VALUE __real_rb_require_safe(VALUE, int);
9
+ #endif
10
+
11
+ VALUE
12
+ __wrap_rb_require(const char *fname)
13
+ {
14
+ VALUE fn = rb_str_new2(fname);
15
+ OBJ_FREEZE(fn);
16
+ return exerb_require(fn);
17
+ }
18
+
19
+ #ifdef RUBY19
20
+
21
+ VALUE
22
+ __wrap_rb_require_safe(VALUE fname, int safe)
23
+ {
24
+ return exerb_require(fname);
25
+ }
26
+
27
+ #endif
@@ -0,0 +1,22 @@
1
+ // $Id: resource.h,v 1.14 2010/12/26 00:03:43 arton Exp $
2
+ #ifndef RESOURCE_H
3
+ #define RESOURCE_H 1
4
+
5
+ #define RT_EXERB 100
6
+ #define ID_EXERB 1
7
+ #define IDD_EXCEPTION 101
8
+ #define IDI_RUBY 102
9
+
10
+ #define ID_CLOSE 1000
11
+ #define IDC_EDIT_MESSAGE 1001
12
+ #define IDC_EDIT_BACKTRACE 1002
13
+ #define IDC_EDIT_TYPE 1003
14
+
15
+ #ifndef IDC_STATIC
16
+ #define IDC_STATIC -1
17
+ #endif
18
+
19
+ #define EXERB_RES_EXERB_VERSION1 6,0,1,0
20
+ #define EXERB_RES_EXERB_VERSION2 "6.0.1"
21
+
22
+ #endif /* RESOURCE_H */