Toy 1.1.6
The Toy programming language is an imperative bytecode-intermediate embedded scripting language
Loading...
Searching...
No Matches
toy_reffunction.h
Go to the documentation of this file.
1
7#ifndef TOY_REFFUNCTION_H_
8#define TOY_REFFUNCTION_H_
9
10#include <stddef.h>
11
12#include "toy_common.h"
13
14//memory allocation hook
23typedef void* (*Toy_RefFunctionAllocatorFn)(void *pointer, size_t oldSize, size_t newSize);
24
32
33//the RefFunction structure
39typedef struct Toy_RefFunction {
40 size_t length;
42 unsigned char data[];
44
45//API
55TOY_API Toy_RefFunction* Toy_createRefFunction(const void *data, size_t length);
56
63TOY_API void Toy_deleteRefFunction(Toy_RefFunction *refFunction);
64
72TOY_API int Toy_countRefFunction(Toy_RefFunction *refFunction);
73
81TOY_API size_t Toy_lengthRefFunction(Toy_RefFunction *refFunction);
82
91
100
101#endif /* TOY_REFFUNCTION_H_ */
102
Definition: toy_reffunction.h:39
unsigned char data[]
Definition: toy_reffunction.h:42
size_t length
Definition: toy_reffunction.h:40
int refCount
Definition: toy_reffunction.h:41
TOY_API int Toy_countRefFunction(Toy_RefFunction *refFunction)
Returns the total number of references to refFunction, for debugging.
void *(* Toy_RefFunctionAllocatorFn)(void *pointer, size_t oldSize, size_t newSize)
@???@
Definition: toy_reffunction.h:23
TOY_API Toy_RefFunction * Toy_copyRefFunction(Toy_RefFunction *refFunction)
Increases the reference counter of refFunction by 1, before returning the given pointer.
TOY_API void Toy_deleteRefFunction(Toy_RefFunction *refFunction)
Reduces the refFunction's reference counter by 1 and, if it reaches 0, frees the memory.
TOY_API size_t Toy_lengthRefFunction(Toy_RefFunction *refFunction)
Returns the length of the underlying bytecode of refFunction.
TOY_API void Toy_setRefFunctionAllocatorFn(Toy_RefFunctionAllocatorFn)
Conforms to and is invoked by Toy's memory API, and generally shouldn't be used.
TOY_API Toy_RefFunction * Toy_deepCopyRefFunction(Toy_RefFunction *refFunction)
Behaves identically to Toy_copyRefFunction, except that it explicitly preforms a deep copy of the int...
TOY_API Toy_RefFunction * Toy_createRefFunction(const void *data, size_t length)
Returns a new Toy_RefFunction, containing a copy of data, or NULL on error. This function also sets t...