mulle-objc / mulle-objc-runtime Goto Github PK
View Code? Open in Web Editor NEW⏩ A fast, portable Objective-C runtime written 100% in C11
Home Page: https://www.mulle-kybernetik.com/mulle-objc
License: Other
⏩ A fast, portable Objective-C runtime written 100% in C11
Home Page: https://www.mulle-kybernetik.com/mulle-objc
License: Other
The compiler should somehow then alias the only named parameter as _param
, so that forwarding code can be written more uniformly, without having to think about types (in this case).
- (void) foo:(double) x
{
mulle_objc_object_call( self, @selector( bar:), _param);
}
- (void) foo:(void *) x
{
mulle_objc_object_call( self, @selector( bar:), _param);
}
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7f369f8 in _mulle_atomic_pointer_read (address=0x0)
at /home/src/srcO/MulleUI/MulleUICaca/test/dependency/include/mulle-thread/mulle-atomic-c11.h:272
272 result = atomic_load_explicit( address, memory_order_relaxed);
(gdb) bt
#0 0x00007ffff7f369f8 in _mulle_atomic_pointer_read (address=0x0)
at /home/src/srcO/MulleUI/MulleUICaca/test/dependency/include/mulle-thread/mulle-atomic-c11.h:272
#1 _mulle_objc_cachepivot_atomicget_entries (p=0x0) at /home/src/srcO/mulle-objc/mulle-objc-runtime/src/mulle-objc-cache.h:162
#2 mulle_objc_object_call (obj=0x405120 <_unnamed_nsstring>, methodid=174245054, parameter=0x7fffffffd978)
at /home/src/srcO/mulle-objc/mulle-objc-runtime/src/mulle-objc-call.c:99
Possible idea. There is a global symbol, that is used as the static string class and compiled/linked into the strings. The actual class information with method lists and so forth is then set by the Foundation.
The allocator is embedded in the hashmaps. With a _hashmap
one could extract the allocator
and pass it in on demand, which would shrink the class a bit.
To enable classes to free stuff like thread local keys, it would be good to run +unload on classes during universe destruction. The order in which +unload should be run (probably subclass -> class) is unclear.
This looks like a bug to me. The superclass should determine it's inheritance itself.
#import "import-private.h"
#include <stdio.h>
#include "regression-version.h"
typedef double mulle_relativetime_t;
typedef double mulle_absolutetime_t;
struct UIWindowFrameStatistics;
@interface Foo : NSObject
@end
@implementation Foo
static MULLE_C_NEVER_INLINE void stackPointer( void)
{
}
- (mulle_relativetime_t) remainingFrameTime:(mulle_absolutetime_t) now
frameRate:(mulle_relativetime_t) frameRate
animationRate:(mulle_relativetime_t) animationRate
frameStatistics:(struct UIWindowFrameStatistics *) stats
frameRateLimiter:(BOOL) frameRateLimiter
{
void* p = NULL;
fprintf( stderr, "stackPointer %p ", (void*)&p);
fprintf( stderr, "_param=%p ", _param);
fprintf( stderr, "now=%g ", now);
fprintf( stderr, "frameRate=%g ", frameRate);
fprintf( stderr, "animationRate=%g ", animationRate);
fprintf( stderr, "stats=%p ", stats);
fprintf( stderr, "frameRateLimiter=%ld ", (long) frameRateLimiter);
return( 0.0);
}
- (mulle_relativetime_t) remainingFrameTime:(mulle_relativetime_t) now
frameRate:(mulle_relativetime_t) frameRate
{
void* p = NULL;
fprintf( stderr, "stackPointer %p ", (void*)&p);
fprintf( stderr, "_param=%p ", _param);
fprintf( stderr, "now=%g ", now);
fprintf( stderr, "frameRate=%g ", frameRate);
return( 0.0);
}
@end
int main( int argc, char *argv[])
{
double x;
Foo *foo;
#if defined( DEBUG) && defined( __MULLE_OBJC__)
mulle_objc_global_check_universe( __MULLE_OBJC_UNIVERSENAME__);
#endif
foo = [Foo new];
for(;;)
{
x = [foo remainingFrameTime:1.0
frameRate:2.0
// animationRate:3.0
// frameStatistics:NULL
// frameRateLimiter:1
];
fprintf( stderr, "x=%g\n", x);
}
return( 0);
}
This only happens with DEBUG
. It's probably an alloca
which doesn't get reclaimed.
@encode( struct names { int f0:2; unsigned f1:12;}) -> {names=b2b12}
Instead of owner. The indirection to categoryid will not hurt much and then we can do a bit nicer introspection ?
[ 93%] Linking C executable mulle-objc-uniqueid
/usr/local/Cellar/cmake/3.26.2/bin/cmake -E cmake_link_script CMakeFiles/mulle-objc-uniqueid.dir/link.txt --verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -I/Users/wc/scratch/mulle/usr/include -Wno-parentheses -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names "CMakeFiles/_1_mulle-objc-uniqueid.dir/src/mulle-objc-uniqueid/main.c.o" "CMakeFiles/_1_mulle-objc-uniqueid.dir/src/mulle-objc-uniqueid.c.o" -o mulle-objc-uniqueid
Undefined symbols for architecture x86_64:
"__mulle_fnv1a_chained_32", referenced from:
__mulle_fnv1a_32 in mulle-objc-uniqueid.c.o
ld: symbol(s) not found for architecture x86_64
is this function defined in mulle-data and missed as a dependency as mulle-objc-uniqueid?
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-csvdump.c:162:16: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( list = _mulle_concurrent_pointerarrayreverseenumerator_next( &rover))
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-csvdump.c:167:21: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( method = _mulle_objc_methodlistenumerator_next( &enumerator))
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-dotdump.c:526:20: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( prop_cls = _mulle_objc_protocolclassenumerator_next( &rover))
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-dotdump.c:560:22: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( methodlist = _mulle_concurrent_pointerarrayenumerator_next( &rover))
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-dotdump.c:750:23: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( ivarlist = _mulle_concurrent_pointerarrayenumerator_next( &rover))
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-dotdump.c:769:27: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( propertylist = _mulle_concurrent_pointerarrayenumerator_next( &rover))
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-dotdump.c:932:15: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( cls = _mulle_objc_class_get_superclass( cls));
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-html.c:1184:17: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( value = _mulle_concurrent_pointerarrayenumerator_next( &rover))
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-htmldump.c:371:24: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( string = _mulle_concurrent_pointerarrayenumerator_next( &rover))
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-htmldump.c:468:26: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( prop_cls = _mulle_objc_protocolclassenumerator_next( &prover))
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-htmldump.c:500:30: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( propertylist = _mulle_concurrent_pointerarrayenumerator_next( &rover))
~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-htmldump.c:519:26: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( ivarlist = _mulle_concurrent_pointerarrayenumerator_next( &rover))
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-htmldump.c:538:28: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( methodlist = _mulle_concurrent_pointerarrayenumerator_next( &rover))
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-htmldump.c:558:28: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( methodlist = _mulle_concurrent_pointerarrayenumerator_next( &rover))
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-debug/src/mulle-objc-htmldump.c:740:15: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while( cls = _mulle_objc_class_get_superclass( cls));
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Volumes/Source/srcO/mulle-objc/mulle-objc-runtime/src/mulle-objc-class-search.c:404:12: warning: 9 enumeration values not handled in switch: 'search_default', 'search_imp', 'search_previous_method'... [-Wswitch]
switch( *mode)
^
/Volumes/Source/srcO/mulle-objc/mulle-objc-runtime/src/mulle-objc-class-search.c:427:15: warning: 10 enumeration values not handled in switch: 'search_default', 'search_imp', 'search_super_method'... [-Wswitch]
switch( *mode)
^
/Volumes/Source/srcO/mulle-objc/mulle-objc-runtime/src/mulle-objc-class-search.c:454:15: warning: 9 enumeration values not handled in switch: 'search_default', 'search_imp', 'search_super_method'... [-Wswitch]
switch( *mode)
^
/Volumes/Source/srcO/mulle-objc/mulle-objc-runtime/src/mulle-objc-class-search.c:507:12: warning: 10 enumeration values not handled in switch: 'search_default', 'search_imp', 'search_super_method'... [-Wswitch]
switch( *mode)
^
/Volumes/Source/srcO/mulle-objc/mulle-objc-runtime/src/mulle-objc-class-search.c:678:12: warning: 9 enumeration values not handled in switch: 'search_default', 'search_imp', 'search_specific_method'... [-Wswitch]
switch( mode)
This means (to me):
What's wrong with libobjc2 so that the mulle-objc-runtime is created instead?
If the caller doesn't know the prototype, the value is not correctly forwarded it seems.
So X declares - (void) setFoo:(double) x;
but that is not know to the caller. In this case if Y forwards, the value is incorrect.
Implemented "multi inheritance" as per docs in the ref below. However it doesn't work as expect (from reading the doc). Maybe I'm doing it wrong?
Ref: https://www.mulle-kybernetik.com/weblog/2017/mulle_objc_multiple_inheritance.html
@interface MulleBaseAnimal: NSObject {
}
- (NSString *) speak;
@end
@implementation MulleBaseAnimal
- (NSString *) speak
{
return @"I love beer";
}
@end
@class MulleVersatilityProtocolClass;
@protocol MulleVersatilityProtocolClass
- (NSString *) perform;
@end
@implementation MulleVersatilityProtocolClass
- (NSString *) perform {
return @"I can jump over the hoop";
}
@end
@interface MulleBelgiumDog: MulleBaseAnimal {}
- (NSString *) speak;
@end
@implementation MulleBelgiumDog
- (NSString *) speak
{
return @"J'aime Leffe";
}
@end
@interface MulleGermanDog: MulleBaseAnimal<MulleVersatilityProtocolClass> {}
- (NSString *) speak;
@end
@implementation MulleGermanDog
- (NSString *) speak
{
return @"Ich liebe Weissbier";
}
@end
int main (int argc, char *argv[])
{
MulleBaseAnimal * baseAnimal = [[MulleBaseAnimal alloc] init];
printf ("baseAnimal.1: %s\n", [[baseAnimal speak] UTF8String]);
MulleBelgiumDog * belgiumDog = [[MulleBelgiumDog alloc] init];
printf ("belgiumDog.1: %s\n", [[belgiumDog speak] UTF8String]);
MulleGermanDog * germanDog = [[MulleGermanDog alloc] init];
printf ("germanDog.1: %s\n", [[germanDog speak] UTF8String]);
printf ("germanDog.2: %s\n", [[germanDog perform] UTF8String]);
return 0;
};
Building & running:
$ make; ./mulle-testproto
[ 50%] Built target _1_mulle-testproto
[100%] Linking C executable mulle-testproto
[100%] Built target mulle-testproto
baseAnimal.1: I love beer
belgiumDog.1: J'aime Leffe
germanDog.1: Ich liebe Weissbier
mulle_objc_universe 0x1043d9488 fatal: unknown method ae293c20 "-perform" in class 109d90ee "MulleGermanDog"
zsh: abort ./mulle-testproto
I took the liberty to make a minimum reproduction repo from a clone of mulle-markdow. Note the branch "versatile".
https://github.com/wenq1/mulle-markdown/tree/versatile
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.