-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathArray.h
109 lines (89 loc) · 3.68 KB
/
Array.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Copyright Kabuki Starship� <kabukistarship.com>.
#pragma once
#ifndef SCRIPT2_ARRAY_DECL
#define SCRIPT2_ARRAY_DECL
#include <_Config.h>
namespace _ {
/* Fills the array with the given fill_char identical to memset. */
LIB_MEMBER CHA* RAMFill(void* origin, ISW bytes, CHA fill_char = 0);
} //< namespace _
#if SEAM >= SCRIPT2_STACK
/* RAMFactory manages memory for ASCII Objects.
@return A word-aligned boofer, rounding up if unaligned.
@param autoject A contiguous memory auto-object.
@param bytes Autoject size in bytes. */
typedef IUW* (*RAMFactory)(IUW* autoject, ISW size);
namespace _ {
/* ASCII OBJ and RAMFactory. */
struct Autoject {
RAMFactory ram; //< Autoject Factory function pointer.
IUW* origin; //< Pointer to the Autoject.
};
enum RAMFactoryFunction {
RAMFactoryDelete = 0, //< Factory function deletes an OBJ.
RAMFactoryNew = 1, //< Factory function checks if the size can double.
RAMFactoryGrow = 2, //< Factory function double OBJ size.
RAMFactoryClone = 3, //< Factory function clones the OBJ.
RAMFactoryName = 4, //< Factory function gets the info string.
RAMFactoryFunctionCount = 5, //< Factory function count.
};
enum RAMFactoryError {
RAMFactorySuccess = 0, //< Factory operation completed successfully error.
RAMFactoryNil = 1, //< Factory missing error.
RAMFactoryNilOBJ = 2, //< Factory found nil obj.origin pointer error.
RAMFactoryNilArg = 3, //< Factory arg nil error.
FactoryCantGrow = 4, //< Factory can't grow.
RAMFactorySizeInvalid = 5, //< Factory size invalid.
RAMFactoryErrorCount = 6, //< Factory function count.
};
/* RAMFactory for Autojects on the program stack that doesn't delete the
boofer. */
LIB_MEMBER IUW* RAMFactoryStack(IUW* boofer, ISW bytes);
/* RAMFactory for Autojects on the heap that deletes a the boofer. */
LIB_MEMBER IUW* RAMFactoryHeap(IUW* boofer, ISW bytes);
/* Copies the source to the target functionally identical to memcpy.
@param write The start of the write socket.
@param size The stop of the write socket.
@param origin The origin of the read socket.
@param read_size Number of bytes to copy.
@return Pointer to the last IUA written or nil upon failure. */
LIB_MEMBER ISW RAMCopy(void* write, ISW size, const void* read,
ISW read_size);
/* Compares the two memory sockets.
@param a The start of socket a.
@param a_bytes The size of socket a in bytes.
@param b The start of socket b.
@param b_bytes The size of socket b in bytes.
@return a_bytes if a is identical to b, or if a and b are not identical
the return will be -1 times the number of bytes that were identical in a and
b. */
LIB_MEMBER ISW RAMCompare(const void* a, ISW a_bytes,
const void* b, ISW b_bytes);
/* Shifts the memory up by the given count in bytes.
@return 0 upon failure and count upon success.
@param origin The origin byte address.
@param end The end IUA.
@param count_bytes The IUA count to shift up. */
LIB_MEMBER ISW RAMShiftUp(void* origin, void* end, ISW count_bytes);
/* Shifts the memory down by the given bytes_count.
@return 0 upon failure and count upon success.
@param origin The start IUA.
@param end The end IUA.
@param count_bytes The IUA count to shift up. */
LIB_MEMBER ISW RAMShiftDown(void* origin, void* end, ISW bytes_count);
class Nil {
public:
/* Constructures nothing. */
Nil();
/* Gets the size of the socket. */
static constexpr ISW Size();
/* Gets the size of the socket. */
static constexpr ISW Bytes();
/* Gets the size of the socket. */
static constexpr ISW SizeWords();
/* Gets the nil origin word address. */
IUW* Words();
};
} //< namespace _
#endif
#endif