picofuse-objc

Classes | Macros | Typedefs | Enumerations | Functions
Foundation Framework

Foundational classes and types. More...

Collaboration diagram for Foundation Framework:

Classes

protocol  <NXArchiving>
 Objects which can be written to an archive and read back. More...
 
class  NXArchive
 Writes objects out as JSON or binary, and reads them back. More...
 
class  NXArgument
 A flag which can be given on the command line, as –name or -n, which NXEnvironment parses. More...
 
class  NXArray
 An ordered list of objects, which can be changed. More...
 
class  NXAtomic
 A 32-bit unsigned number, which threads can read and change without a lock. More...
 
class  NXAutoreleasePool
 A pool of objects, which are released when the pool is drained. More...
 
protocol  <NXCollection>
 Objects which hold other objects, such as arrays, which can be gone through with a for...in loop. More...
 
class  NXColor
 A color: red, green and blue, with an opacity. More...
 
class  NXCondition
 A lock, and a condition which threads holding it can wait for. More...
 
class  NXConstantString
 The class of constant strings, such as @"string". More...
 
class  NXData
 Bytes, which can be added to. More...
 
class  NXDate
 A date and time, to the nanosecond, with the offset of a time zone. More...
 
class  NXEnvironment
 The command line, and what the program and the system it runs on are. More...
 
protocol  <NXFastEnumeration>
 Objects which can be gone through with a for...in loop. More...
 
struct  NXPoint
 A point, in pixels from the top left. More...
 
struct  NXSize
 A size, in pixels. More...
 
struct  NXRect
 A rectangle: its top left, and its size. More...
 
class  NXLock
 A lock, which one thread at a time can hold. More...
 
protocol  <NXLocking>
 Objects which can be locked by one thread at a time. More...
 
class  NXMap
 Objects found by keys, which can be changed. More...
 
class  NXMutableString
 A string which can be changed. More...
 
class  NXNull
 A null value, as an object, for where nil can't be used. More...
 
class  NXNumber
 An integer, floating point or boolean value, as an object. More...
 
class  NXObject
 The base class for objects in the Foundation framework. More...
 
class  NXScanner
 Reads tokens, one at a time, from a string or a stream. More...
 
class  NXStream
 A stream of bytes, which can be read or written. More...
 
class  NXString
 A string of UTF-8 text. More...
 
class  NXThread
 Runs methods in threads, and provides information about cores. More...
 
class  NXWaitGroup
 A count of work to be done, which threads can wait for to reach zero. More...
 
class  NXZone
 A region of memory, from which objects and other memory can be allocated. More...
 

Macros

#define NXNanosecond   ((NXDuration)1)
 One nanosecond.
 
#define NXMicrosecond   (1000 * NXNanosecond)
 One microsecond.
 
#define NXMillisecond   (1000 * NXMicrosecond)
 One millisecond.
 
#define NXSecond   (1000 * NXMillisecond)
 One second.
 
#define NXMinute   (60 * NXSecond)
 One minute.
 
#define NXHour   (60 * NXMinute)
 One hour.
 
#define NXDay   (24 * NXHour)
 One day of 24 hours.
 
#define NXHashMaxSize   SYS_HASH_SIZE
 The size in bytes of the largest hash.
 
#define NXLogDepthMax   4
 How deeply logs can be nested, as when a description itself logs, after which a line saying so is written instead.
 
#define NXDebug(format, ...)   _NXDebug(format, ##__VA_ARGS__)
 Writes a formatted line to the standard output, after "[DEBUG] ", in a debug build. More...
 
#define NXNotFound   SIZE_MAX
 Returned by methods which return where something is, when it isn't found.
 
#define NXStreamEnd   SYS_IOSTREAM_EOF
 Returned by peek when there's nothing to read.
 

Typedefs

typedef int64_t NXDuration
 A length of time, in nanoseconds, which may be negative. More...
 
typedef struct __objcFastEnumerationState NXFastEnumerationState
 The state of a for...in loop, passed to countByEnumeratingWithState:objects:count:.
 

Enumerations

enum  NXArchiveFormat { NXArchiveFormatJSON, NXArchiveFormatBinary }
 The formats of an archive. More...
 
enum  NXComparisonResult { NXComparisonAscending = -1, NXComparisonSame = 0, NXComparisonDescending = 1 }
 The order of two objects. More...
 
enum  NXDateFormat { NXDateFormatISO8601 = sys_date_format_iso8601, NXDateFormatRFC2822 = sys_date_format_rfc2822, NXDateFormatLog = sys_date_format_log }
 Ways of writing a date. More...
 
enum  NXHashAlgorithm { NXHashAlgorithmMD5 = sys_hash_md5, NXHashAlgorithmSHA256 = sys_hash_sha256 }
 Algorithms which hash data. More...
 
enum  NXScannerFlags {
  NXScannerNone = sys_scanner_none, NXScannerEscapes = sys_scanner_escapes, NXScannerNewlines = sys_scanner_newlines, NXScannerKeywords = sys_scanner_keywords,
  NXScannerKeywordsWithUnderscores, NXScannerKeywordsWithDashes, NXScannerQuotesSingle = sys_scanner_quotes_single, NXScannerQuotesDouble = sys_scanner_quotes_double,
  NXScannerQuotes = sys_scanner_quotes, NXScannerCommentsHash = sys_scanner_comments_hash, NXScannerCommentsSlash = sys_scanner_comments_slash, NXScannerComments = sys_scanner_comments,
  NXScannerNumbers = sys_scanner_numbers, NXScannerNumbersOctal = sys_scanner_numbers_octal, NXScannerNumbersBinary = sys_scanner_numbers_binary, NXScannerNumbersHex = sys_scanner_numbers_hex,
  NXScannerNumbersFloat = sys_scanner_numbers_float, NXScannerDatesISO8601 = sys_scanner_dates_iso8601, NXScannerDates = sys_scanner_dates, NXScannerDurations = sys_scanner_durations
}
 Which tokens a scanner recognizes, besides runs of spaces, letters and digits. More...
 
enum  NXScannerClass {
  NXScannerClassOther = sys_scanner_other, NXScannerClassSpace = sys_scanner_space, NXScannerClassDigit = sys_scanner_digit, NXScannerClassAlpha = sys_scanner_alpha,
  NXScannerClassPunct = sys_scanner_punct, NXScannerClassSymbol = sys_scanner_symbol, NXScannerClassControl = sys_scanner_control, NXScannerClassEscape = sys_scanner_escape,
  NXScannerClassNewline = sys_scanner_newline, NXScannerClassKeyword = sys_scanner_keyword, NXScannerClassString = sys_scanner_string, NXScannerClassComment = sys_scanner_comment,
  NXScannerClassNumber = sys_scanner_number, NXScannerClassDate = sys_scanner_date, NXScannerClassDuration = sys_scanner_duration
}
 The class of a token. More...
 

Functions

uint32_t NXDurationMilliseconds (NXDuration duration)
 Converts a duration to milliseconds, as used by picofuse. More...
 
NXDuration NXDurationTimestamp (void)
 Returns the time since the program started. More...
 
NXString * NXDurationDescription (NXDuration duration, NXDuration truncate)
 Returns a description of a duration, such as "1d2h3m4s5ms6us7ns", which NXDurationFromString reads. More...
 
BOOL NXDurationFromString (NXString *string, NXDuration *duration)
 Reads a duration from a string. More...
 
static NXPoint NXMakePoint (int16_t x, int16_t y)
 Returns a point.
 
static NXSize NXMakeSize (uint16_t width, uint16_t height)
 Returns a size.
 
static NXRect NXMakeRect (int16_t x, int16_t y, uint16_t width, uint16_t height)
 Returns a rectangle.
 
size_t NXLog (NXString *format,...)
 Writes a formatted line to the standard output. More...
 
size_t NXLogv (NXString *format, va_list args)
 Writes a formatted line to the standard output, from arguments.
 
int32_t NXRandInt32 (void)
 Returns a random 32-bit signed integer.
 
uint32_t NXRandUnsignedInt32 (void)
 Returns a random 32-bit unsigned integer.
 
int64_t NXRandInt64 (void)
 Returns a random 64-bit signed integer.
 
uint64_t NXRandUnsignedInt64 (void)
 Returns a random 64-bit unsigned integer.
 

Detailed Description

Foundational classes and types.

Threads and mutable objects

Macro Definition Documentation

◆ NXDebug

#define NXDebug (   format,
  ... 
)    _NXDebug(format, ##__VA_ARGS__)

Writes a formatted line to the standard output, after "[DEBUG] ", in a debug build.

As NXLog, but in a release build, where NDEBUG is defined, it does nothing, and its arguments aren't evaluated.

Definition at line 51 of file NXLog.h.

Typedef Documentation

◆ NXDuration

typedef int64_t NXDuration

A length of time, in nanoseconds, which may be negative.

Durations are made by multiplying the constants for units of time. For example, 90 * NXSecond or NXMinute + 30 * NXSecond. They can be up to about 292 years.

Definition at line 17 of file NXDuration.h.

Enumeration Type Documentation

◆ NXArchiveFormat

The formats of an archive.

Enumerator
NXArchiveFormatJSON 

JSON, with keys, and no classes unless they differ.

NXArchiveFormatBinary 

Values in order, little-endian, with a hash of each class.

Definition at line 13 of file NXArchive.h.

13  {
Values in order, little-endian, with a hash of each class.
Definition: NXArchive.h:15
NXArchiveFormat
The formats of an archive.
Definition: NXArchive.h:13
JSON, with keys, and no classes unless they differ.
Definition: NXArchive.h:14

◆ NXComparisonResult

The order of two objects.

Enumerator
NXComparisonAscending 

The first is before the second.

NXComparisonSame 

They're in the same place.

NXComparisonDescending 

The first is after the second.

Definition at line 13 of file NXComparisonResult.h.

13  {
15  NXComparisonSame = 0,
The first is after the second.
NXComparisonResult
The order of two objects.
The first is before the second.
They&#39;re in the same place.

◆ NXDateFormat

Ways of writing a date.

Enumerator
NXDateFormatISO8601 

"2026-09-06T11:37:05Z", or with an offset such as "+01:00"

NXDateFormatRFC2822 

"Sun, 06 Sep 2026 11:37:05 GMT", as in HTTP, always in UTC

NXDateFormatLog 

"2026-09-06 11:37:05", always in UTC

Definition at line 17 of file NXDate.h.

17  {
18  NXDateFormatISO8601 = sys_date_format_iso8601,
19  NXDateFormatRFC2822 = sys_date_format_rfc2822,
21  NXDateFormatLog = sys_date_format_log,
23 } NXDateFormat;
"Sun, 06 Sep 2026 11:37:05 GMT", as in HTTP, always in UTC
Definition: NXDate.h:20
NXDateFormat
Ways of writing a date.
Definition: NXDate.h:17
"2026-09-06 11:37:05", always in UTC
Definition: NXDate.h:22
"2026-09-06T11:37:05Z", or with an offset such as "+01:00"
Definition: NXDate.h:18

◆ NXHashAlgorithm

Algorithms which hash data.

MD5 isn't secure, so it's only for uses such as checksums.

Enumerator
NXHashAlgorithmMD5 

MD5, which is 16 bytes.

NXHashAlgorithmSHA256 

SHA-256, which is 32 bytes.

Definition at line 16 of file NXHashAlgorithm.h.

16  {
17  NXHashAlgorithmMD5 = sys_hash_md5,
18  NXHashAlgorithmSHA256 = sys_hash_sha256,
SHA-256, which is 32 bytes.
NXHashAlgorithm
Algorithms which hash data.
MD5, which is 16 bytes.

◆ NXScannerClass

The class of a token.

Punctuation, symbols, control characters and line feeds are one character each; the others can be longer.

Enumerator
NXScannerClassOther 

Not one of the others, or no token.

NXScannerClassSpace 

Spaces.

NXScannerClassDigit 

Digits.

NXScannerClassAlpha 

Letters.

NXScannerClassPunct 

A punctuation character.

NXScannerClassSymbol 

A symbol, such as = or +.

NXScannerClassControl 

A control character.

NXScannerClassEscape 

An escape (NXScannerEscapes)

NXScannerClassNewline 

A line feed (NXScannerNewlines)

NXScannerClassKeyword 

A keyword (NXScannerKeywords)

NXScannerClassString 

A string, with its quotes (NXScannerQuotes)

NXScannerClassComment 

A comment (NXScannerComments)

NXScannerClassNumber 

A number (NXScannerNumbers)

NXScannerClassDate 

A date (NXScannerDates)

NXScannerClassDuration 

A duration (NXScannerDurations)

Definition at line 51 of file NXScanner.h.

51  {
52  NXScannerClassOther = sys_scanner_other,
53  NXScannerClassSpace = sys_scanner_space,
54  NXScannerClassDigit = sys_scanner_digit,
55  NXScannerClassAlpha = sys_scanner_alpha,
56  NXScannerClassPunct = sys_scanner_punct,
57  NXScannerClassSymbol = sys_scanner_symbol,
58  NXScannerClassControl = sys_scanner_control,
59  NXScannerClassEscape = sys_scanner_escape,
60  NXScannerClassNewline = sys_scanner_newline,
61  NXScannerClassKeyword = sys_scanner_keyword,
62  NXScannerClassString = sys_scanner_string,
63  NXScannerClassComment = sys_scanner_comment,
64  NXScannerClassNumber = sys_scanner_number,
65  NXScannerClassDate = sys_scanner_date,
66  NXScannerClassDuration = sys_scanner_duration,
A date (NXScannerDates)
Definition: NXScanner.h:65
Not one of the others, or no token.
Definition: NXScanner.h:52
A keyword (NXScannerKeywords)
Definition: NXScanner.h:61
NXScannerClass
The class of a token.
Definition: NXScanner.h:51
A punctuation character.
Definition: NXScanner.h:56
A string, with its quotes (NXScannerQuotes)
Definition: NXScanner.h:62
A symbol, such as = or +.
Definition: NXScanner.h:57
An escape (NXScannerEscapes)
Definition: NXScanner.h:59
A control character.
Definition: NXScanner.h:58
A number (NXScannerNumbers)
Definition: NXScanner.h:64
A duration (NXScannerDurations)
Definition: NXScanner.h:66
A line feed (NXScannerNewlines)
Definition: NXScanner.h:60
A comment (NXScannerComments)
Definition: NXScanner.h:63

◆ NXScannerFlags

Which tokens a scanner recognizes, besides runs of spaces, letters and digits.

Combine them with |. Those such as NXScannerNumbersHex include the one they extend.

Enumerator
NXScannerNone 

Only runs of spaces, letters and digits.

NXScannerEscapes 

Escapes such as \n and \u0041.

NXScannerNewlines 

Line feeds, apart from other spaces.

NXScannerKeywords 

Letters followed by letters and digits.

NXScannerKeywordsWithUnderscores 

Keywords which can include _.

NXScannerKeywordsWithDashes 

Keywords which can include -.

NXScannerQuotesSingle 

Strings in '.

NXScannerQuotesDouble 

Strings in ".

NXScannerQuotes 

Strings in ' or ".

NXScannerCommentsHash 

Comments from # to a line end.

NXScannerCommentsSlash 

Comments from // to a line end.

NXScannerComments 

Comments from # or //.

NXScannerNumbers 

Integers, with a sign.

NXScannerNumbersOctal 

And 0o17 or 017.

NXScannerNumbersBinary 

And 0b101.

NXScannerNumbersHex 

And 0x1F.

NXScannerNumbersFloat 

And 3.14 or 1e-3.

NXScannerDatesISO8601 

Dates such as 2026-09-06T11:37:05Z.

NXScannerDates 

Dates in every format scanned.

NXScannerDurations 

Durations such as 1h30m or 1.5s.

Definition at line 17 of file NXScanner.h.

17  {
18  NXScannerNone = sys_scanner_none,
19  NXScannerEscapes = sys_scanner_escapes,
20  NXScannerNewlines = sys_scanner_newlines,
21  NXScannerKeywords = sys_scanner_keywords,
23  sys_scanner_keywords_withunderscores,
25  sys_scanner_keywords_withdashes,
26  NXScannerQuotesSingle = sys_scanner_quotes_single,
27  NXScannerQuotesDouble = sys_scanner_quotes_double,
28  NXScannerQuotes = sys_scanner_quotes,
29  NXScannerCommentsHash = sys_scanner_comments_hash,
30  NXScannerCommentsSlash = sys_scanner_comments_slash,
31  NXScannerComments = sys_scanner_comments,
32  NXScannerNumbers = sys_scanner_numbers,
33  NXScannerNumbersOctal = sys_scanner_numbers_octal,
34  NXScannerNumbersBinary = sys_scanner_numbers_binary,
35  NXScannerNumbersHex = sys_scanner_numbers_hex,
36  NXScannerNumbersFloat = sys_scanner_numbers_float,
37  NXScannerDatesISO8601 = sys_scanner_dates_iso8601,
38  NXScannerDates = sys_scanner_dates,
39  NXScannerDurations = sys_scanner_durations,
And 3.14 or 1e-3.
Definition: NXScanner.h:36
Dates such as 2026-09-06T11:37:05Z.
Definition: NXScanner.h:37
Keywords which can include _.
Definition: NXScanner.h:22
Only runs of spaces, letters and digits.
Definition: NXScanner.h:18
Dates in every format scanned.
Definition: NXScanner.h:38
Comments from # or //.
Definition: NXScanner.h:31
Comments from // to a line end.
Definition: NXScanner.h:30
NXScannerFlags
Which tokens a scanner recognizes, besides runs of spaces, letters and digits.
Definition: NXScanner.h:17
Line feeds, apart from other spaces.
Definition: NXScanner.h:20
Strings in ".
Definition: NXScanner.h:27
Durations such as 1h30m or 1.5s.
Definition: NXScanner.h:39
And 0x1F.
Definition: NXScanner.h:35
And 0o17 or 017.
Definition: NXScanner.h:33
Strings in &#39;.
Definition: NXScanner.h:26
Strings in &#39; or ".
Definition: NXScanner.h:28
Letters followed by letters and digits.
Definition: NXScanner.h:21
Escapes such as \n and \u0041.
Definition: NXScanner.h:19
Keywords which can include -.
Definition: NXScanner.h:24
Comments from # to a line end.
Definition: NXScanner.h:29
Integers, with a sign.
Definition: NXScanner.h:32

Function Documentation

◆ NXDurationDescription()

NXString* NXDurationDescription ( NXDuration  duration,
NXDuration  truncate 
)

Returns a description of a duration, such as "1d2h3m4s5ms6us7ns", which NXDurationFromString reads.

Parameters
durationThe duration.
truncateThe unit to which the duration is truncated, or zero for none.
Returns
The description, which is "0s" if the duration is truncated to zero. It's in the current autorelease pool.

◆ NXDurationFromString()

BOOL NXDurationFromString ( NXString *  string,
NXDuration *  duration 
)

Reads a duration from a string.

Parameters
stringThe whole of it is a duration: an optional sign, then one or more amounts, each a number and a unit, without spaces, such as "1h30m", "1.5s", "-250ms" or "1d2h3m". The units are "d", "day" or "days", "h", "m", "s", "ms", "us" or "µs", and "ns". Any part of a nanosecond is dropped.
durationWhere to put the duration, which isn't changed if it can't be read.
Returns
YES if it was read, or NO if it isn't a duration or doesn't fit, which is about 292 years.

◆ NXDurationMilliseconds()

uint32_t NXDurationMilliseconds ( NXDuration  duration)

Converts a duration to milliseconds, as used by picofuse.

Parameters
durationThe duration.
Returns
The number of milliseconds, rounded up, so that only a duration which is zero or negative returns zero. It's UINT32_MAX if the duration is longer than that.

◆ NXDurationTimestamp()

NXDuration NXDurationTimestamp ( void  )

Returns the time since the program started.

Returns
The duration, in whole milliseconds. It never decreases, so the difference between two of these is the time between them.

◆ NXLog()

size_t NXLog ( NXString *  format,
  ... 
)

Writes a formatted line to the standard output.

Parameters
formatThe format, as for +[NXString stringWithFormat:], which can include %@ for the description of an object and t for a duration. A line feed is added.
Returns
The number of bytes written, or zero if there isn't enough memory.

It's formatted before anything is written, so the description of an object can itself log, and its line is written first. A line of up to 127 bytes is formatted once, but a longer one is formatted twice, to find its length, so the descriptions in it are found twice. Logs nested more than NXLogDepthMax deep, as when a description logs itself, write a line saying so instead of recursing. Lines from threads at the same time aren't mixed. Don't log from an interrupt.