discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a c++11 wrapper for gnustep libraries


From: H. Nikolaus Schaller
Subject: Re: a c++11 wrapper for gnustep libraries
Date: Mon, 31 May 2021 10:00:27 +0200

Hi,
I've downloaded and looked into the wxWidgets source code and the task doesn't 
seem very complex.

There is a subdirectory src/cocoa which contains all .mm files and it is indeed 
like I imagined. For example the cursor.mm implements a C++ class for defining 
cursors and uses NSBitmapImageRep to make a custom NSCursor (wxWidgets seems to 
define its own cursors). Similar things for windows, menus, buttons, colours, 
fonts. lists, sliders, etc.

So IMHO the challenge is to get this wxWidgets-backend compiled on a 
GNUstep/Linux machine by modifying the makefiles and .mm files to match GNUstep 
conventions and properly link to gui and base. The result should just be 
another .so library with C++ headers.

What I can't judge is if it is better to modify the Cocoa code by some #ifdef 
__GNUSTEP__ or start with a copy of src/cocoa as src/gnustep.

IMHO having such a wrapper would be very useful to broaden the range of 
applications with GNUstep look and feel - and attract more developers from 
outside who are sitting on wxWidget based C++ source code.

BR,
Nikolaus


> Am 27.05.2021 um 09:42 schrieb ⁨أسامة مخزوم⁩ <⁨osmakh1@gmail.com⁩>:
> 
> once i write the wrapper, i will consider making GNUSTEP Ui more
> attractive to widget-toolkit backend developers so they can target
> GNUStep more easily, thank nikolaus for the purposal.
> 
> On Mon, May 24, 2021 at 11:53 AM H. Nikolaus Schaller <hns@computer.org> 
> wrote:
>> 
>> Hi,
>> 
>> Am 22.05.2021 um 11:41 schrieb أسامة مخزوم <osmakh1@gmail.com>:
>> 
>> Well, you seem to be on my side but in anthoer corner
>> 
>> 
>> :)
>> 
>> The question will be which corner finds the best adoption by the broader 
>> community of C++ programmers. What they really need or are missing. Because 
>> we need adopters.
>> 
>> When we are talking about Gnustep outside objc view, developers has one main 
>> benefit: gnustep libraries that provide portable and rich libraries as a 
>> framework. as a programmer i like it  but try to avoid objective-c and 
>> objective-c++ even more. gnustep ui are pretty cool to port wxWidgets or 
>> even tk into its backend.  but why not to make this STEP more stright and 
>> provide some wrapper/binding to c++? So anyone can later do whatever he want 
>> using a c++ syntax without getting messed in objective-c++ every project.
>> 
>> 
>> Hm. Maybe we should clarify the corners first.
>> 
>> My proposal is to use the wxWidgets API in C++. Implementing the wxWidgets 
>> API can likely be done in objc++ - not much different from Cocoa. The result 
>> should be some libwxgnustep...
>> 
>> This means that C++ programmers can simply link agains this wxWidgets 
>> wrappers by using plain C++.
>> They don't see objc++. Only those developers who develop wxWidgets wrapping 
>> for GNUstep have to care about.
>> 
>> To give an example, a hello world: 
>> https://docs.wxwidgets.org/3.0/overview_helloworld.html
>> 
>> A C++ programmer obviously (I have never written code in wxWidgets, but it 
>> is obvious what is going on) uses C++ classes like wxApp, wxFrame, wxMenu 
>> and functions like wxMessageBox() or SetStatusText().
>> These are provided by the wxWidget libs.
>> 
>> A GNUstep wxWidgets wrapper would of course be written in objc++, but 
>> compiled only once into the wrapper library.
>> It would translate these classes and function calls into ObjC-messages for 
>> GNUstep GUI and Base. For example I imagine that wxMessageBox() could open 
>> some NSPanel or the wxMenu method AppendSeparator() would translate into 
>> [menu addItem:[NSMenu separatorItem]].
>> 
>> The result would be that programmers can write in pure C++ for wxWidgets, 
>> link to the GNUstep wrapper and system and run the Apps on some GNUstep 
>> based desktop.
>> 
>> This would be my corner of thinking :)
>> 
>> Or do you generally think about something else?
>> 
>> 
>> Objc++ is something evil when it comes to syntax and code readabilty: two 
>> languages, many restricts to merge, and a strange convention . theorically 
>> you can anything possible using this latter, but its too ugly to people to 
>> handle it.
>> 
>> 
>> Fully agree. It should only be used to write Wrappers in either direction, 
>> e.g. making ObjC frameworks available to C++ programmers and making C++ 
>> libraries available to ObjC programmers.
>> 
>> That's why i would like to go further and make gnustep accesible outside 
>> using objective-c++ from the application-developers and other programmer
>> 
>> 
>> Yes, wxWidgets provide pure C++ classes to programmers and hide objc++.
>> 
>> So maybe we are not even in different corners?
>> 
>> And the key question is what C++ developers really want to see if GNUstep is 
>> wrapped. It is a little difficult to find them here on this list, but maybe 
>> some reader is "living in both worlds" and can comment.
>> 
>> BR and thanks,
>> Nikolaus
>> 
>> 
>> 
>> On Sat, May 15, 2021, 6:15 PM H. Nikolaus Schaller <hns@computer.org> wrote:
>>> 
>>> Hi Usama and all,
>>> any thoughts on my suggestions?
>>> 
>>> BR,
>>> Nikolaus
>>> 
>>>> Am 11.05.2021 um 14:24 schrieb H. Nikolaus Schaller <hns@computer.org>:
>>>> 
>>>> 
>>>>> Am 11.05.2021 um 13:48 schrieb Usama makhzoum <osmakh1@gmail.com>:
>>>>> 
>>>>> 
>>>>> On 5/10/21 11:20 PM, H. Nikolaus Schaller wrote:
>>>>>> Hi,
>>>>>> 
>>>>>>> Am 10.05.2021 um 20:58 schrieb أسامة مخزوم <osmakh1@gmail.com>:
>>>>>>> 
>>>>>>> hi all
>>>>>>> 
>>>>>>> I am thinking of a C++11 wrapper for base, gui and other libraries, may 
>>>>>>> be it is easier to do than another PL (because of objective-c++ 
>>>>>>> existence). however, i want to hear from you: I would like to have 
>>>>>>> opinions and whether if there was a attemp to do this (with c++98, for 
>>>>>>> example).
>>>>>>> 
>>>>>>> This also can give gnustep (another step). macosX developers always 
>>>>>>> searches for c++ wrappers around cocoa and friends. before they 
>>>>>>> enforced deeply to objc and swift, they simply wishing the last wish "I 
>>>>>>> hope that someone did it". so maybe a c++ wrapper can make gnutep 
>>>>>>> famous for the mac development, rather.
>>>>>> On macOS C++ is not the primary language (except for kernel drivers). It 
>>>>>> is ObjC and Swift.
>>>>>> 
>>>>>> IMHO, objc++ exists because there are some interesting C++ based 
>>>>>> libraries (e.g. data processing, business logic, file format decoders) 
>>>>>> where it should be possible to integrate them into objc based GUI apps. 
>>>>>> So in MVC architecture, C++ would be mainly used for providing an 
>>>>>> existing data model.
>>>>> 
>>>>> this could be also a reason for writing such a wrapper.
>>>> 
>>>> I do not understand how it would help. If the GUI is to be written in ObjC 
>>>> and some C++ libs to be included, wrapping ObjC transforms the whole 
>>>> project into a C++ project which is not what I would like to have.
>>>> 
>>>>> why doing things in two language becomes the standard way? think of it as 
>>>>> you were using python and have to do GUI staff with Qt, does i have to 
>>>>> try py-c++ or to use a wrapper like pyqt?
>>>> 
>>>> Well, if I use ObjC and want to do some macOS or Linux or Windows GUI 
>>>> stuff. Then I simply use GNUstep withou any wrappers.
>>>> 
>>>>> 
>>>>> 
>>>>> GNUSTEP framework is a very easy-and-popular framework, i like it both 
>>>>> with developing, and in use. and I think it will make another little 
>>>>> advance if there was some easy/neat way to use from c++ (and many other 
>>>>> programming languages, like perl, and even javascript), i assume some 
>>>>> progress when a c++ programmer (thinks in terms of templates, 
>>>>> mutli-inheritance and smartpointers) has access to GNUSTEP. I know that i 
>>>>> didn't invent something new or make things impossible as possible. I want 
>>>>> to help people that like c++-syntax to consider gnustep as an option, 
>>>>> after all.
>>>> 
>>>> Ok!
>>>> 
>>>> Now, I could imagine something like a https://www.wxwidgets.org glue so 
>>>> that you can compile any wxWidgets based application not only for macOS, 
>>>> Linux (GTK, Qt, X11 etc.) or Windows but also for GNUstep. So make GNUstep 
>>>> another "backend" option for wxWidgets in the list of supported platforms:
>>>> 
>>>>      https://www.wxwidgets.org/about/   (i.e. create some wxGNUstep)
>>>> 
>>>>> 
>>>>>> 
>>>>>> I wonder what a use case of the reverse wrapping would be.
>>>>> 
>>>>> a syntax-sugar, or convince wrapper is the main goal.  maybe used as 
>>>>> additional gui-frontend for a c++  graphical or command line application 
>>>>> without too much diving into obj-c++.
>>>> 
>>>> There may be a key decision before starting a project like you are 
>>>> thinking of: which classes and interfaces should your wrapper provide? 
>>>> Something completely new (optimized for wrapping GNUstep) or a well known 
>>>> set of interfaces already used by many C++ projects.
>>>> 
>>>> Beware: there are already many:
>>>> 
>>>>      
>>>> https://www.reddit.com/r/cpp/comments/babfl5/a_pretty_big_list_of_c_gui_libraries/
>>>> 
>>>> So wxWidget seems to me one of the preferred choices - but I am not that 
>>>> active in C++ that I know what others are doing.
>>>> 
>>>> What I therefor suggest is to check if it is sufficient to make a special 
>>>> compiler setup to compile wxOSX/Cocoaas as C++ wrapper around GNUstep. So 
>>>> it may even almost exist but nobody did have the idea to make use of it. 
>>>> And it may be a much more manageable task than inventing a new wrapper and 
>>>> make people use it.
>>>> 
>>>> Now I see a nice benefit of such a project: get any source package from 
>>>> github (e.g. KiCAD) that uses wxWidgets, compile it with wxGNUstep and get 
>>>> a harmonized look and feel inside a GNUstep desktop...
>>>> 
>>>> 
>>> 
>> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]