Skip to content

Commit

Permalink
* added new types NSUIntegerAtomic and NSIntegerAtomic to facilit…
Browse files Browse the repository at this point in the history
…ate @Property code

* experimental and *untested* `MulleProxy` class added
* added NSAutoreleasePool debugging facility to dump contents into CSV format for postprocessing with sqlite or scripts
* method `-[NSThread mulleDetach]` no longer exists!
* new NSThread methods `-mulleInitWithObjectFunction:object:` for convenient ownership transfer even when using C functions
* improved the teardown code of NSThread and improved the detached case
* added various `Instance` functions, where previously `Object` was used exlusively to properly differentiate Class and Instance code
* improved and simplified tracing with `MULLE_OBJC_TRACE_ZOMBIE` and `MULLE_OBJC_TRACE_LEAK`, which eliminates the need to use he finer grained variables a lot of times
* added `MulleObjCObjectIsInstance` and a host of other introspection functions dealing with Class and Instance distinctions
  • Loading branch information
Your Name committed Dec 8, 2024
1 parent ad0f259 commit 4db6a22
Show file tree
Hide file tree
Showing 104 changed files with 3,881 additions and 391 deletions.
5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 45 additions & 66 deletions .idea/workspace.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required( VERSION 3.18) # 3.15 fails on windows

project( MulleObjC VERSION 0.24.0 LANGUAGES C)
project( MulleObjC VERSION 0.25.0 LANGUAGES C)


if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
Expand Down
13 changes: 13 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 0.25.0

* added new types `NSUIntegerAtomic` and `NSIntegerAtomic` to facilitate @property code
* experimental and *untested* `MulleProxy` class added
* added NSAutoreleasePool debugging facility to dump contents into CSV format for postprocessing with sqlite or scripts
* method `-[NSThread mulleDetach]` no longer exists!
* new NSThread methods `-mulleInitWithObjectFunction:object:` for convenient ownership transfer even when using C functions
* improved the teardown code of NSThread and improved the detached case
* added various `Instance` functions, where previously `Object` was used exlusively to properly differentiate Class and Instance code
* improved and simplified tracing with ``MULLE_OBJC_TRACE_ZOMBIE`` and ``MULLE_OBJC_TRACE_LEAK`,` which eliminates the need to use he finer grained variables a lot of times
* added `MulleObjCObjectIsInstance` and a host of other introspection functions dealing with Class and Instance distinctions


## 0.24.0


Expand Down
1 change: 1 addition & 0 deletions cmake/reflect/_Headers.cmake

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmake/reflect/_Sources.cmake

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

159 changes: 159 additions & 0 deletions src/MulleObjCIntegralType.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,163 @@ static inline char *_NSComparisonResultUTF8String( NSComparisonResult result)
}



union _NSUIntegerAtomic
{
NSUInteger value; // dont read, except when debugging
mulle_atomic_pointer_t pointer;
};

typedef union _NSUIntegerAtomic NSUIntegerAtomic;


// ivarType:
// _C_ASSIGN_ID for an ivar/property that is assign only (its a bug don't do this)
// _C_COPY_ID for an ivar/property that stores a copy
// _C_RETAIN_ID the default ivar stores the value retained
//


static inline NSUInteger NSUIntegerAtomicGet( NSUIntegerAtomic *ivar)
{
NSUInteger value;

value = (NSUInteger) _mulle_atomic_pointer_read( &ivar->pointer);
return( value);
}


static inline NSUInteger NSUIntegerAtomicUpdate( NSUIntegerAtomic *ivar,
NSUInteger value)

{
NSUInteger old;

for(;;)
{
old = (NSUInteger) _mulle_atomic_pointer_read( &ivar->pointer);

// can't cas with same value
if( old == value)
return( old);

if( _mulle_atomic_pointer_cas( &ivar->pointer, (void *) value, (void *) old))
{
return( old);
}
}
}


static inline NSUInteger NSUIntegerAtomicMaskedOr( NSUIntegerAtomic *ivar,
NSUInteger mask,
NSUInteger bits)

{
NSUInteger old;
NSUInteger value;

for(;;)
{
old = (NSUInteger) _mulle_atomic_pointer_read( &ivar->pointer);
value = (old & mask) | bits;

// can't cas with same value
if( old == value)
return( old);

if( _mulle_atomic_pointer_cas( &ivar->pointer, (void *) value, (void *) old))
{
return( old);
}
}
}

static inline NSUInteger NSUIntegerAtomicOr( NSUIntegerAtomic *ivar,
NSUInteger bits)

{
NSUInteger old;
NSUInteger value;

for(;;)
{
old = (NSUInteger) _mulle_atomic_pointer_read( &ivar->pointer);
value = old | bits;

// can't cas with same value
if( old == value)
return( old);

if( _mulle_atomic_pointer_cas( &ivar->pointer, (void *) value, (void *) old))
{
return( old);
}
}
}



static inline void NSUIntegerAtomicSet( NSUIntegerAtomic *ivar,
NSUInteger value)
{
(void) NSUIntegerAtomicUpdate( ivar, value);
}



union _NSIntegerAtomic
{
NSInteger value; // dont read, except when debugging
mulle_atomic_pointer_t pointer;
};

typedef union _NSIntegerAtomic NSIntegerAtomic;


// ivarType:
// _C_ASSIGN_ID for an ivar/property that is assign only (its a bug don't do this)
// _C_COPY_ID for an ivar/property that stores a copy
// _C_RETAIN_ID the default ivar stores the value retained
//


static inline NSInteger NSIntegerAtomicGet( NSIntegerAtomic *ivar)
{
NSInteger value;

value = (NSInteger) _mulle_atomic_pointer_read( &ivar->pointer);
return( value);
}


static inline NSInteger NSIntegerAtomicUpdate( NSIntegerAtomic *ivar,
NSInteger value)

{
NSInteger old;

for(;;)
{
old = (NSInteger) _mulle_atomic_pointer_read( &ivar->pointer);

// can't cas with same value
if( old == value)
return( old);

if( _mulle_atomic_pointer_cas( &ivar->pointer, (void *) value, (void *) old))
{
return( old);
}
}
}


static inline void NSIntegerAtomicSet( NSIntegerAtomic *ivar,
NSInteger value)
{
(void) NSIntegerAtomicUpdate( ivar, value);
}


#endif /* ns_int_type_h */
2 changes: 1 addition & 1 deletion src/MulleObjCVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define MulleObjC_version__h__


#define MULLE_OBJC_VERSION ((0UL << 20) | (24 << 8) | 0)
#define MULLE_OBJC_VERSION ((0UL << 20) | (25 << 8) | 0)

#endif

3 changes: 2 additions & 1 deletion src/class/MulleDynamicObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#import "MulleDynamicObject.h"

#import "MulleObjCProtocol.h"
#import "MulleObjCFunctions.h"

#import "import-private.h"
#include <ctype.h>
Expand Down Expand Up @@ -1949,7 +1950,7 @@ - (id) mutableCopy
MulleDynamicObject *copy;
unsigned int n;

copy = [MulleObjCObjectGetClass( self) new];
copy = [MulleObjCInstanceGetClass( self) new];

// wipe possibly copied ivars
n = mulle__pointermap_get_count( &self->__ivars);
Expand Down
3 changes: 2 additions & 1 deletion src/class/MulleObjCAutoreleasePool.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ void _mulle_objc_poolconfiguration_done( struct _mulle_objc_poolconfiguration

// for NSThread
MULLE_OBJC_GLOBAL
void mulle_objc_thread_new_poolconfiguration( struct _mulle_objc_universe *universe);
struct _mulle_objc_poolconfiguration *
mulle_objc_thread_new_poolconfiguration( struct _mulle_objc_universe *universe);

MULLE_OBJC_GLOBAL
void mulle_objc_thread_reset_poolconfiguration( struct _mulle_objc_universe *universe);
Expand Down
Loading

0 comments on commit 4db6a22

Please sign in to comment.