Coder Social home page Coder Social logo

mulle-objc / mulle-objc-runtime Goto Github PK

View Code? Open in Web Editor NEW
109.0 7.0 8.0 3.56 MB

⏩ A fast, portable Objective-C runtime written 100% in C11

Home Page: https://www.mulle-kybernetik.com/mulle-objc

License: Other

CMake 0.38% Shell 2.48% C 84.32% Objective-C 12.83%
objective-c runtime mulle-objc objc-runtime

mulle-objc-runtime's People

Contributors

codeon-nat avatar mulle-kybernetik-tv avatar mulle-nat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mulle-objc-runtime's Issues

_param is unavailable when void * -only parameter passing is used

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).

OK

- (void) foo:(double) x
{
   mulle_objc_object_call( self, @selector( bar:), _param);
}

Not OK (at the moment)

- (void) foo:(void *) x
{
   mulle_objc_object_call( self, @selector( bar:), _param);
}

Static strings w/o a NSString class produce SIGSEGV

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.

+unload message for universe destruction

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.

mulle-clang in debug mode pushes the stackpointer too much

#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.

__mulle_fnv1a_32

[ 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?

docs website

I experimented an initial docs website using vitepress. See if you like it.

$ git clone https://github.com/wenq1/vitepress-mulle
$ cd vitepress-mule
$ npm i
$ npm run docs:dev

image

Warnings

/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)

_resignAsRootObject is never used in practice

This means (to me):

  • could remove rootobjects and use an autoreleasepool wired to the universe. this is not the same pool as the default NSThread autoreleasepool
  • remove _resignAsRootObject
  • use pushToRootPool to make root objects stick.

libobjc2

What's wrong with libobjc2 so that the mulle-objc-runtime is created instead?

Forwarding a non-prototyped floating point value fails

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.

@protocol @class, @protocolclass or whatever, doesn't work as explained in the doc.

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.