git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

HexFiend/HexFiend_2_Framework_Prefix.pch

      1 //
      2 // Prefix header for all source files of the 'HexFiend_2' target in the 'HexFiend_2' project
      3 //
      4 
      5 #ifdef __OBJC__
      6     #import <Cocoa/Cocoa.h>
      7     #import <HexFiend/HFTypes.h>
      8 #endif
      9 
     10 #define PRIVATE_EXTERN __private_extern__
     11 
     12 #include <assert.h>
     13 
     14 #if ! NDEBUG
     15 #define HFASSERT(a) assert(a)
     16 #else
     17 #define HFASSERT(a) if (0 && ! (a)) abort() 
     18 #endif
     19 
     20 
     21 #define UNIMPLEMENTED_VOID() [NSException raise:NSGenericException \
     22                                          format:@"Message %@ sent to instance of class %@, "\
     23                                                 @"which does not implement that method",\
     24                                                 NSStringFromSelector(_cmd), [[self class] description]]
     25 
     26 #define UNIMPLEMENTED() UNIMPLEMENTED_VOID(); return 0
     27 
     28 /* Macro to "use" a variable to prevent unused variable warnings. */
     29 #define USE(x) ((void)(x))
     30 
     31 #define check_malloc(x) ({ size_t _count = (x); void *_result = malloc(_count); if(!_result) { fprintf(stderr, "Out of memory allocating %lu bytes\n", (unsigned long)_count); exit(EXIT_FAILURE); } _result; })
     32 #define check_calloc(x) ({ size_t _count = (x); void *_result = calloc(_count, 1); if(!_result) { fprintf(stderr, "Out of memory allocating %lu bytes\n", (unsigned long)_count); exit(EXIT_FAILURE); } _result; })
     33 #define check_realloc(p, x) ({ size_t _count = (x); void *_result = realloc((p), x); if(!_result) { fprintf(stderr, "Out of memory reallocating %lu bytes\n", (unsigned long)_count); exit(EXIT_FAILURE); } _result; })
     34 
     35 #if ! NDEBUG
     36 #define REQUIRE_NOT_NULL(a) do { \
     37 	if ((a)==NULL) {\
     38 		fprintf(stderr, "REQUIRE_NOT_NULL failed: NULL value for parameter " #a " on line %d in file %s\n", __LINE__, __FILE__);\
     39 			abort();\
     40 	}\
     41 } while (0)
     42 
     43 #define EXPECT_CLASS(e, c) do { \
     44 	if (! [(e) isKindOfClass:[c class]]) {\
     45 		fprintf(stderr, "EXPECT_CLASS failed: Expression " #e " is %s on line %d in file %s\n", (e) ? "(nil)" : [[e description] UTF8String], __LINE__, __FILE__);\
     46 			abort();\
     47 	}\
     48 } while (0)
     49 
     50 #else
     51 #define REQUIRE_NOT_NULL(a) USE(a)
     52 #define EXPECT_CLASS(e, c) USE(e)
     53 #endif
     54 
     55 #define FOREACH(type, var, exp) for (type var in (exp))
     56 
     57 #define NEW_ARRAY(type, name, number) \
     58     type name ## static_ [256];\
     59     type * name = ((number) <= 256 ? name ## static_ : check_malloc((number) * sizeof(type)))
     60     
     61 #define FREE_ARRAY(name) \
     62     if (name != name ## static_) free(name)
     63 
     64 #if !defined(MIN)
     65     #define MIN(A,B)	({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; })
     66 #endif
     67 
     68 #if !defined(MAX)
     69     #define MAX(A,B)	({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
     70 #endif
     71 
     72 //How many bytes should we read at a time when doing a find/replace?
     73 #define SEARCH_CHUNK_SIZE 32768
     74 
     75 //What's the smallest clipboard data size we should offer to avoid copying when quitting?  This is 5 MB
     76 #define MINIMUM_PASTEBOARD_SIZE_TO_WARN_ABOUT (5UL << 20)
     77 
     78 //What's the largest clipboard data size we should support exporting (at all?)  This is 500 MB.  Note that we can still copy more data than this internally, we just can't put it in, say, TextEdit.
     79 #define MAXIMUM_PASTEBOARD_SIZE_TO_EXPORT (500UL << 20)
     80 
     81 // When we save a file, and other byte arrays need to break their dependencies on the file by copying some of its data into memory, what's the max amount we should copy (per byte array)?  We currently don't show any progress for this, so this should be a smaller value
     82 #define MAX_MEMORY_TO_USE_FOR_BREAKING_FILE_DEPENDENCIES_ON_SAVE (16 * 1024 * 1024)
     83 
     84 #ifdef __OBJC__
     85     #import <HexFiend/HFFunctions.h>
     86     #import "HFFunctions_Private.h"
     87 #endif
     88 
     89 #ifndef __has_feature      // Optional.
     90 #define __has_feature(x) 0 // Compatibility with non-clang compilers.
     91 #endif
     92 
     93 #ifndef NS_RETURNS_RETAINED
     94 #if __has_feature(attribute_ns_returns_retained)
     95 #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
     96 #else
     97 #define NS_RETURNS_RETAINED
     98 #endif
     99 #endif

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.