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 // -------------------------------------------------------------------------*/
10 #include "sjme/list.h"
11 #include "sjme/alloc.h"
12 #include "sjme/debug.h"
14 sjme_errorCode
sjme_list_allocR(
15 sjme_attrInNotNull sjme_alloc_pool
* inPool
,
16 sjme_attrInPositive sjme_jint inLength
,
17 sjme_attrOutNotNull
void** outList
,
18 sjme_attrInPositive sjme_jint elementSize
,
19 sjme_attrInPositive sjme_jint elementOffset
,
20 sjme_attrInValue sjme_jint pointerCheck
)
26 if (inPool
== NULL
|| outList
== NULL
)
27 return SJME_ERROR_NULL_ARGUMENTS
;
29 if (inLength
< 0 || elementSize
<= 0 || elementOffset
<= 0 ||
31 return SJME_ERROR_INVALID_ARGUMENT
;
33 /* Calculate the size of the list. */
34 size
= elementOffset
+ (elementSize
* inLength
);
36 return SJME_ERROR_INVALID_ARGUMENT
;
38 /* Forward allocation. */
40 if (SJME_IS_ERROR(error
= sjme_alloc(inPool
, size
, &result
)) ||
44 /* Set size, it is always at the start. */
45 *((sjme_jint
*)result
) = inLength
;
47 /* Give the result! */
49 return SJME_ERROR_NONE
;
52 sjme_errorCode
sjme_list_flattenArgCV(
53 sjme_attrInNotNull sjme_alloc_pool
* inPool
,
54 sjme_attrOutNotNull sjme_list_sjme_lpcstr
** outList
,
55 sjme_attrInPositive sjme_jint argC
,
56 sjme_attrInNotNull sjme_lpcstr
* argV
)
58 sjme_todo("Implement this?");
59 return SJME_ERROR_NOT_IMPLEMENTED
;
62 sjme_errorCode
sjme_list_flattenR(
63 sjme_attrInNotNull sjme_alloc_pool
* inPool
,
64 sjme_attrInPositive sjme_jint elementSize
,
65 sjme_attrInPositive sjme_jint elementOffset
,
66 sjme_attrInValue sjme_jint pointerCheck
,
67 sjme_attrInNotNull sjme_basicTypeId basicTypeId
,
68 sjme_attrInPositive sjme_jint numPointerStars
,
69 sjme_attrInPositive sjme_jint length
,
70 sjme_attrOutNotNull
void** outList
,
73 sjme_message("sjme_list_flattenVR(%p, %d, %d, %d, %d, %d, %d, %p)",
74 inPool
, elementSize
, elementOffset
, pointerCheck
,
75 basicTypeId
, numPointerStars
, length
, outList
);
77 sjme_todo("Implement this?");
78 return SJME_ERROR_NOT_IMPLEMENTED
;
81 sjme_errorCode
sjme_list_flattenVR(
82 sjme_attrInNotNull sjme_alloc_pool
* inPool
,
83 sjme_attrInPositive sjme_jint elementSize
,
84 sjme_attrInPositive sjme_jint elementOffset
,
85 sjme_attrInValue sjme_jint pointerCheck
,
86 sjme_attrInNotNull sjme_basicTypeId basicTypeId
,
87 sjme_attrInPositive sjme_jint numPointerStars
,
88 sjme_attrInPositive sjme_jint length
,
89 sjme_attrOutNotNull
void** outList
,
92 sjme_message("sjme_list_flattenVR(%p, %d, %d, %d, %d, %d, %d, %p)",
93 inPool
, elementSize
, elementOffset
, pointerCheck
,
94 basicTypeId
, numPointerStars
, length
, outList
);
96 sjme_todo("Implement this?");
97 return SJME_ERROR_NOT_IMPLEMENTED
;