Timmy Douglas | 9 Jun 2009 00:24

Re: GTK and libraries loading in Windows


On Jun 8, 9:54 am, pocho <elpochodelage... <at> gmail.com> wrote:
> I also have a question... as I was told there's no way of saving gtk
> windows to be reopened later in slate, but is at least possible to
> save an image with all Gtk libs loaded? As I said before, it takes
> almost 8 minutes to load gtk so I don't want to do this loading
> everytime I turn on the vm.

Yeah it should be possible and fairly easy to do. If you can't do it
by loading gtk/init.slate and then saving your image, then tell me.
After than (like demo.slate), you run this to start the gui:
Gtk Main do: [ Gtk Workspace new show ].

Currently, entering the gui is the point of no return. It should be a
fairly easy fix (for someone that understands gtk) to make it where
closing the last window puts you back into a slate prompt so that you
can save again. The reason you can't just save in the gui is because
the GUI code uses bytearrays with C pointers of gtk objects and if you
save a slate image in that code and have it resume (by starting slate
with that image), the resuming code will deref those invalid pointers
and crash.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "slate-language" group.
To post to this group, send email to slate-language <at> googlegroups.com
To unsubscribe from this group, send email to slate-language+unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/slate-language?hl=en
-~----------~----~----~----~------~----~------~--~---

(Continue reading)

pocho | 2 Jun 2009 19:35
Picon

GTK and libraries loading in Windows


Hi again, this is a fork of the other post, specifically refered to
Gtk and libraries loading

As we said...

> > > > > All this was in order to make it work in Windows XP[...]
>
> > I think you might have been the first to try gtk on windows. It's
> > fairly new code
>
> Well, it seems to be almost working. I've been investigating a bit
> more... in src/ui/glib/lib.slate we have
>
> GLib define: #Lib -> (
>         ExternalInterface newForLibrary: 'glib-wrapper' primitives: #(
>                 (Void wrapper_g_object_connect_to_block_id(Pointer CString Int))"
>
>                 (Void wrapper_g_callback_queue_init())
>                 (Void wrapper_g_callback_queue_shutdown())
>                 (Pointer wrapper_g_callback_wait_next())
>                 (Void wrapper_g_callback_end(Pointer))
>                 (Int wrapper_g_callback_data_get_block_id(Pointer))
>                 (Int wrapper_g_callback_data_get_parameter_count(Pointer))
>                 (Pointer wrapper_g_callback_data_get_parameter_at(Pointer Int))
>
>                 (Boolean wrapper_g_type_is_fundamental(Int))
>                 (Int wrapper_g_type_fundamental(Int))
>                 (Int wrapper_g_type_from_instance(Pointer))
>                 (CString g_type_name(Int))
(Continue reading)

Timmy Douglas | 2 Jun 2009 23:49

Re: GTK and libraries loading in Windows


On Jun 2, 1:35 pm, pocho <elpochodelage... <at> gmail.com> wrote:
> in line 83 you have
>
> #ifdef WIN32
>   fn = (void *) GetProcAddress(h, symbol);
> #else
>   fn = (void *) dlsym(h, symbol);
> #endif
>
> the problem is that, as you can read here,http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html,
> "... The dlsym() function shall search for the named symbol in all
> objects loaded automatically as a result of loading the object
> referenced by handle ."
>
> but GetProcAddress used in windows doesn't (I wasn't able to find some
> parametrized version to do this), so when you call GetProcAddress(glib-
> wrapper handle, "g_type_name"), it just searches glib-wrapper.dll and
> fails.
>
> well.. I don't know how to solve this problem, but at least I think
> I've given you a good enough description so that someone could fix it.
> Also, I can send you the projects I had to create in VS to generate
> the wrappers' dlls.

Yeah, Guille did this as a shortcut to not having to write wrapper
functions in his plugin to recall the actual gtk function. I should
have thought of that. On the other hand, would it make more sense for
someone to just do a native windows port instead of using gtk?

(Continue reading)

pocho | 3 Jun 2009 05:20
Picon

Re: GTK and libraries loading in Windows


Well, I'm doing that, but then another problem arrises..

when creating the wrappers, I can't name them exactly like gtk funcs
(because they would clash) so, I'm adding wrap_ before each name (like
this: "g_type_name" becomes "wrap_g_type_name"). The problem then is
that I have to modify ui/glib/init.slate to search for
wrap_q_type_name instead of q_type_name. But now, everything in .slate
files refers to g_type_name, so we get MethodNotFound everywhere. This
happens for each glib, gtk and gdk function. Do you have any quick fix
for that problem?

On 2 jun, 18:49, Timmy Douglas <goo... <at> timmy.tmbx.com> wrote:
> On Jun 2, 1:35 pm, pocho <elpochodelage... <at> gmail.com> wrote:
>
>
>
> > in line 83 you have
>
> > #ifdef WIN32
> >   fn = (void *) GetProcAddress(h, symbol);
> > #else
> >   fn = (void *) dlsym(h, symbol);
> > #endif
>
> > the problem is that, as you can read here,http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html,
> > "... The dlsym() function shall search for the named symbol in all
> > objects loaded automatically as a result of loading the object
> > referenced by handle ."
>
(Continue reading)

Timmy Douglas | 3 Jun 2009 05:27

Re: GTK and libraries loading in Windows


timmy <at> timmy-desktop:~/src/slate/cslatevm$ grep -rn 'g_type_name' src/
grep: src/plugins/.libs/gtk-wrapper.la: No such file or directory
grep: src/plugins/.libs/glib-wrapper.la: No such file or directory
grep: src/plugins/.libs/llvm-wrapper.la: No such file or directory
grep: src/plugins/.libs/gdk-wrapper.la: No such file or directory
src/ui/glib/lib.slate:16:               (CString g_type_name(Int))
src/ui/glib/type.slate:33:      GLib Lib primitives g_type_name
applyTo: {t type}

that's probably the easiest way to find all the matches. Sorry, but
you might have to manually find and replace the matches. Visual Studio
probably has a find and replace that can help you get all the source
files.

Since they have underscores in the name, you don't have to worry much
about them being used in other places.

Sorry for the inconvenience.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "slate-language" group.
To post to this group, send email to slate-language <at> googlegroups.com
To unsubscribe from this group, send email to slate-language+unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/slate-language?hl=en
-~----------~----~----~----~------~----~------~--~---

pocho | 3 Jun 2009 05:35
Picon

Re: GTK and libraries loading in Windows


actually I was thinking in renaming all method names (or slots? not
sure) of

Glib Lib primitives

so that everything whose name starts with 'wrap_' gets renamed (to the
original name, whitout the 'wrap_'). That could be done just after
loading the library, at the end of src/ui/glib/init.slate. Do you
think that's posible?

On 3 jun, 00:27, Timmy Douglas <goo... <at> timmy.tmbx.com> wrote:
> timmy <at> timmy-desktop:~/src/slate/cslatevm$ grep -rn 'g_type_name' src/
> grep: src/plugins/.libs/gtk-wrapper.la: No such file or directory
> grep: src/plugins/.libs/glib-wrapper.la: No such file or directory
> grep: src/plugins/.libs/llvm-wrapper.la: No such file or directory
> grep: src/plugins/.libs/gdk-wrapper.la: No such file or directory
> src/ui/glib/lib.slate:16:               (CString g_type_name(Int))
> src/ui/glib/type.slate:33:      GLib Lib primitives g_type_name
> applyTo: {t type}
>
> that's probably the easiest way to find all the matches. Sorry, but
> you might have to manually find and replace the matches. Visual Studio
> probably has a find and replace that can help you get all the source
> files.
>
> Since they have underscores in the name, you don't have to worry much
> about them being used in other places.
>
> Sorry for the inconvenience.
(Continue reading)

Timmy Douglas | 3 Jun 2009 14:08

Re: GTK and libraries loading in Windows


I don't know exactly what you mean... but I think the easiest way
would be to rename to:

src/ui/glib/lib.slate:16:               (CString wrap_g_type_name
(Int))
src/ui/glib/type.slate:33:      GLib Lib primitives wrap_g_type_name
applyTo: {t type}

and in src/plugins/glib.c or whatever you might have:

char* wrap_g_type_name(int arg) { return g_type_name(arg); }

On Jun 2, 11:35 pm, pocho <elpochodelage... <at> gmail.com> wrote:
> actually I was thinking in renaming all method names (or slots? not
> sure) of
>
> Glib Lib primitives
>
> so that everything whose name starts with 'wrap_' gets renamed (to the
> original name, whitout the 'wrap_'). That could be done just after
> loading the library, at the end of src/ui/glib/init.slate. Do you
> think that's posible?
>
> On 3 jun, 00:27, Timmy Douglas <goo... <at> timmy.tmbx.com> wrote:
>
> > timmy <at> timmy-desktop:~/src/slate/cslatevm$ grep -rn 'g_type_name' src/
> > grep: src/plugins/.libs/gtk-wrapper.la: No such file or directory
> > grep: src/plugins/.libs/glib-wrapper.la: No such file or directory
> > grep: src/plugins/.libs/llvm-wrapper.la: No such file or directory
(Continue reading)

pocho | 3 Jun 2009 18:56
Picon

Re: GTK and libraries loading in Windows


well my idea is to just to use this wrap_* names when loading, because
it's not just g_type_name that would need to be changed in each use
in .slate files, it's every glib primitive (and that's a looot). So,
the way to do that would be, after loading the wrappers, and before
anyone uses them, run some code that gathers all wrapped methods ands
copies them but without the 'wrap_':

GLib Library specs methods select: [ |:each| each selector beginsWith:
'wrap_'].

would get the methods to be renamed, now I lack the code to:

a) rename them to the same but without wrap_, and
b) add them to the specs.

doing this would make all this change transparent to the users of the
wrapped functions.

On 3 jun, 09:08, Timmy Douglas <goo... <at> timmy.tmbx.com> wrote:
> I don't know exactly what you mean... but I think the easiest way
> would be to rename to:
>
> src/ui/glib/lib.slate:16:               (CString wrap_g_type_name
> (Int))
> src/ui/glib/type.slate:33:      GLib Lib primitives wrap_g_type_name
> applyTo: {t type}
>
> and in src/plugins/glib.c or whatever you might have:
>
(Continue reading)

Timmy Douglas | 3 Jun 2009 23:40

Re: GTK and libraries loading in Windows


Oh, yeah that makes sense. In that case you could do something like:

GLib define: #BaseLib -> (
	ExternalInterface newForLibrary: 'libglib' primitives: #(

		(CString g_type_name(Int))
	)
).

GLib BaseLib enable.

(We might have to modify the search path for dlopen/loadlibrary?)
In other words, put the real library name there and then call them
like

  GLib BaseLib primitives g_type_name applyTo: {t type}

Perhaps there would be a way to put them in the lib namespace also so
you wouldn't have to change that too. But it might make more sense if
they were separated.

How is this approach?

On Jun 3, 12:56 pm, pocho <elpochodelage... <at> gmail.com> wrote:
> well my idea is to just to use this wrap_* names when loading, because
> it's not just g_type_name that would need to be changed in each use
> in .slate files, it's every glib primitive (and that's a looot). So,
> the way to do that would be, after loading the wrappers, and before
> anyone uses them, run some code that gathers all wrapped methods ands
(Continue reading)

pocho | 4 Jun 2009 20:59
Picon

Re: GTK and libraries loading in Windows


Well, I think I'm almost there... using that code, I was able to load
everything. Actually, I changed GLib Lib to GLib LibWrapper and let
GLib Lib be the one who has all glib functions. That allowed me to
leave most slate code unchanged. Also had to do the same with Gdk and
Gtk, and add GObject, which was used in some places.

But... doing load: 'src/ui/gtk/demo.slate' worked fine until the end,
all gtk, glib and gdk files were loaded. It took almost 8 minutes but
worked. Then it tryied to open something and exploded. I've got some
weird messages repeating everytime (had to close console because it
wouldn't stop repeating). This was too much for me, I'm clueless here.

this was the output, it kind of repeated this all the time.

------------------------------
fp: 853991
sp: 853985
ip: 40/48
result: 853966
method: 'newWithFlags:type:buttons:'
regs: 16
heap alloc: true
arg[0] (014630B4) = ('Gtk MessageDialog')
arg[1] (00000003) = <smallint value: 1 (0x1x)>
arg[2] (00000005) = <smallint value: 2 (0x2x)>
arg[3] (00000009) = <smallint value: 4 (0x4x)>
var[0] (014630B4)= ('Gtk MessageDialog')
var[1] (00000003)= <smallint value: 1 (0x1x)>
var[2] (00000005)= <smallint value: 2 (0x2x)>
(Continue reading)

Mark Haniford | 5 Jun 2009 01:35
Picon

Re: GTK and libraries loading in Windows


Pocho, I for one, appreciate your efforts (especially on the windows
platform).  As you pointed out, Slate has some unique properties as a
language.  Once I win the lottery, I'll hire you, Timmy, and Brian to
work on Slate full time ;)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "slate-language" group.
To post to this group, send email to slate-language <at> googlegroups.com
To unsubscribe from this group, send email to slate-language+unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/slate-language?hl=en
-~----------~----~----~----~------~----~------~--~---

pocho | 6 Jun 2009 01:26
Picon

Re: GTK and libraries loading in Windows


jajaja I appreciate your offer but there's no way I'll become a full
time programmer!

On 4 jun, 20:35, Mark Haniford <markhanif... <at> gmail.com> wrote:
> Pocho, I for one, appreciate your efforts (especially on the windows
> platform).  As you pointed out, Slate has some unique properties as a
> language.  Once I win the lottery, I'll hire you, Timmy, and Brian to
> work on Slate full time ;)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "slate-language" group.
To post to this group, send email to slate-language <at> googlegroups.com
To unsubscribe from this group, send email to slate-language+unsubscribe <at> googlegroups.com
For more options, visit this group at http://groups.google.com/group/slate-language?hl=en
-~----------~----~----~----~------~----~------~--~---

pocho | 8 Jun 2009 15:54
Picon

Re: GTK and libraries loading in Windows


well, timmy has just committed some changes I did in order to make
this work in windows. Now if you try to open gtk in windows, you
should get a window open (that looks dead and won't respond, like this
http://img41.imageshack.us/img41/163/screenshotnwz.png ). While
debbugging slate vm in VS, I found that there were 2 threads running,
one stuck waiting here (I'm not 100% sure because i can't remember),

EXPORT CallbackData *wrapper_g_callback_wait_next(void) {
	return (CallbackData *)g_async_queue_pop(callbackQueue);
}

and the other here, I think between gtk_main() and gdk_threads_leave
(),

void wrapper_gtk_main( void ) {
	gdk_threads_enter(); //The book says to call this begore gtk_main
	gtk_main();
	gdk_threads_leave();
}

as I don't know what this does, and Gtk bundle doesn't come with
debbugging symbols, I can't go further. If someone could give a hand,
that would be nice. Meanwhile I may try to compile Gtk with VS, but
that will take a huge amount of time, so if this can be solved without
going through that pain I'll be really really happy.

I also have a question... as I was told there's no way of saving gtk
windows to be reopened later in slate, but is at least possible to
save an image with all Gtk libs loaded? As I said before, it takes
(Continue reading)

Timmy Douglas | 4 Jun 2009 23:26

Re: GTK and libraries loading in Windows


Thanks for working on it.

It looks like an error happened earlier from the output you pasted.
The error caused you to enter the debugger but there is an error when
you enter the debugger which makes the debugger go in an endless loop.
Make sure you ported these correctly since it seems the function
wasn't found:

src/ui/gtk/messagedialog.slate:12:              Gtk Lib primitives
gtk_message_dialog_new applyTo: {parentHandle. flags. type. buttons.
message }
src/ui/gtk/lib.slate:84:                (Pointer gtk_message_dialog_new
(Pointer Int Int Int CString))

This is probably executed from code around:

src/ui/gtk/main.slate:11:  c <at> (Condition traits) invokeDebugger [

On Jun 4, 2:59 pm, pocho <elpochodelage... <at> gmail.com> wrote:
> Well, I think I'm almost there... using that code, I was able to load
> everything. Actually, I changed GLib Lib to GLib LibWrapper and let
> GLib Lib be the one who has all glib functions. That allowed me to
> leave most slate code unchanged. Also had to do the same with Gdk and
> Gtk, and add GObject, which was used in some places.
>
> But... doing load: 'src/ui/gtk/demo.slate' worked fine until the end,
> all gtk, glib and gdk files were loaded. It took almost 8 minutes but
> worked. Then it tryied to open something and exploded. I've got some
> weird messages repeating everytime (had to close console because it
(Continue reading)


Gmane