Permalink
Browse files

latest

  • Loading branch information...
Steve Dekorte Steve Dekorte
Steve Dekorte authored and Steve Dekorte committed Oct 21, 2009
1 parent 75b2211 commit 234337fbdaf366390a5155a2f3473636ba547d64
Showing with 65 additions and 24 deletions.
  1. +8 −1 source/CHash.c
  2. +1 −0 source/CHash.h
  3. +1 −1 source/List.c
  4. +1 −1 source/PointerHash.c
  5. +9 −9 source/UArray.c
  6. +24 −0 source/UArray.h
  7. +1 −0 source/UArray_character.c
  8. +5 −4 source/UArray_math.c
  9. +1 −0 source/UArray_string.c
  10. +14 −8 source/UArray_utf.c
View
@@ -61,7 +61,7 @@ void CHash_show(CHash *self)
for(i = 0; i < self->size; i++)
{
CHashRecord *r = CRecords_recordAt_(self->records, i);
- printf(" %p: %p %p\n", i, r->k, r->v);
+ printf(" %i: %p %p\n", (int)i, r->k, r->v);
}
}
@@ -201,6 +201,13 @@ void CHash_removeKey_(CHash *self, void *k)
}
}
+void CHash_clear(CHash *self)
+{
+ memset(self->records, 0x0, self->size * sizeof(CHashRecord));
+ self->keyCount = 0;
+ CHash_shrinkIfNeeded(self);
+}
+
size_t CHash_size(CHash *self) // actually the keyCount
{
return self->keyCount;
View
@@ -45,6 +45,7 @@ BASEKIT_API void CHash_setHash2Func_(CHash *self, CHashHashFunc *f);
BASEKIT_API void CHash_setEqualFunc_(CHash *self, CHashEqualFunc *f);
BASEKIT_API void CHash_removeKey_(CHash *self, void *k);
+BASEKIT_API void CHash_clear(CHash *self);
BASEKIT_API size_t CHash_size(CHash *self); // actually the keyCount
BASEKIT_API size_t CHash_memorySize(CHash *self);
View
@@ -158,7 +158,7 @@ void List_print(const List *self)
for (i = 0; i < self->size; i ++)
{
- printf("%i: %p\n", i, (void *)self->items[i]);
+ printf("%i: %p\n", (int)i, (void *)self->items[i]);
}
printf("\n");
View
@@ -60,7 +60,7 @@ void PointerHash_show(PointerHash *self)
for(i = 0; i < self->size; i++)
{
PointerHashRecord *r = PointerHashRecords_recordAt_(self->records, i);
- printf(" %p: %p %p\n", i, r->k, r->v);
+ printf(" %i: %p %p\n", (int)i, r->k, r->v);
}
}
View
@@ -255,8 +255,8 @@ UArray *UArray_clone(const UArray *self)
void UArray_show(const UArray *self)
{
printf("UArray_%p %s\t", (void *)self, CTYPE_name(self->itemType));
- printf("size: %i ", self->size);
- printf("itemSize: %i ", self->itemSize);
+ printf("size: %i ", (int)self->size);
+ printf("itemSize: %i ", (int)self->itemSize);
printf("data: ");
UArray_print(self);
printf("\n");
@@ -885,13 +885,13 @@ void UArray_at_putAll_(UArray *self, size_t pos, const UArray *other)
//(&newChunk)->data == 0x0 ||
(&insertChunk)->data == 0x0)
{
- printf("oldChunk.data %p size %i\n", (void *)(&oldChunk)->data, oldChunk.size);
- printf("newChunk.data %p size %i\n", (void *)(&newChunk)->data, newChunk.size);
- printf("insertChunk.data %p size %i\n", (void *)(&insertChunk)->data, insertChunk.size);
- printf("originalSelfSize = %i\n", originalSelfSize);
- printf("self->size = %i\n", self->size);
- printf("other->size = %i\n", other->size);
- printf("pos = %i\n", pos);
+ printf("oldChunk.data %p size %i\n", (void *)(&oldChunk)->data, (int)oldChunk.size);
+ printf("newChunk.data %p size %i\n", (void *)(&newChunk)->data, (int)newChunk.size);
+ printf("insertChunk.data %p size %i\n", (void *)(&insertChunk)->data, (int)insertChunk.size);
+ printf("originalSelfSize = %i\n", (int)originalSelfSize);
+ printf("self->size = %i\n", (int)self->size);
+ printf("other->size = %i\n", (int)other->size);
+ printf("pos = %i\n", (int)pos);
//exit(-1);
oldChunk = UArray_stackRange(self, pos, chunkSize);
View
@@ -442,6 +442,30 @@ BASEKIT_API void UArray_sortBy_(UArray *self, UArraySortCallback *cmp);
case CTYPE_float32_t: UARRAY_FOREACHTYPEASSIGN(self, i, v, code, float32_t); break;\
case CTYPE_float64_t: UARRAY_FOREACHTYPEASSIGN(self, i, v, code, float64_t); break;\
}
+
+#define UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, TYPE)\
+ {\
+ size_t i;\
+ for(i = 0; i < self->size; i ++)\
+ {\
+ ((TYPE *)self->data)[i] = code;\
+ }\
+ }
+
+#define UARRAY_FOREACHASSIGN_VALUE_UNUSED(self, i, code)\
+ switch(self->itemType)\
+ {\
+ case CTYPE_uint8_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, uint8_t); break;\
+ case CTYPE_uint16_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, uint16_t); break;\
+ case CTYPE_uint32_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, uint32_t); break;\
+ case CTYPE_uint64_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, uint64_t); break;\
+ case CTYPE_int8_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, int8_t); break;\
+ case CTYPE_int16_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, int16_t); break;\
+ case CTYPE_int32_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, int32_t); break;\
+ case CTYPE_int64_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, int64_t); break;\
+ case CTYPE_float32_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, float32_t); break;\
+ case CTYPE_float64_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, float64_t); break;\
+ }
// ----------------------------
@@ -5,6 +5,7 @@
#include "UArray.h"
#include <math.h>
+#include <ctype.h>
// set
View
@@ -58,22 +58,22 @@ void UArray_round(UArray *self)
void UArray_clear(UArray *self)
{
- UARRAY_FOREACHASSIGN(self, i, v, 0);
+ UARRAY_FOREACHASSIGN_VALUE_UNUSED(self, i, 0);
}
void UArray_setItemsToLong_(UArray *self, long x)
{
- UARRAY_FOREACHASSIGN(self, i, v, x);
+ UARRAY_FOREACHASSIGN_VALUE_UNUSED(self, i, x);
}
void UArray_setItemsToDouble_(UArray *self, double x)
{
- UARRAY_FOREACHASSIGN(self, i, v, x);
+ UARRAY_FOREACHASSIGN_VALUE_UNUSED(self, i, x);
}
void UArray_rangeFill(UArray *self)
{
- UARRAY_FOREACHASSIGN(self, i, v, i);
+ UARRAY_FOREACHASSIGN_VALUE_UNUSED(self, i, i);
}
void UArray_negate(const UArray *self)
@@ -147,6 +147,7 @@ void UArray_divide_(UArray *self, const UArray *other)
double UArray_dotProduct_(const UArray *self, const UArray *other)
{
DUARRAY_OP(UARRAY_DOT, NULL, self, other);
+ return 0; // to keep compiler from annoying us
}
// basic scalar math
View
@@ -10,6 +10,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stddef.h>
+#include <ctype.h>
void UArray_append_(UArray *self, const UArray *other)
{
View
@@ -126,7 +126,13 @@ int UArray_isMultibyte(const UArray *self)
{
if (self->encoding == CENCODING_UTF8)
{
- UARRAY_INTFOREACH(self, i, v, if (ismbchar((int)v)) return 1; );
+ size_t i, max = UArray_sizeInBytes(self);
+ const uint8_t *bytes = UArray_bytes(self);
+ for (i = 0; i < max; i ++)
+ {
+ if (UArray_SizeOfUTF8Char(bytes + i) > 1) return 1;
+ }
+ //UARRAY_INTFOREACH(self, i, v, if (ismbchar((int)v)) return 1; );
}
return 0;
@@ -150,11 +156,11 @@ UArray *UArray_asNumberArrayString(const UArray *self)
if(UArray_isFloatType(self))
{
- sprintf(s, "%f", v);
+ sprintf(s, "%f", (double)v);
}
else
{
- sprintf(s, "%i", v);
+ sprintf(s, "%i", (int)v);
}
if(i != UArray_size(self) -1 ) strcat(s, ", ");
@@ -172,11 +178,11 @@ UArray *UArray_asUTF8(const UArray *self)
UArray_setSize_(out, self->size * 4);
{
- ConversionFlags options = lenientConversion;
+ //ConversionFlags options = lenientConversion;
void *sourceStart = self->data;
- void *sourceEnd = self->data + self->size * self->itemSize;
+ //void *sourceEnd = self->data + self->size * self->itemSize;
UTF8 *targetStart = out->data;
- UTF8 *targetEnd = out->data + out->size * out->itemSize;
+ //UTF8 *targetEnd = out->data + out->size * out->itemSize;
size_t outSize;
switch(self->encoding)
@@ -242,7 +248,7 @@ UArray *UArray_asUCS2(const UArray *self)
if ((numChars > 0) && (numChars > countedChars*2))
{
- printf("UArray_asUCS2 error: numChars (%i) > countedChars (2*%i)\n", numChars, countedChars);
+ printf("UArray_asUCS2 error: numChars (%i) > countedChars (2*%i)\n", (int)numChars, (int)countedChars);
printf("Exiting because we may have overwritten the usc2 decode output buffer.");
exit(-1);
}
@@ -269,7 +275,7 @@ UArray *UArray_asUCS4(const UArray *self)
if ((numChars > 0) && (numChars > countedChars*2))
{
- printf("UArray_asUCS4 error: numChars %i != countedChars %i\n", numChars, countedChars);
+ printf("UArray_asUCS4 error: numChars %i != countedChars %i\n", (int)numChars, (int)countedChars);
exit(-1);
}

0 comments on commit 234337f

Please sign in to comment.