Various tidies.

main
theraven 16 years ago
parent 718c9398e5
commit 569a48650d

@ -77,7 +77,7 @@ struct psy_block_byref_obj {
struct psy_block_byref_obj *forwarding; struct psy_block_byref_obj *forwarding;
int flags; //refcount; int flags; //refcount;
int size; int size;
void (*byref_keep)(struct psy_block_byref_obj *dst, struct psy_block_byref_obj *src); void (*byref_keep)(struct psy_block_byref_obj *dst, const struct psy_block_byref_obj *src);
void (*byref_dispose)(struct psy_block_byref_obj *); void (*byref_dispose)(struct psy_block_byref_obj *);
}; };
@ -88,7 +88,7 @@ struct psy_block_byref_obj {
* the other choices which are mutually exclusive. Only in a Block copy helper * the other choices which are mutually exclusive. Only in a Block copy helper
* will one see BLOCK_FIELD_IS_BYREF. * will one see BLOCK_FIELD_IS_BYREF.
*/ */
void _Block_object_assign(void *destAddr, void *object, const int flags) void _Block_object_assign(void *destAddr, const void *object, const int flags)
{ {
//printf("Copying %x to %x with flags %x\n", object, destAddr, flags); //printf("Copying %x to %x with flags %x\n", object, destAddr, flags);
// FIXME: Needs to be implemented // FIXME: Needs to be implemented
@ -99,7 +99,7 @@ void _Block_object_assign(void *destAddr, void *object, const int flags)
{ {
if(flags & BLOCK_FIELD_IS_BYREF) if(flags & BLOCK_FIELD_IS_BYREF)
{ {
struct psy_block_byref_obj *src = object; const struct psy_block_byref_obj *src = object;
struct psy_block_byref_obj **dst = destAddr; struct psy_block_byref_obj **dst = destAddr;
/* I followed Apple's specs saying byref's "flags" field should /* I followed Apple's specs saying byref's "flags" field should
@ -119,13 +119,13 @@ void _Block_object_assign(void *destAddr, void *object, const int flags)
src->byref_keep(*dst, src); src->byref_keep(*dst, src);
} }
} }
else *dst = src; else *dst = (struct psy_block_byref_obj*)src;
(*dst)->flags++; (*dst)->flags++;
} }
else if((flags & BLOCK_FIELD_IS_BLOCK) == BLOCK_FIELD_IS_BLOCK) else if((flags & BLOCK_FIELD_IS_BLOCK) == BLOCK_FIELD_IS_BLOCK)
{ {
struct psy_block_literal *src = object; struct psy_block_literal *src = (struct psy_block_literal*)object;
struct psy_block_literal **dst = destAddr; struct psy_block_literal **dst = destAddr;
*dst = Block_copy(src); *dst = Block_copy(src);
@ -145,7 +145,7 @@ void _Block_object_assign(void *destAddr, void *object, const int flags)
* The same flags used in the copy helper should be used for each call * The same flags used in the copy helper should be used for each call
* generated to this function: * generated to this function:
*/ */
void _Block_object_dispose(void *object, const int flags) void _Block_object_dispose(const void *object, const int flags)
{ {
// FIXME: Needs to be implemented // FIXME: Needs to be implemented
if(flags & BLOCK_FIELD_IS_WEAK) if(flags & BLOCK_FIELD_IS_WEAK)
@ -155,7 +155,8 @@ void _Block_object_dispose(void *object, const int flags)
{ {
if(flags & BLOCK_FIELD_IS_BYREF) if(flags & BLOCK_FIELD_IS_BYREF)
{ {
struct psy_block_byref_obj *src = object; struct psy_block_byref_obj *src =
(struct psy_block_byref_obj*)object;
src->flags--; src->flags--;
if((src->flags & ~BLOCK_HAS_COPY_DISPOSE) == 0) if((src->flags & ~BLOCK_HAS_COPY_DISPOSE) == 0)
@ -168,7 +169,7 @@ void _Block_object_dispose(void *object, const int flags)
} }
else if((flags & ~BLOCK_BYREF_CALLER) == BLOCK_FIELD_IS_BLOCK) else if((flags & ~BLOCK_BYREF_CALLER) == BLOCK_FIELD_IS_BLOCK)
{ {
struct psy_block_literal *src = object; struct psy_block_literal *src = (struct psy_block_literal*)object;
Block_release(src); Block_release(src);
} }
else if((flags & ~BLOCK_BYREF_CALLER) == BLOCK_FIELD_IS_OBJECT) else if((flags & ~BLOCK_BYREF_CALLER) == BLOCK_FIELD_IS_OBJECT)

@ -10,10 +10,10 @@
// that it doesn't impact the rest of the program. // that it doesn't impact the rest of the program.
#ifndef _GNU_SOURCE #ifndef _GNU_SOURCE
# define _GNU_SOURCE 1 # define _GNU_SOURCE 1
# include <unwind.h> # include "unwind.h"
# undef _GNU_SOURCE # undef _GNU_SOURCE
#else #else
# include <unwind.h> # include "unwind.h"
#endif #endif
typedef unsigned char *dw_eh_ptr_t; typedef unsigned char *dw_eh_ptr_t;

@ -1,6 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <objc/runtime.h> #include "objc/runtime.h"
#include "class.h" #include "class.h"
#include "ivar.h" #include "ivar.h"

Loading…
Cancel
Save