Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function channel_of_descr_socket (windows has different handles for sockets and files) #176

Merged
merged 4 commits into from
May 14, 2024

Conversation

SkySkimmer
Copy link
Contributor

@SkySkimmer
Copy link
Contributor Author

(I don't know if this patch is expected to work outside windows or if it needs some modification)

@MSoegtropIMC
Copy link
Contributor

I would say the main question is if we want separate functions also in Unix, so that one could more easily write portable code. If so, then on Unix the two channel_of_descr functions would be the same, on Windows not. On all OSes one should use the correct function depending on if one is working with a file or a socket. The downside of this portability would be that it would require distinctions which would be quite artificial in Linux in some playes - maybe even annoying.

Copy link
Owner

@garrigue garrigue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine; I have just a suggestion for the naming of the wrapper.

src/glib.ml Outdated
@@ -72,6 +72,8 @@ module Io = struct
type id
external channel_of_descr : Unix.file_descr -> channel
= "ml_g_io_channel_unix_new"
external channel_of_descr_socket : Unix.file_descr -> channel
= "ml_g_io_channel_unix_new_socket"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this rather be ml_g_io_channel_win32_new_socket ?
Note that the change is not visible in the interface, so this would not matter for CoqIDE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean to rename the C function? One can of course do this. The reason I named it this way is that this is still about Windows' emulation of the Unix socket system. But I have no strong feelings about the naming.

@garrigue
Copy link
Owner

I've changed it quite a lot. Basically, since OCaml uses a common tagged data structure for sockets and handles, there is no need to have separate functions.
Unfortunately, I have no environment to test that on windows. Can you check that it works ?
Also, I'm not opposed to add the other ocaml function name for backward compatibility, if it matters.

@SkySkimmer
Copy link
Contributor Author

I don't have a windows to test either

@MSoegtropIMC
Copy link
Contributor

@garrigue : I can test it. Are we talking about the PR branch or can I find the code somewhere else?

@garrigue
Copy link
Owner

garrigue commented Mar 5, 2024

I pushed the code to the pr branch.

@MSoegtropIMC
Copy link
Contributor

OK, give me a few days. I put it on my list for Friday.

@MSoegtropIMC
Copy link
Contributor

Sorry, I had to delay it to Monday, but it is still on my list ...

@MSoegtropIMC
Copy link
Contributor

Not sure what is going on, but I can't get the patch applied by opam. If I run opam reinstall -b lablgtk3 I don't see the patch applied in the opam build folder (the patch file as such is there).

I downloaded https://patch-diff.githubusercontent.com/raw/garrigue/lablgtk/pull/176.patch, added it to the opam file in the usual way (there was already one in my local patch repo - I just had to change the name). All looks good, no errors, opam lint says all is good, but the patch is not done.

If I modify the name of the patch file, opam complains that the patch file is not there (as it should). Also my original patch works. But if I put in the patch of this PR nothing happens. I have not the slightest idea what is going on here.

It might take a bit ...

@MSoegtropIMC
Copy link
Contributor

I think I found it - the patch produced by github (see link above) contains several separate patches for separate commits (4 in total) - apparently opam / patch does not support this.

@MSoegtropIMC
Copy link
Contributor

I split the patch file into 4 and added all 4 to opam - this also doesn't work (no errors, no patch applied).

Can someone please squash this PR - maybe this fixes it.

@SkySkimmer
Copy link
Contributor Author

I don't think squashing would change the patch.

@SkySkimmer
Copy link
Contributor Author

Also why test with a patch instead of pointing the url at my branch?

@MSoegtropIMC
Copy link
Contributor

Also why test with a patch instead of pointing the url at my branch?

It is Coq Platform policy to only use official releases + patches which are kept directly in the Coq Platform repo.

But this can be handled - I will just clone the repo (I am lazy and didn't do sp as yet) and I am sure I find a way to create the patch - worst case I put both versions in separate folders ...

@MSoegtropIMC
Copy link
Contributor

I squashed it in a local branch and created a patch from that - this did work.

One obviously needs to adjust CoqIDE then - I guess we do this from Coq 8.20 on. We need to take care to link it to the proper lablgtk versions in opam then.

I did a quick test of the resulting CoqIDE and it works fine.

=> good to go.

@SkySkimmer
Copy link
Contributor Author

One obviously needs to adjust CoqIDE then

That's what

Also, I'm not opposed to add the other ocaml function name for backward compatibility, if it matters.

is about no?

@MSoegtropIMC
Copy link
Contributor

One obviously needs to adjust CoqIDE then

That's what

Also, I'm not opposed to add the other ocaml function name for backward compatibility, if it matters.

is about no?

Yes. I am not sure we want this, though. It is for sure cleaner to get rid of it and assuming everyone is using opam it should not be a problem to manage the version restrictions. But I have no strong feelings about this - adding the old function name as an alias would also be an option.

@MSoegtropIMC
Copy link
Contributor

Thinking about it: one would have to add an upper bound for the lablgtk version for all older versions of CoqIDE. I still would prefer this solution, but again no strong feelings.

@SkySkimmer
Copy link
Contributor Author

So is this going to be merged?

@garrigue garrigue merged commit ea5a8dc into garrigue:lablgtk3 May 14, 2024
9 of 15 checks passed
@garrigue
Copy link
Owner

Sorry the long delay, I got to do other things and forgot.
But I still need to do a release, probably next week.

garrigue added a commit to garrigue/opam-repository that referenced this pull request Jun 10, 2024
CHANGES:

2024.06.10 [Jacques]
  * Prepare for release
  * Fix typos in README.md (garrigue/lablgtk#182) [Sylvain Chiron]

2024.05.20 [Jacques]
  * Typo in ml_gtk_text_buffer_get_iter_at_line_index. (garrigue/lablgtk#181) [Hugo Herbelin]

2024.05.14 [Jacques]
  * Support windows sockets in Glib.IO.channel_of_descr (garrigue/lablgtk#176)
    [with Michael Soegtrop]

2024.03.24 [Jacques]
  * fix pointer incompatibility in ml_gtk_style_context_list_classes (garrigue/lablgtk#178)
@SkySkimmer SkySkimmer deleted the win-patch branch June 18, 2024 11:01
avsm pushed a commit to avsm/opam-repository that referenced this pull request Sep 5, 2024
CHANGES:

2024.06.10 [Jacques]
  * Prepare for release
  * Fix typos in README.md (garrigue/lablgtk#182) [Sylvain Chiron]

2024.05.20 [Jacques]
  * Typo in ml_gtk_text_buffer_get_iter_at_line_index. (garrigue/lablgtk#181) [Hugo Herbelin]

2024.05.14 [Jacques]
  * Support windows sockets in Glib.IO.channel_of_descr (garrigue/lablgtk#176)
    [with Michael Soegtrop]

2024.03.24 [Jacques]
  * fix pointer incompatibility in ml_gtk_style_context_list_classes (garrigue/lablgtk#178)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants