Skip to content

Avoid duplication of effort #1

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

Open
wants to merge 55 commits into
base: main
Choose a base branch
from

Conversation

ethanc8
Copy link

@ethanc8 ethanc8 commented Mar 6, 2024

I don't actually intend for this pull request to be merged (I wanted to file an issue but this repo doesn't accept issues), but we should avoid duplication of effort in our CoreFoundation ports. My CoreFoundation port is based off of swift-corelibs-foundation from Catalina (at some version of Swift 5.3, I don't remember which and I'm not very good at Git), and it supports bridging with GNUstep-base. In my gnustep branch, I just have a plain port of CoreFoundation to be buildable with GNUstep Make. Could you please explain what changes you've made in your fork more broadly and whether it would be better to build off of my fork or to start a new fork from a newer version of CoreFoundation?

millenomi and others added 30 commits May 9, 2020 09:27
Fix typo and logic error in the overflow check in integerMultiply(), which was
screwing up Decimal calculations under certain conditions.

(cherry picked from commit 81fddf2)
[5.3] SR-13015: Decimal calculation incorrect on Linux
There are some issues in current implementation. To keep things simple, I'd like to extend
test coverage of problem area first. Not all of new tests are expected to fail, but I find them useful
to have.

Co-authored-by: Andrew Druk <[email protected]>
Co-authored-by: Anton Pogonets <[email protected]>
(cherry picked from commit d6cb1ee)
This fixes typos in code responsible for counting operations in queue.

(cherry picked from commit d8c2cfa)
- prevent releasing of stored value in `Operation._queue` property getter
- balance retain count after current queue removed from thread-specific storage
- make test_OperationWaitUntilFinished stable
- extend test_OperationCount

(cherry picked from commit 6257faa)
…f a directory was created by another thread concurrently.

If another thread creates one of the same directories in the target path, the `!fileExists` check may pass while the `mkdir` call fails with `EEXIST`. However, if the existing file is a directory, then that should still be a success.

Fixes [SR-12272](https://bugs.swift.org/browse/SR-12272).

(cherry picked from commit b6eea02)
[5.3] Return success from `FileManager` recursive directory creation even if a directory was created by another thread concurrently.
[5.3] fix convenience accessors on CocoaError and URLError
[5.3] improve URLError returned upon task cancellation
The static libraries need to link against additional dependencies, which are listed in the newly added modulemaps
Remove the absolute path to the host toolchain's stdlib from the three Foundation
shared libraries.
Maybe they need to be compiled together.
@ethanc8
Copy link
Author

ethanc8 commented Mar 17, 2024

@trunkmaster What do you think?

@trunkmaster
Copy link
Owner

trunkmaster commented Mar 17, 2024

@ethanc8 hi, probably I've missed your 2-week-ago PR, sorry.

I don't actually intend for this pull request to be merged (I wanted to file an issue but this repo doesn't accept issues), but we should avoid duplication of effort in our CoreFoundation ports.

It's excellent idea to merge our efforts! I've created this repo to avoid keeping patches inside NEXTSPACE.

My CoreFoundation port is based off of swift-corelibs-foundation from Catalina (at some version of Swift 5.3, I don't remember which and I'm not very good at Git), and it supports bridging with GNUstep-base.

My repo is based on the 5.9.2 branch of original Swift's version. I've noticed that CoreFoundation in Swift's repository changes not that often. I think your bridging to GNUstep-base would be a killer feature!

In my gnustep branch, I just have a plain port of CoreFoundation to be buildable with GNUstep Make. Could you please explain what changes you've made in your fork more broadly and whether it would be better to build off of my fork or to start a new fork from a newer version of CoreFoundation?

The main idea behind this fork is to create CoreFoundation to write C-based programms with all the power of CoreFoundation. For example, it helped me to rewrote large part of WindowMaker and get rid of WINGs and data management part of it (preferences, arrays, dictionaries etc.).

The next major part is CFRunLoop and CFFileDescriptor implementation. I've managed to get X11 messages by monitoring CFFileDescriptor of X server connection inside CFRunLoop.

Next big deal is a CFNotificationCenter implementation: I use it inside WM to pass messages inside C code and create a NSNotificationCenter<->CFNotificationCenter bridge. This part is usefull for notifications exchange between Obj-C and C programms. For example, GNUstep applications may send notifications to global notifications center and be catched by window manager (CFRunLoop, CFNotificationCenter) and vice versa.

So to sum up, i've made the following changes:

  • made Swift's version of CoreFoundation to build as shared library;
  • added missing CFFileDescriptor implementation - testing with NEXTSPACE;
  • added missing CFNotificationCenter implementation - testing with NEXTSPACE;
  • removed all Swift-specific code - in this repo I have only CoreFoundation subdirectory.

You could track all my changes starting from 03eea75 commit.

If you want I can configure this repo available for issues and PR. Also I want to keep this repo as CMake-based project. Do you want to become a contributor or will add your changes as PRs?

@trunkmaster
Copy link
Owner

@ethanc8 I don't quite understand what's going on here. I see CoreFoundation subdirectory with a bunch of C files (.c) renamed into ObjC files (.m). What do you include Swift code? How it should correspond to existing CF sources that already exists in my CF source tree?

Could you please explain your idea of implementing CoreFoundation to GNUstep Base bridge? What mechanics of bridging you assume to implement? How ObjC classes should gain access to CF types and vice versa?

@ethanc8
Copy link
Author

ethanc8 commented Jul 28, 2024

@ethanc8
Copy link
Author

ethanc8 commented Jul 28, 2024

(this is a simplification, you need to read my commits in order to know everything I did, as I forgot many things that I did two years ago)

  • I branched off of swift-5.3-RELEASE, based on the Catalina source code, with release notes here (CoreFoundation versions 1665.15~1677.104)
  • I renamed all .c files to .m.
  • There were various changes I did to make it build with GNUstep Make -- this was a couple of years ago and I don't remember exactly
  • The deployment runtime can be DEPLOYMENT_RUNTIME_OBJC or DEPLOYMENT_RUNTIME_SWIFT. If DEPLOYMENT_RUNTIME_OBJC, it will bridge to Darwin Foundation.framework, and if DEPLOYMENT_RUNTIME_SWIFT, it will bridge to the Windows/Linux Swift runtime. I added a DEPLOYMENT_RUNTIME_GNUSTEP_LIBOBJC2, and added the correct behavior for that case to everywhere that did a #ifdef DEPLOYMENT_RUNTIME_OBJC.
  • I modified CF_OBJC_FUNCDISPATCHV and other macros which were related to bridging, to work on Objective-C.
  • I implemented a lot of toll-free bridged classes according to https://github.com/ethanc8/CoreFoundation/blob/gnustep-bridging/CoreFoundation/Documentation/Bridging.md, and based on the WinObjC Foundation.

@trunkmaster
Copy link
Owner

trunkmaster commented Jul 29, 2024

(this is a simplification, you need to read my commits in order to know everything I did, as I forgot many things that I did two years ago)

OK, my version of CoreFoundation is newer - 5.9.3.

  • I renamed all .c files to .m.

What for? Is there any reason to make C library to look like ObjC?

  • There were various changes I did to make it build with GNUstep Make -- this was a couple of years ago and I don't remember exactly

I see no reason to build Apple library with GNUstep Make - my version builds before GNUstep Make even installed. Do you?

  • The deployment runtime can be DEPLOYMENT_RUNTIME_OBJC or DEPLOYMENT_RUNTIME_SWIFT. If DEPLOYMENT_RUNTIME_OBJC, it will bridge to Darwin Foundation.framework, and if DEPLOYMENT_RUNTIME_SWIFT, it will bridge to the Windows/Linux Swift runtime. I added a DEPLOYMENT_RUNTIME_GNUSTEP_LIBOBJC2, and added the correct behavior for that case to everywhere that did a #ifdef DEPLOYMENT_RUNTIME_OBJC.

  • I modified CF_OBJC_FUNCDISPATCHV and other macros which were related to bridging, to work on Objective-C.

Great.That's the most interesting part for me.

Could you please extract those 2 block of changes and prepare it to apply to my source tree? See my first post in this discussion.
At this point all of these changes couldn't be aplied to trunkmaster/apple-corefoundation.

Thanks, I'll try to understand idea.

@ethanc8
Copy link
Author

ethanc8 commented Jul 29, 2024

What for? Is there any reason to make C library to look like ObjC?

The point is not to look like ObjC; the point is to allow CoreFoundation to send Objective-C messages without having to manually call objc_msgSend (which is rather error-prone). CF_OBJC_FUNCDISPATCHV in my version simmply sends Objective-C messages.

I see no reason to build Apple library with GNUstep Make - my version builds before GNUstep Make even installed. Do you?

I know how to use GNUstep Make, and don't know how to use CMake. GNUstep Make is also good at dealing with GNUstep libraries. That's pretty much the only reason why.

Could you please extract those 2 block of changes and prepare it to apply to my source tree? See my first post in this discussion.

Sorry, I don't want to work on this. I want to focus on getting the tests to pass; if you need a CoreFoundation with bridging, just use mine. If I do want to rebase on a newer CoreFoundation, I will rebase on Ventura CoreFoundation, not Monterey CoreFoundation.

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.

10 participants