1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
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 // -------------------------------------------------------------------------*/
11 * Generic tread reading/writing functions.
16 #ifndef SQUIRRELJME_TREAD_H
17 #define SQUIRRELJME_TREAD_H
23 #ifndef SJME_CXX_IS_EXTERNED
24 #define SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_SQUIRRELJME_TREAD_H
27 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
28 #endif /* #ifdef __cplusplus */
30 /*--------------------------------------------------------------------------*/
33 * Accessor functions for treads.
37 typedef struct sjme_nvm_frameTreadAccessor sjme_nvm_frameTreadAccessor
;
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.
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
);
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.
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
);
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.
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
);
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.
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
109 sjme_javaTypeId typeId
;
111 /** The size of the type. */
114 /** The name of the type. */
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.
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 /*--------------------------------------------------------------------------*/
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 */