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 #include "sjme/util.h"
12 #include "sjme/debug.h"
14 sjme_jchar
sjme_decodeUtfChar(const char* at
, const char** stringP
)
19 sjme_todo("sjme_decodeUtfChar()");
24 * Initializes the random number generator.
26 * @param outRandom The random state to initialize.
27 * @param seedHi The high seed value.
28 * @param seedLo The low seed value.
29 * @return Returns @c SJME_JNI_TRUE on success.
32 sjme_jboolean
sjme_randomInit(
33 sjme_attrInOutNotNull sjme_random
* outRandom
,
34 sjme_attrInValue sjme_jint seedHi
,
35 sjme_attrInValue sjme_jint seedLo
)
37 sjme_todo("Implement this?");
38 return SJME_JNI_FALSE
;
41 sjme_jboolean
sjme_randomInitL(
42 sjme_attrInOutNotNull sjme_random
* outRandom
,
43 sjme_attrInValue sjme_jlong seed
)
45 sjme_todo("Implement this?");
46 return SJME_JNI_FALSE
;
49 sjme_jboolean
sjme_randomNextInt(
50 sjme_attrInOutNotNull sjme_random
* random
,
51 sjme_attrOutNotNull sjme_jint
* outValue
)
53 sjme_todo("Implement this?");
54 return SJME_JNI_FALSE
;
57 sjme_jboolean
sjme_randomNextIntMax(
58 sjme_attrInOutNotNull sjme_random
* random
,
59 sjme_attrOutNotNull sjme_jint
* outValue
,
60 sjme_attrInPositiveNonZero sjme_jint maxValue
)
62 sjme_todo("Implement this?");
63 return SJME_JNI_FALSE
;
66 sjme_jint
sjme_stringHash(const char* string
)
78 /* Read until end of string. */
79 for (p
= string
; *p
!= 0;)
81 /* Decode character. */
82 c
= sjme_decodeUtfChar(p
, &p
);
84 /* Calculate the hashCode(), the JavaDoc gives the following formula:
85 // == s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] .... yikes! */
86 result
= ((result
<< 5) - result
) + (sjme_jint
)c
;
89 /* Return calculated result. */
93 sjme_jint
sjme_stringLength(const char* string
)
98 sjme_todo("sjme_stringLength()");
102 sjme_jint
sjme_treeFind(void* in
, void* what
,
103 const sjme_treeFindFunc
* functions
)
105 if (in
== NULL
|| functions
== NULL
)
108 sjme_todo("sjme_treeFind()");