Rename unzip tool.
[SquirrelJME.git] / nanocoat / include / sjme / tread.h
blob645d543d7cf29aaf4b1d041cdb5fbc1635c745e7
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 /**
11 * Generic tread reading/writing functions.
13 * @since 2023/11/16
16 #ifndef SQUIRRELJME_TREAD_H
17 #define SQUIRRELJME_TREAD_H
19 #include "sjme/nvm.h"
21 /* Anti-C++. */
22 #ifdef __cplusplus
23 #ifndef SJME_CXX_IS_EXTERNED
24 #define SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_SQUIRRELJME_TREAD_H
26 extern "C" {
27 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
28 #endif /* #ifdef __cplusplus */
30 /*--------------------------------------------------------------------------*/
32 /**
33 * Accessor functions for treads.
35 * @since 2023/11/16
37 typedef struct sjme_nvm_frameTreadAccessor sjme_nvm_frameTreadAccessor;
39 /**
40 * Returns the address of a given index on the tread.
42 * @param frame The frame the access is in.
43 * @param accessor The accessor used for the address.
44 * @param tread The tread to read from.
45 * @param treadIndex The index to access.
46 * @param outAddress The output address.
47 * @return Returns an error code, if any.
48 * @since 2023/11/16
50 typedef sjme_errorCode (*sjme_nvm_frameTreadAccessorAddress)(
51 sjme_attrInNotNull sjme_nvm_frame* frame,
52 sjme_attrInNotNull const sjme_nvm_frameTreadAccessor* accessor,
53 sjme_attrInNotNull sjme_nvm_frameTread* tread,
54 sjme_attrInPositive sjme_jint treadIndex,
55 sjme_attrOutNotNull sjme_pointer* outAddress);
57 /**
58 * Returns the tread from the given frame.
60 * @param frame The frame to access the tread for.
61 * @param outTread The output tread.
62 * @return Returns an error code, if any.
63 * @since 2023/11/16
65 typedef sjme_errorCode (*sjme_nvm_frameTreadAccessorGetTread)(
66 sjme_attrInNotNull sjme_nvm_frame* frame,
67 sjme_attrInNotNull const sjme_nvm_frameTreadAccessor* accessor,
68 sjme_attrInOutNotNull sjme_nvm_frameTread** outTread);
70 /**
71 * Reads from a tread.
73 * @param frame The frame the access is in.
74 * @param accessor The accessor used.
75 * @param tread The tread to read from.
76 * @param treadIndex The index to access.
77 * @param outVal The output value.
78 * @return Returns an error code, if any.
79 * @since 2023/11/16
81 typedef sjme_errorCode (*sjme_nvm_frameTreadAccessorRead)(
82 sjme_attrInNotNull sjme_nvm_frame* frame,
83 sjme_attrInNotNull const sjme_nvm_frameTreadAccessor* accessor,
84 sjme_attrInNotNull const sjme_nvm_frameTread* tread,
85 sjme_attrInPositive sjme_jint treadIndex,
86 sjme_attrOutNotNull sjme_pointer outVal);
88 /**
89 * Reads from a tread.
91 * @param frame The frame the access is in.
92 * @param accessor The accessor used.
93 * @param tread The tread to read from.
94 * @param treadIndex The index to access.
95 * @param outVal The output value.
96 * @return Returns an error code, if any.
97 * @since 2023/11/16
99 typedef sjme_errorCode (*sjme_nvm_frameTreadAccessorWrite)(
100 sjme_attrInNotNull sjme_nvm_frame* frame,
101 sjme_attrInNotNull const sjme_nvm_frameTreadAccessor* accessor,
102 sjme_attrInNotNull sjme_nvm_frameTread* tread,
103 sjme_attrInPositive sjme_jint treadIndex,
104 sjme_attrInNotNull sjme_cpointer inVal);
106 struct sjme_nvm_frameTreadAccessor
108 /** The type id. */
109 sjme_javaTypeId typeId;
111 /** The size of the type. */
112 size_t size;
114 /** The name of the type. */
115 sjme_lpcstr name;
117 /** The error code when the top type does not match. */
118 sjme_errorCode errorInvalidTop;
120 /** Get tread function. */
121 sjme_nvm_frameTreadAccessorGetTread getTread;
123 /** Address function. */
124 sjme_nvm_frameTreadAccessorAddress address;
126 /** Read function. */
127 sjme_nvm_frameTreadAccessorRead read;
129 /** Write function. */
130 sjme_nvm_frameTreadAccessorWrite write;
134 * Returns the accessor for the frame tread.
136 * @param typeId The type ID to get for.
137 * @return The accessor for the given tread.
138 * @since 2023/11/16
140 const sjme_nvm_frameTreadAccessor* sjme_nvm_frameTreadAccessorByType(
141 sjme_attrInRange(SJME_JAVA_TYPE_ID_INTEGER, SJME_NUM_JAVA_TYPE_IDS = 1)
142 sjme_javaTypeId typeId);
144 /*--------------------------------------------------------------------------*/
146 /* Anti-C++. */
147 #ifdef __cplusplus
148 #ifdef SJME_CXX_SQUIRRELJME_TREAD_H
150 #undef SJME_CXX_SQUIRRELJME_TREAD_H
151 #undef SJME_CXX_IS_EXTERNED
152 #endif /* #ifdef SJME_CXX_SQUIRRELJME_TREAD_H */
153 #endif /* #ifdef __cplusplus */
155 #endif /* SQUIRRELJME_TREAD_H */