Objectively 1.0.0
Ultra-lightweight object oriented framework for GNU C.
Properties | Methods | Protected Attributes
Boole Struct Reference

#include <Boole.h>

Overview

A wrapper for placing boolean primitives into collections, etc.

Definition at line 41 of file Boole.h.

Inheritance diagram for Boole:
Object

Properties

Object object
 The superclass. More...
 
_Bool value
 The backing _Bool. More...
 
- Properties inherited from Object
Classclazz
 Every instance of Object begins with a pointer to its Class. More...
 

Methods

Class_Boole (void)
 The Boole archetype. More...
 
BooleFalse (void)
 
BooleTrue (void)
 
Boolevalueof (_Bool value)
 
- Methods inherited from Object
Class_Object (void)
 The Object archetype. More...
 
Objectcopy (const Object *self)
 Creates a shallow copy of this Object. More...
 
void dealloc (Object *self)
 Frees all resources held by this Object. More...
 
Stringdescription (const Object *self)
 
int hash (const Object *self)
 
Objectinit (Object *self)
 Initializes this Object. More...
 
_Bool isEqual (const Object *self, const Object *other)
 Tests equality of the other Object. More...
 
_Bool isKindOfClass (const Object *self, const Class *clazz)
 Tests for Class hierarchy membership. More...
 

Protected Attributes

BooleInterface * interface
 The interface. More...
 
- Protected Attributes inherited from Object
ObjectInterface * interface
 The interface. More...
 

Property Details

◆ interface

BooleInterface* Boole::interface
protected

The interface.

Definition at line 52 of file Boole.h.

◆ object

Object Boole::object

The superclass.

Definition at line 46 of file Boole.h.

◆ value

_Bool Boole::value

The backing _Bool.

Definition at line 57 of file Boole.h.

Method Details

◆ _Boole()

Class * _Boole ( void  )

The Boole archetype.

Returns
The Boole Class.

Definition at line 125 of file Boole.c.

125 {
126 static Class *clazz;
127 static Once once;
128
129 do_once(&once, {
130 clazz = _initialize(&(const ClassDef) {
131 .name = "Boole",
132 .superclass = _Object(),
133 .instanceSize = sizeof(Boole),
134 .interfaceOffset = offsetof(Boole, interface),
135 .interfaceSize = sizeof(BooleInterface),
137 .destroy = destroy,
138 });
139 });
140
141 return clazz;
142}
static void destroy(Class *clazz)
Definition: Boole.c:115
static void initialize(Class *clazz)
Definition: Boole.c:102
Class * _initialize(const ClassDef *def)
Initializes the given Class.
Definition: Class.c:91
long Once
The Once type.
Definition: Once.h:37
#define do_once(once, block)
Executes the given block at most one time.
Definition: Once.h:43
A wrapper for placing boolean primitives into collections, etc.
Definition: Boole.h:41
BooleInterface * interface
The interface.
Definition: Boole.h:52
ClassDefs are passed to _initialize via an archetype to initialize a Class.
Definition: Class.h:41
The runtime representation of a Class.
Definition: Class.h:95
Class * clazz
Every instance of Object begins with a pointer to its Class.
Definition: Object.h:51
Class * _Object(void)
The Object archetype.
Definition: Object.c:136

◆ False()

Boole * False ( void  )
Returns
The false Boole.

Definition at line 59 of file Boole.c.

59 {
60
61 static Once once;
62
63 do_once(&once, {
64 _False = (Boole *) $((Object *) alloc(Boole), init);
65 _False->value = false;
66 });
67
68 return _False;
69}
static Boole * _False
Definition: Boole.c:53
#define alloc(type)
Allocate and initialize and instance of type.
Definition: Class.h:159
_Bool value
The backing _Bool.
Definition: Boole.h:57
Object is the root Class of The Objectively Class hierarchy.
Definition: Object.h:46
Object * init(Object *self)
Initializes this Object.
Definition: Object.c:83

◆ True()

Boole * True ( void  )
Returns
The true Boole.

Definition at line 77 of file Boole.c.

77 {
78
79 static Once once;
80
81 do_once(&once, {
82 _True = (Boole *) $((Object *) alloc(Boole), init);
83 _True->value = true;
84 });
85
86 return _True;
87}
static Boole * _True
Definition: Boole.c:71

◆ valueof()

Boole * valueof ( _Bool  value)
Parameters
valueThe boolean.
Returns
The Boole representation of value.

Definition at line 93 of file Boole.c.

93 {
94 return value ? $$(Boole, True) : $$(Boole, False);
95}
Boole * False(void)
Definition: Boole.c:59
Boole * True(void)
Definition: Boole.c:77

The documentation for this struct was generated from the following files: