1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef bbs_INT32ARR_EM_H
18 #define bbs_INT32ARR_EM_H
19 
20 /* ---- includes ----------------------------------------------------------- */
21 
22 #include "b_BasicEm/Context.h"
23 #include "b_BasicEm/MemSeg.h"
24 
25 /* ---- related objects  --------------------------------------------------- */
26 
27 /* ---- typedefs ----------------------------------------------------------- */
28 
29 /* ---- constants ---------------------------------------------------------- */
30 
31 /* ---- object definition -------------------------------------------------- */
32 
33 /** byte array */
34 struct bbs_Int32Arr
35 {
36 
37 	/* ---- private data --------------------------------------------------- */
38 
39 	/** pointer to exclusive memory segment used for allocation */
40 	struct bbs_MemSeg* mspE;
41 
42 	/* ---- public data ---------------------------------------------------- */
43 
44 	/** pointer to array of int32 */
45 	int32* arrPtrE;
46 
47 	/** current size */
48 	uint32 sizeE;
49 
50 	/** allocated size */
51 	uint32 allocatedSizeE;
52 
53 };
54 
55 /* ---- associated objects ------------------------------------------------- */
56 
57 /* ---- external functions ------------------------------------------------- */
58 
59 /* ---- \ghd{ constructor/destructor } ------------------------------------- */
60 
61 /** initializes bbs_Int32Arr  */
62 void bbs_Int32Arr_init( struct bbs_Context* cpA,
63 					    struct bbs_Int32Arr* ptrA );
64 
65 /** frees bbs_Int32Arr  */
66 void bbs_Int32Arr_exit( struct bbs_Context* cpA,
67 					    struct bbs_Int32Arr* ptrA );
68 
69 /* ---- \ghd{ operators } -------------------------------------------------- */
70 
71 /** copy operator */
72 void bbs_Int32Arr_copy( struct bbs_Context* cpA,
73 					    struct bbs_Int32Arr* ptrA,
74 						const struct bbs_Int32Arr* srcPtrA );
75 
76 /** equal operator */
77 flag bbs_Int32Arr_equal( struct bbs_Context* cpA,
78 						 const struct bbs_Int32Arr* ptrA,
79 						 const struct bbs_Int32Arr* srcPtrA );
80 
81 /* ---- \ghd{ query functions } -------------------------------------------- */
82 
83 /** calculates the amount of heap memory needed (16bit words) if created with given parameters */
84 uint32 bbs_Int32Arr_heapSize( struct bbs_Context* cpA,
85 							  const struct bbs_Int32Arr* ptrA,
86 							  uint32 sizeA );
87 
88 /* ---- \ghd{ modify functions } ------------------------------------------- */
89 
90 /** allocates memory for bbs_Int32Arr */
91 void bbs_Int32Arr_create( struct bbs_Context* cpA,
92 						  struct bbs_Int32Arr* ptrA,
93 						  uint32 sizeA,
94 						  struct bbs_MemSeg* mspA );
95 
96 /** sets array size */
97 void bbs_Int32Arr_size( struct bbs_Context* cpA,
98 					    struct bbs_Int32Arr* ptrA,
99 						uint32 sizeA );
100 
101 /* ---- \ghd{ memory I/O } ------------------------------------------------- */
102 
103 /** size object needs when written to memory */
104 uint32 bbs_Int32Arr_memSize( struct bbs_Context* cpA,
105 							 const struct bbs_Int32Arr* ptrA );
106 
107 /** writes object to memory; returns number of bytes written */
108 uint32 bbs_Int32Arr_memWrite( struct bbs_Context* cpA,
109 							  const struct bbs_Int32Arr* ptrA,
110 							  uint16* memPtrA );
111 
112 /** reads object from memory; returns number of bytes read */
113 uint32 bbs_Int32Arr_memRead( struct bbs_Context* cpA,
114 							 struct bbs_Int32Arr* ptrA,
115 							 const uint16* memPtrA,
116 							 struct bbs_MemSeg* mspA );
117 
118 /* ---- \ghd{ exec functions } --------------------------------------------- */
119 
120 /** fills array with a value */
121 void bbs_Int32Arr_fill( struct bbs_Context* cpA,
122 					    struct bbs_Int32Arr* ptrA,
123 						int32 valA );
124 
125 #endif /* bbs_INT32ARR_EM_H */
126 
127