2 Copyright (c) 2007-2008 Luca Bruno
4 This file is part of Smalltalk YX.
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
27 #include "syx-gobject.h"
29 static SyxOop _syx_gtk_process
;
32 _syx_gtk_iteration (void)
34 gtk_main_iteration_do (FALSE
);
38 EXPORT
void syx_g_closure_marshal (GClosure
*closure
,
41 const GValue
*param_values
,
42 gpointer invocation_hint
,
43 gpointer marshal_data
)
45 SyxOop array
= syx_array_new_size (n_param_values
);
47 SyxOop callback
= (SyxOop
) closure
->data
;
55 for (i
=0; i
< n_param_values
; i
++)
58 t
= G_TYPE_FUNDAMENTAL (G_VALUE_TYPE (v
));
64 SYX_OBJECT_DATA(array
)[i
] = syx_nil
;
68 SYX_OBJECT_DATA(array
)[i
] = syx_character_new (g_value_get_char (v
));
71 SYX_OBJECT_DATA(array
)[i
] = syx_boolean_new (g_value_get_boolean (v
));
80 SYX_OBJECT_DATA(array
)[i
] = syx_small_integer_new (g_value_get_int (v
));
84 SYX_OBJECT_DATA(array
)[i
] = syx_float_new (g_value_get_double (v
));
87 SYX_OBJECT_DATA(array
)[i
] = syx_string_new (g_value_get_string (v
));
91 SYX_OBJECT_DATA(array
)[i
] = SYX_POINTER_CAST_OOP (g_value_get_pointer (v
));
94 value
= SYX_POINTER_CAST_OOP (g_value_get_boxed (v
));
96 value
= SYX_POINTER_CAST_OOP (g_value_get_object (v
));
97 /* get the class name */
98 name
= G_VALUE_TYPE_NAME (v
);
99 /* lookup the class and create the object */
100 oop
= syx_object_new (syx_globals_at (name
));
101 /* set the first instance variable (handle) to hold the CPointer */
102 SYX_OBJECT_VARS(oop
)[0] = value
;
104 SYX_OBJECT_DATA(array
)[i
] = oop
;
109 context
= syx_send_unary_message (callback
, "invoke");
110 syx_interp_enter_context (_syx_gtk_process
, context
);
111 SYX_PROCESS_SUSPENDED (_syx_gtk_process
) = syx_false
;
112 do { syx_scheduler_run (); } while (SYX_IS_FALSE (SYX_PROCESS_SUSPENDED (_syx_gtk_process
)));
117 SYX_FUNC_PRIMITIVE(Gtk_main
)
119 static syx_bool registered
= FALSE
;
124 syx_scheduler_poll_register_source (_syx_gtk_iteration
, syx_nil
);
125 _syx_gtk_process
= es
->message_arguments
[0];
128 SYX_PRIM_RETURN (es
->message_receiver
);
131 SYX_FUNC_PRIMITIVE(Gtk_mainQuit
)
133 syx_scheduler_poll_unregister_source (_syx_gtk_iteration
, syx_nil
);
135 SYX_PRIM_RETURN(es
->message_receiver
);
139 syx_plugin_initialize (void)
141 static syx_bool _syx_gtk_initialized
= FALSE
;
142 syx_symbol
*filename
;
143 syx_string full_filename
;
144 static syx_symbol gtk_filenames
[] = {
145 "GObject.st", "Gtk.st",
146 "GtkWidget.st", "GtkLabel.st", "GtkContainer.st",
147 "GtkWindow.st", "GtkButton.st", "GtkTools.st", "GtkBox.st",
148 "GtkAdjustment.st", "GtkScrolledWindow.st",
149 "GtkTextIter.st", "GtkTextView.st", "GtkTextBuffer.st", "GtkTextMark.st",
150 "GtkTextTag.st", "GtkTextTagTable.st",
154 if (_syx_gtk_initialized
)
157 _syx_gtk_initialized
= TRUE
;
159 for (filename
= gtk_filenames
; *filename
; filename
++)
161 full_filename
= syx_find_file ("st", "gtk", *filename
);
162 syx_file_in_blocking (full_filename
);
163 syx_free (full_filename
);
172 syx_plugin_finalize (void)