• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-cqtcocoa誰得pythonphprubygameguibathyscaphec翻訳計画中(planning stage)omegatframeworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Graphics library for Mercury, including OpenGL bindings, TGA image reading, and X11, Win32, and SDL2 windowing and input.


コミットメタ情報

リビジョン1afe83fba3c159276d8642340f13928a38535903 (tree)
日時2022-04-11 00:22:25
作者AlaskanEmily <emily@alas...>
コミッターAlaskanEmily

ログメッセージ

Make the saffron_window native exports for window_event not use maybes.

変更サマリ

差分

--- a/util/glow/saffron_glow.m
+++ b/util/glow/saffron_glow.m
@@ -282,11 +282,11 @@ create_window_error = io.error(io.make_io_error("Could not create Glow window"))
282282 if(Glow_GetEvent(Win, &event)){
283283 switch(event.type){
284284 case eGlowQuit:
285- Event = Saffron_CreateQuitEvent();
285+ Event = Saffron_CreateYesEvent(Saffron_CreateQuitEvent());
286286 break;
287287 case eGlowKeyboardPressed:
288288 if(SaffronGlow_StringIsSpecialKey(event.value.key, &tmp)){
289- Event = Saffron_CreateSpecialKeyPressEvent(tmp);
289+ Event = Saffron_CreateYesEvent(Saffron_CreateSpecialKeyPressEvent(tmp));
290290 }
291291 else{
292292 int width;
@@ -297,13 +297,13 @@ create_window_error = io.error(io.make_io_error("Could not create Glow window"))
297297 Event = Saffron_CreateNoEvent();
298298 }
299299 else{
300- Event = Saffron_CreateKeyPressEvent(c);
300+ Event = Saffron_CreateYesEvent(Saffron_CreateKeyPressEvent(c));
301301 }
302302 }
303303 break;
304304 case eGlowKeyboardReleased:
305305 if(SaffronGlow_StringIsSpecialKey(event.value.key, &tmp)){
306- Event = Saffron_CreateSpecialKeyReleaseEvent(tmp);
306+ Event = Saffron_CreateYesEvent(Saffron_CreateSpecialKeyReleaseEvent(tmp));
307307 }
308308 else{
309309 int width;
@@ -311,36 +311,36 @@ create_window_error = io.error(io.make_io_error("Could not create Glow window"))
311311 if(width <= 0){
312312 /* TODO: We should fetch another event. */
313313 REPORT_INVALID_KEY(event.value.key);
314- Event = Saffron_CreateNoEvent();
314+ Event = Saffron_CreateYesEvent(Saffron_CreateNoEvent());
315315 }
316316 else{
317- Event = Saffron_CreateKeyReleaseEvent(c);
317+ Event = Saffron_CreateYesEvent(Saffron_CreateKeyReleaseEvent(c));
318318 }
319319 }
320320 break;
321321 case eGlowMousePressed:
322322 SaffronGlow_ConvertButton(&tmp, event.value.mouse.button);
323- Event = Saffron_CreateMousePressEvent(
323+ Event = Saffron_CreateYesEvent(Saffron_CreateMousePressEvent(
324324 tmp,
325325 event.value.mouse.xy[0],
326- event.value.mouse.xy[1]);
326+ event.value.mouse.xy[1]));
327327 break;
328328 case eGlowMouseReleased:
329329 SaffronGlow_ConvertButton(&tmp, event.value.mouse.button);
330- Event = Saffron_CreateMouseReleaseEvent(
330+ Event = Saffron_CreateYesEvent(Saffron_CreateMouseReleaseEvent(
331331 tmp,
332332 event.value.mouse.xy[0],
333- event.value.mouse.xy[1]);
333+ event.value.mouse.xy[1]));
334334 break;
335335 case eGlowMouseMoved:
336- Event = Saffron_CreateMotionEvent(
336+ Event = Saffron_CreateYesEvent(Saffron_CreateMotionEvent(
337337 event.value.mouse.xy[0],
338- event.value.mouse.xy[1]);
338+ event.value.mouse.xy[1]));
339339 break;
340340 case eGlowResized:
341- Event = Saffron_CreateResizeEvent(
341+ Event = Saffron_CreateYesEvent(Saffron_CreateResizeEvent(
342342 event.value.resize[0],
343- event.value.resize[1]);
343+ event.value.resize[1]));
344344 break;
345345 default:
346346 MR_assert(0);
--- a/util/window/saffron_window.m
+++ b/util/window/saffron_window.m
@@ -113,6 +113,31 @@
113113 :- implementation.
114114 %==============================================================================%
115115
116+:- pragma foreign_code("Java",
117+ "
118+static public Window_event_0 CreateMouseEvent(Button_0 button, int x, int y, boolean press){
119+ if(press)
120+ return CreateMousePressEvent(button, x, y);
121+ else
122+ return CreateMouseReleaseEvent(button, x, y);
123+}
124+static public Window_event_0 CreateKeyEvent(int key, boolean press){
125+ if(press)
126+ return CreateKeyPressEvent(key);
127+ else
128+ return CreateKeyReleaseEvent(key);
129+}
130+
131+static public Window_event_0 CreateSpecialKeyEvent(Special_key_0 key, boolean press){
132+ if(press)
133+ return CreateSpecialKeyPressEvent(key);
134+ else
135+ return CreateSpecialKeyReleaseEvent(key);
136+}
137+ ").
138+
139+%------------------------------------------------------------------------------%
140+
116141 :- pragma foreign_export_enum("C", button/0,
117142 [prefix("SAFFRON_BUTTON_"), uppercase]).
118143
@@ -148,54 +173,62 @@ create_no_event = maybe.no.
148173
149174 %------------------------------------------------------------------------------%
150175
151-:- func create_quit_event = (maybe.maybe(window_event)::out) is det.
152-create_quit_event = maybe.yes(quit).
153-:- pragma foreign_export("C", create_quit_event = (out), "Saffron_CreateQuitEvent").
154-:- pragma foreign_export("Java", create_quit_event = (out), "CreateQuitEvent").
176+:- func create_yes_event(window_event::di) = (maybe.maybe(window_event)::uo) is det.
177+create_yes_event(E) = maybe.yes(E).
178+:- pragma foreign_export("C", create_yes_event(di) = (uo), "Saffron_CreateYesEvent").
179+:- pragma foreign_export("Java", create_yes_event(di) = (uo), "CreateYesEvent").
155180
156181 %------------------------------------------------------------------------------%
157182
158-:- func create_press_event(character::in) = (maybe.maybe(window_event)::uo) is det.
159-create_press_event(C) = maybe.yes(press(key(CC))) :- builtin.copy(C, CC).
160-:- pragma foreign_export("C", create_press_event(in) = (uo), "Saffron_CreateKeyPressEvent").
161-:- pragma foreign_export("Java", create_press_event(in) = (uo), "CreateKeyPressEvent").
183+:- func create_quit_event = (window_event::uo) is det.
184+create_quit_event = quit.
185+:- pragma foreign_export("C", create_quit_event = (uo), "Saffron_CreateQuitEvent").
186+:- pragma foreign_export("Java", create_quit_event = (uo), "CreateQuitEvent").
162187
163188 %------------------------------------------------------------------------------%
164189
165-:- func create_release_event(character::in) = (maybe.maybe(window_event)::uo) is det.
166-create_release_event(C) = maybe.yes(release(key(CC))) :- builtin.copy(C, CC).
167-:- pragma foreign_export("C", create_release_event(in) = (uo), "Saffron_CreateKeyReleaseEvent").
168-:- pragma foreign_export("Java", create_release_event(in) = (uo), "CreateKeyReleaseEvent").
190+:- func create_press_event(character::di) = (window_event::uo) is det.
191+create_press_event(C) = press(key(C)).
192+:- pragma foreign_export("C", create_press_event(di) = (uo), "Saffron_CreateKeyPressEvent").
193+:- pragma foreign_export("Java", create_press_event(di) = (uo), "CreateKeyPressEvent").
169194
170195 %------------------------------------------------------------------------------%
171196
172-:- func create_special_press_event(special_key::in) = (maybe.maybe(window_event)::uo) is det.
173-create_special_press_event(C) = maybe.yes(press(special_key(CC))) :- builtin.copy(C, CC).
197+:- func create_release_event(character::di) = (window_event::uo) is det.
198+create_release_event(C) = release(key(C)).
199+:- pragma foreign_export("C", create_release_event(di) = (uo), "Saffron_CreateKeyReleaseEvent").
200+:- pragma foreign_export("Java", create_release_event(di) = (uo), "CreateKeyReleaseEvent").
201+
202+%------------------------------------------------------------------------------%
203+
204+:- func create_special_press_event(special_key::in) = (window_event::uo) is det.
205+create_special_press_event(C) = press(special_key(CC)) :-
206+ builtin.copy(C, CC).
174207 :- pragma foreign_export("C", create_special_press_event(in) = (uo), "Saffron_CreateSpecialKeyPressEvent").
175208 :- pragma foreign_export("Java", create_special_press_event(in) = (uo), "CreateSpecialKeyPressEvent").
176209
177210 %------------------------------------------------------------------------------%
178211
179-:- func create_special_release_event(special_key::in) = (maybe.maybe(window_event)::uo) is det.
180-create_special_release_event(C) = maybe.yes(release(special_key(CC))) :- builtin.copy(C, CC).
212+:- func create_special_release_event(special_key::in) = (window_event::uo) is det.
213+create_special_release_event(C) = release(special_key(CC)) :-
214+ builtin.copy(C, CC).
181215 :- pragma foreign_export("C", create_special_release_event(in) = (uo), "Saffron_CreateSpecialKeyReleaseEvent").
182216 :- pragma foreign_export("Java", create_special_release_event(in) = (uo), "CreateSpecialKeyReleaseEvent").
183217
184218 %------------------------------------------------------------------------------%
185219
186-:- func create_press_event(button::in, int::in, int::in) = (maybe.maybe(window_event)::uo) is det.
187-create_press_event(B, X, Y) = maybe.yes(press(BC, XC, YC)) :-
220+:- func create_press_event(button::in, int::in, int::in) = (window_event::uo) is det.
221+create_press_event(B, X, Y) = press(BC, XC, YC) :-
188222 builtin.copy(B, BC),
189223 builtin.copy(X, XC),
190224 builtin.copy(Y, YC).
191-
192225 :- pragma foreign_export("C", create_press_event(in, in, in) = (uo), "Saffron_CreateMousePressEvent").
193226 :- pragma foreign_export("Java", create_press_event(in, in, in) = (uo), "CreateMousePressEvent").
194227
195228 %------------------------------------------------------------------------------%
196229
197-:- func create_release_event(button::in, int::in, int::in) = (maybe.maybe(window_event)::uo) is det.
198-create_release_event(B, X, Y) = maybe.yes(release(BC, XC, YC)) :-
230+:- func create_release_event(button::in, int::in, int::in) = (window_event::uo) is det.
231+create_release_event(B, X, Y) = release(BC, XC, YC) :-
199232 builtin.copy(B, BC),
200233 builtin.copy(X, XC),
201234 builtin.copy(Y, YC).
@@ -204,8 +237,8 @@ create_release_event(B, X, Y) = maybe.yes(release(BC, XC, YC)) :-
204237
205238 %------------------------------------------------------------------------------%
206239
207-:- func create_resize_event(int::in, int::in) = (maybe.maybe(window_event)::uo) is det.
208-create_resize_event(W, H) = maybe.yes(resize(WC, HC)) :-
240+:- func create_resize_event(int::in, int::in) = (window_event::uo) is det.
241+create_resize_event(W, H) = resize(WC, HC) :-
209242 builtin.copy(W, WC),
210243 builtin.copy(H, HC).
211244 :- pragma foreign_export("C", create_resize_event(in, in) = (uo), "Saffron_CreateResizeEvent").
@@ -213,8 +246,8 @@ create_resize_event(W, H) = maybe.yes(resize(WC, HC)) :-
213246
214247 %------------------------------------------------------------------------------%
215248
216-:- func create_motion_event(int::in, int::in) = (maybe.maybe(window_event)::uo) is det.
217-create_motion_event(X, Y) = maybe.yes(motion(XC, YC)) :-
249+:- func create_motion_event(int::in, int::in) = (window_event::uo) is det.
250+create_motion_event(X, Y) = motion(XC, YC) :-
218251 builtin.copy(X, XC),
219252 builtin.copy(Y, YC).
220253 :- pragma foreign_export("C", create_motion_event(in, in) = (uo), "Saffron_CreateMotionEvent").