Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Athas
Aug 6, 2007

fuck that joker
I have a very high tolerance for ugliness of generated code, so I can live with that. Is there any real information on calling ObjC from C? I guess messages turn into calls to the objc_msgSend() family of functions, but it'd be nice to read about someone else who already took a jaunt through this minefield.

Adbot
ADBOT LOVES YOU

Xarn
Jun 26, 2015
idgaf about graphic APIs, but I would kill for a good CI option for OS X.


Or I can just keep on not supporting it I guess :v:

Sapozhnik
Jan 2, 2005

Nap Ghost

Xarn posted:

idgaf about graphic APIs, but I would kill for a good CI option for OS X.


Or I can just keep on not supporting it I guess :v:

appveyor is about the best you're going to do for something that isn't self hosted

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Athas posted:

I have a very high tolerance for ugliness of generated code, so I can live with that. Is there any real information on calling ObjC from C? I guess messages turn into calls to the objc_msgSend() family of functions, but it'd be nice to read about someone else who already took a jaunt through this minefield.

the associated c function type of an objc method “- (Result) foo: (Params...)” is “Result (*)(id, SEL, Params...)”. you cast objc_msgSend to that type and call it (yes, really), like “value = ((int (*)(id, SEL)) objc_msgSend)(receiver, selector);”. the selector is loaded from a global variable in a special section that’s initialized to a string literal. since you’re doing this in c, you can use any old pointer type for id and SEL. if you need to call a method that would return a struct result indirectly, you may have to call msgSend_stret, depending on the target. the other msgSend functions can be ignored if you don’t care about messaging nil, which you probably don’t. if you need to call a class method, you get the class pointer by loading from a global variable in a different special section initialized to the class symbol, kindof like the selectors. if you can read llvm ir, just compile some objc code to see the pattern

the only subtle trick here is to put __attribute__((used)) on the global variables to stop the optimizer from thinking it can optimize loads from them

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I know nothing about Objective-C. What makes this sendMsg thunk necessary, instead of name mangling for non virtual dispatch, and vtables for virtual?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
it’s actually dynamic, so you can’t just directly link, and various goals make v-tables undesirable as an implementation mechanism

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Suspicious Dish posted:

I know nothing about Objective-C. What makes this sendMsg thunk necessary, instead of name mangling for non virtual dispatch, and vtables for virtual?

you can create classes at runtime, add new methods to existing classes at runtime, have classes which respond to every selector (including ones which they don't know about at compile time) to implement things like proxies, etc.

obj-c is smalltalk + c, so the OO part of it is much closer to ruby than c++

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
does anything actually use that stuff or is it mostly just a fun curiosity

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
that stuff is heavily used by the frameworks and anyone implementing things in the same style

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

welcome to obj-c com
you can instantiate anything at obj-c com
anything at all!
hahahaha
the only limit is yourself allocated memory

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
even if you didn't have all the objc dynamism, v-tables perform really badly when there are near-universal root classes with hundreds of methods (usually added by class extensions), since that prefix has to be added to every v-table in the system. they also suffer a lot when you want to maintain a stable ABI and so aren't willing to just hard-code v-table offsets in every call site, since you have to assemble v-tables and load offsets dynamically

swift primarily uses v-tables for its native class and protocol dispatch but mitigates these problems by (1) not using a (user-visible) root class, (2) not using v-table dispatch for class extension methods, and (3) actually knowing when something is your code vs. code that you need to allow to change

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
we’ve had protocols forever (since like 1991 or so) but had to add @optional in order to actually use them in the APIs instead of just id

for example, it used to be that data sources and delegates were just described in our headers via categories-without-implementations on NSObject, as a way of informing you what methods you could implement in them

which meant code completion for anything descended from NSObject would show allllll those methods, even though none of them had implementations in NSObject, and there was no enforcement of conformance at declaration or call sites

of course now Swift comes along with protocols that don’t have optional methods… unless they’re imported from ObjC of course

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Suspicious Dish posted:

I know nothing about Objective-C. What makes this sendMsg thunk necessary, instead of name mangling for non virtual dispatch, and vtables for virtual?
just fyi, there is no longer any reason to know anything about objc

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Gazpacho posted:

just fyi, there is no longer any reason to know anything about objc

except if you want to call into the Metal API, as we were discussing

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Gazpacho posted:

just fyi, there is no longer any reason to know anything about objc

looks like somebody forgot about gnustep

The_Franz
Aug 8, 2003

Lutha Mahtin posted:

looks like somebody forgot about gnustep

someone in tyool 2020 is actually writing a new NeXT-like window manager in objective-c called nextspace

Bloody
Mar 3, 2013

im the 1920x994 monitor

akadajet
Sep 14, 2003

The_Franz posted:

someone in tyool 2020 is actually writing a new NeXT-like window manager in objective-c called nextspace



doesn’t this happen like every year?

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man
2020 is the year of next on the desktop

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



NeXT stop the DeSK top

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
it's always next year somewhere

Captain Foo
May 11, 2004

we vibin'
we slidin'
we breathin'
we dyin'

pokeyman posted:

it's always next year somewhere

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

aw yeah, time to party like it's 1995

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Lutha Mahtin posted:

looks like somebody forgot about gnustep
nobody ever remembered gnustep

suffix
Jul 27, 2013

Wheeee!
some self-ownage going on in https://blog.golang.org/a-new-go-api-for-protocol-buffers

quote:

We also observed that a frequent source of problems was that the proto.Message interface, which identifies values of generated message types, does very little to describe the behavior of those types. When users create types that implement that interface (often inadvertently by embedding a message in another struct) and pass values of those types to functions expecting a generated message value, programs crash or behave unpredictably.

quote:

opts := fd.Options().(*descriptorpb.FieldOptions)
(Why the type assertion? Since the generated descriptorpb package depends on protoreflect, the protoreflect package can't return the concrete options type without causing an import cycle.)

quote:

google.golang.org/protobuf@v1.20.0 is APIv2. This module depends upon github.com/golang/protobuf@v1.4.0, so any program which uses APIv2 will automatically pick a version of APIv1 which integrates with it.
(Why start at version v1.20.0? To provide clarity. We do not anticipate APIv1 to ever reach v1.20.0, so the version number alone should be enough to unambiguously differentiate between APIv1 and APIv2.)

so they release a backwards incompatible v2 version but they don't want to bump the major version and put v2 in the url like the broken "you don't need version pinning if your none of your dependencies ever make breaking changes" go import system requires so they make it v1.20.0 for "clarity"

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

suffix posted:

some self-ownage going on in https://blog.golang.org/a-new-go-api-for-protocol-buffers




so they release a backwards incompatible v2 version but they don't want to bump the major version and put v2 in the url like the broken "you don't need version pinning if your none of your dependencies ever make breaking changes" go import system requires so they make it v1.20.0 for "clarity"

This is dumb but semantic versioning aside you buried the lede that v1 will be exclusively hosted at github.com/golang/protobuf and v2 at google.golang.org/protobuf

Nomnom Cookie
Aug 30, 2009



It is true that if nobody ever makes breaking changes its fine to always depend on HEAD. and when you think about it, isn't breaking stuff always bad?

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
you might even say that the first version of anything is the best because any change will introduce bugs

Zlodo
Nov 25, 2006
maybe just dont make bugs then??

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


Zlodo posted:

maybe just dont make bugs then??

sound advice there

zokie
Feb 13, 2006

Out of many, Sweden

Nomnom Cookie posted:

It is true that if nobody ever makes breaking changes its fine to always depend on HEAD. and when you think about it, isn't breaking stuff always bad?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

eschaton posted:

you might even say that the first version of anything is the best because any change will introduce bugs

I find in fact that my best code is that which I haven’t yet written, but that may not be a universal experience.

CPColin
Sep 9, 2003

Big ol' smile.
*thinks about a piece of unwritten code* "wow it's beautiful"
*writes it* "aw man not again"

Pile Of Garbage
May 28, 2007



CPColin posted:

*thinks about a piece of unwritten code* "wow it's beautiful"
*writes it* "aw man not again"

Pile Of Garbage
May 28, 2007



e: gently caress double

SAVE-LISP-AND-DIE
Nov 4, 2010
all code is equally trash, some is more equal than others

JawnV6
Jul 4, 2004

So hot ...

CPColin posted:

*thinks about a piece of unwritten code* "wow it's beautiful"
*writes it* "aw man not again"

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

CPColin posted:

*thinks about a piece of unwritten code* "wow it's beautiful"
*writes it* "aw man not again"

it’s like an autobiography right here

gonadic io
Feb 16, 2011

>>=

Subjunctive posted:

it’s like an autobiography right here

next time though

Adbot
ADBOT LOVES YOU

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

gonadic io posted:

next time though

law of large numbers says that I’m going to produce something at least mediocre any time now

right?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply