34#define _Class _Resource
55#pragma mark - Resource
108 self->
name = strdup(name);
123 for (
size_t i = 0; i < resourceProviders->
count &&
data == NULL; i++) {
130 for (
size_t i = 0; i < resourcePaths->
count &&
data == NULL; i++) {
136 if (stat(path->
chars, &s) == 0 && S_ISREG(s.st_mode)) {
188#pragma mark - Class lifecycle
209 const char *env = getenv(
"OBJECTIVELY_RESOURCE_PATH");
215 for (
size_t i = 0; i < paths->
count; i++) {
250 .interfaceOffset = offsetof(
Resource, interface),
251 .interfaceSize =
sizeof(ResourceInterface),
ident release(ident obj)
Atomically decrement the given Object's reference count. If the resulting reference count is 0,...
Class * _initialize(const ClassDef *def)
Initializes the given Class.
ident retain(ident obj)
Atomically increment the given Object's reference count.
#define alloc(type)
Allocate and initialize and instance of type.
#define super(type, obj, method,...)
static MutableArray * _resourceProviders
static void destroy(Class *clazz)
static MutableArray * _resourcePaths
static void initialize(Class *clazz)
Resources provide an abstraction for file and stream resources.
Data *(* ResourceProvider)(const char *name)
Applications may specify a provider function for loading via file system abstractions.
Values provide Object encapsulation for C types.
#define do_once(once, block)
Executes the given block at most one time.
ident objectAtIndex(const Array *self, int index)
size_t count
The count of elements.
ClassDefs are passed to _initialize via an archetype to initialize a Class.
The runtime representation of a Class.
ident interface
The interface of the Class.
Condition * init(Condition *self)
Initializes this Condition.
Data * dataWithBytes(const uint8_t *bytes, size_t length)
Returns a new Data by copying length of bytes.
Data * dataWithContentsOfFile(const char *path)
Returns a new Data with the contents of the file at path.
Data * initWithBytes(Data *self, const uint8_t *bytes, size_t length)
Initializes this Data by copying length of bytes.
Log * initWithName(Log *self, const char *name)
Initializes this Log with the specified name.
void addObject(MutableArray *self, const ident obj)
Adds the specified Object to this MutableArray.
void removeObject(MutableArray *self, const ident obj)
Removes the specified Object from this MutableArray.
MutableData * initWithData(MutableData *self, const Data *data)
Initializes this Data with the contents of data.
MutableData * data(void)
Returns a new MutableData.
Number * initWithValue(Number *self, double value)
Initializes this Number with the specified value.
Object is the root Class of The Objectively Class hierarchy.
Class * _Object(void)
The Object archetype.
void dealloc(Object *self)
Frees all resources held by this Object.
Resources provide an abstraction for file and stream resources.
void removeResourceProvider(ResourceProvider provider)
Removes the specified ResourceProvider.
Resource * resourceWithName(const char *name)
Returns a new Resource with the specified name.
void addResourceProvider(ResourceProvider provider)
Adds the specified ResourceProvider.
void removeResourcePath(const char *path)
Removes the specified Resource path.
Data * data
The resource data.
void addResourcePath(const char *path)
Adds the specified Resource path.
Class * _Resource(void)
The Resource archetype.
char * name
The resource name.
char * chars
The backing null-terminated UTF-8 encoded character array.
Array * componentsSeparatedByCharacters(const String *self, const char *chars)
Returns the components of this String that were separated by chars.
OBJECTIVELY_EXPORT String * str(const char *fmt,...)
A convenience function for instantiating Strings.
String * stringWithCharacters(const char *chars)
Returns a new String by copying chars.
Values provide Object encapsulation for C types.
ident value
The backing value.