Skip to content

Commit

Permalink
Refactor: Moved StringPool and unittest.h to libdeng1
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jul 29, 2012
1 parent caaf504 commit a5427bc
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 139 deletions.
33 changes: 17 additions & 16 deletions doomsday/config.pri
Expand Up @@ -11,24 +11,25 @@
# generated scripts (python on path used for building)
#
# CONFIG options for Doomsday:
# - deng_aptstable Include the stable apt repository .list
# - deng_aptunstable Include the unstable apt repository .list
# - deng_fluidsynth Build the FluidSynth sound driver
# - deng_fmod Build the FMOD Ex sound driver
# - deng_nativesdk (Mac) Use current OS's SDK for non-distrib use
# - deng_nodisplaymode Disable native display mode changes
# - deng_nofixedasm Disable assembler fixed-point math
# - deng_noopenal Disable building of the OpenAL sound driver
# - deng_nosdlmixer Disable SDL_mixer; use dummy driver as default
# - deng_nosnowberry (Unix) Exclude Snowberry from installation
# - deng_openal Build the OpenAL sound driver
# - deng_nopackres Do not package the Doomsday resources
# - deng_rangecheck Parameter range checking/value assertions
# - deng_snowberry (Unix) Include Snowberry in installation
# - deng_writertypecheck Enable type checking in Writer/Reader
# - deng_aptstable Include the stable apt repository .list
# - deng_aptunstable Include the unstable apt repository .list
# - deng_fluidsynth Build the FluidSynth sound driver
# - deng_fmod Build the FMOD Ex sound driver
# - deng_nativesdk (Mac) Use current OS's SDK for non-distrib use
# - deng_nodisplaymode Disable native display mode changes
# - deng_nofixedasm Disable assembler fixed-point math
# - deng_noopenal Disable building of the OpenAL sound driver
# - deng_nosdlmixer Disable SDL_mixer; use dummy driver as default
# - deng_nosnowberry (Unix) Exclude Snowberry from installation
# - deng_openal Build the OpenAL sound driver
# - deng_nopackres Do not package the Doomsday resources
# - deng_rangecheck Parameter range checking/value assertions
# - deng_snowberry (Unix) Include Snowberry in installation
# - deng_stringpoolzoneallocs Use the memory Zone for allocs in StringPool
# - deng_writertypecheck Enable type checking in Writer/Reader
#
# Read-only options (set automatically):
# - deng_debug Debug build.
# - deng_debug Debug build.

QT -= core gui
CONFIG *= thread
Expand Down
20 changes: 10 additions & 10 deletions doomsday/engine/api/doomsday.def
Expand Up @@ -284,16 +284,16 @@ EXPORTS
; AutoStr_FromStr @847 NONAME

; StringPool.
StringPool_New @537 NONAME
StringPool_NewWithStrings @538 NONAME
StringPool_Delete @539 NONAME
StringPool_Clear @540 NONAME
StringPool_Empty @541 NONAME
StringPool_Size @542 NONAME
StringPool_Intern @543 NONAME
StringPool_InternAndRetrieve @544 NONAME
StringPool_IsInterned @545 NONAME
StringPool_String @546 NONAME
; StringPool_New @537 NONAME
; StringPool_NewWithStrings @538 NONAME
; StringPool_Delete @539 NONAME
; StringPool_Clear @540 NONAME
; StringPool_Empty @541 NONAME
; StringPool_Size @542 NONAME
; StringPool_Intern @543 NONAME
; StringPool_InternAndRetrieve @544 NONAME
; StringPool_IsInterned @545 NONAME
; StringPool_String @546 NONAME

; Uri.
Uri_New @238 NONAME
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/api/doomsday.h
Expand Up @@ -84,11 +84,11 @@ struct font_s;
#include "point.h"
#include "rect.h"
#include "size.h"
#include "stringpool.h"
#include <de/reader.h>
#include <de/writer.h>
#include <de/memoryzone.h>
#include <de/smoother.h>
#include <de/stringpool.h>

//------------------------------------------------------------------------
//
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/engine.pro
Expand Up @@ -116,7 +116,6 @@ DENG_API_HEADERS = \
api/point.h \
api/rect.h \
api/size.h \
api/stringpool.h \
api/sys_audiod.h \
api/sys_audiod_mus.h \
api/sys_audiod_sfx.h \
Expand Down Expand Up @@ -607,7 +606,6 @@ SOURCES += \
portable/src/sidedef.c \
portable/src/size.c \
portable/src/stringarray.cpp \
portable/src/stringpool.cpp \
portable/src/surface.c \
portable/src/sv_frame.c \
portable/src/sv_infine.c \
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/edit_map.c
Expand Up @@ -34,7 +34,7 @@
#include "de_dam.h"
#include "de_filesys.h"

#include "stringpool.h"
#include <de/stringpool.h>
#include "s_environ.h"

typedef struct {
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/pathdirectory.c
Expand Up @@ -30,7 +30,7 @@
#include "de_system.h"
#include "m_misc.h" // For M_NumDigits

#include "stringpool.h"
#include <de/stringpool.h>
#include "blockset.h"

#include "pathdirectory.h"
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/r_model.c
Expand Up @@ -38,7 +38,7 @@
#include "de_misc.h"

#include "def_main.h"
#include "stringpool.h"
#include <de/stringpool.h>
#include "texture.h"
#include "texturevariant.h"
#include "materialvariant.h"
Expand Down
@@ -1,5 +1,5 @@
/**
* @file stringpool.h
* @file de/stringpool.h
* String pool (case insensitive). @ingroup base
*
* Container data structure for a set of unique case-insensitive strings.
Expand All @@ -26,8 +26,8 @@
*
* @todo Add case-sensitive mode.
*
* @authors Copyright © 2010-2012 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright &copy; 2010-2012 Daniel Swanson <danij@dengine.net>
* @authors Copyright &copy; 2012 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand All @@ -47,11 +47,19 @@
#ifndef LIBDENG_STRINGPOOL_H
#define LIBDENG_STRINGPOOL_H

/**
* @def DENG_STRINGPOOL_ZONE_ALLOCS
* Define this to make StringPool allocate memory from the memory zone instead
* of with system malloc().
*/
//#define DENG_STRINGPOOL_ZONE_ALLOCS

#ifdef __cplusplus
extern "C" {
#endif

#include "dd_types.h"
#include "libdeng.h"
#include "types.h"

struct stringpool_s; // The stringpool instance (opaque).

Expand All @@ -67,7 +75,7 @@ typedef uint StringPoolId;
* Constructs an empty StringPool. The pool must be destroyed with
* StringPool_Delete() when no longer needed.
*/
StringPool* StringPool_New(void);
DENG_PUBLIC StringPool* StringPool_New(void);

/**
* Constructs an empty StringPool and interns a number of strings. The pool
Expand All @@ -76,33 +84,33 @@ StringPool* StringPool_New(void);
* @param strings Array of strings to be interned (must contain at least @a count strings).
* @param count Number of strings to be interned.
*/
StringPool* StringPool_NewWithStrings(const ddstring_t* strings, uint count);
DENG_PUBLIC StringPool* StringPool_NewWithStrings(const ddstring_t* strings, uint count);

/**
* Destroys the stringpool.
* @param pool StringPool instance.
*/
void StringPool_Delete(StringPool* pool);
DENG_PUBLIC void StringPool_Delete(StringPool* pool);

/**
* Clear the string pool. All strings in the pool will be destroyed.
* @param pool StringPool instance.
*/
void StringPool_Clear(StringPool* pool);
DENG_PUBLIC void StringPool_Clear(StringPool* pool);

/**
* Is the pool empty?
* @param pool StringPool instance.
* @return @c true if there are no strings present in the pool.
*/
boolean StringPool_Empty(const StringPool* pool);
DENG_PUBLIC boolean StringPool_Empty(const StringPool* pool);

/**
* Determines the number of strings in the pool.
* @param pool StringPool instance.
* @return Number of strings in the pool.
*/
uint StringPool_Size(const StringPool* pool);
DENG_PUBLIC uint StringPool_Size(const StringPool* pool);

/**
* Interns string @a str. If this string is not already in the pool, a new
Expand All @@ -115,7 +123,7 @@ uint StringPool_Size(const StringPool* pool);
*
* @return Unique Id associated with the internal copy of @a str.
*/
StringPoolId StringPool_Intern(StringPool* pool, const ddstring_t* str);
DENG_PUBLIC StringPoolId StringPool_Intern(StringPool* pool, const ddstring_t* str);

/**
* Interns string @a str. If this string is not already in the pool, a new
Expand All @@ -128,7 +136,7 @@ StringPoolId StringPool_Intern(StringPool* pool, const ddstring_t* str);
*
* @return The interned copy of the string owned by the pool.
*/
const ddstring_t* StringPool_InternAndRetrieve(StringPool* pool, const ddstring_t* str);
DENG_PUBLIC const ddstring_t* StringPool_InternAndRetrieve(StringPool* pool, const ddstring_t* str);

/**
* Sets the user-specified custom value associated with the string @a id.
Expand All @@ -138,7 +146,7 @@ const ddstring_t* StringPool_InternAndRetrieve(StringPool* pool, const ddstring_
* @param id Id of a string.
* @param value User value.
*/
void StringPool_SetUserValue(StringPool* pool, StringPoolId id, uint value);
DENG_PUBLIC void StringPool_SetUserValue(StringPool* pool, StringPoolId id, uint value);

/**
* Retrieves the user-specified custom value associated with the string @a id.
Expand All @@ -149,7 +157,7 @@ void StringPool_SetUserValue(StringPool* pool, StringPoolId id, uint value);
*
* @return User value.
*/
uint StringPool_UserValue(StringPool* pool, StringPoolId id);
DENG_PUBLIC uint StringPool_UserValue(StringPool* pool, StringPoolId id);

/**
* Sets the user-specified custom pointer associated with the string @a id.
Expand All @@ -161,7 +169,7 @@ uint StringPool_UserValue(StringPool* pool, StringPoolId id);
* @param id Id of a string.
* @param ptr User pointer.
*/
void StringPool_SetUserPointer(StringPool* pool, StringPoolId id, void* ptr);
DENG_PUBLIC void StringPool_SetUserPointer(StringPool* pool, StringPoolId id, void* ptr);

/**
* Retrieves the user-specified custom pointer associated with the string @a id.
Expand All @@ -171,7 +179,7 @@ void StringPool_SetUserPointer(StringPool* pool, StringPoolId id, void* ptr);
*
* @return User pointer.
*/
void* StringPool_UserPointer(StringPool* pool, StringPoolId id);
DENG_PUBLIC void* StringPool_UserPointer(StringPool* pool, StringPoolId id);

/**
* Is @a str considered to be in the pool?
Expand All @@ -181,7 +189,7 @@ void* StringPool_UserPointer(StringPool* pool, StringPoolId id);
*
* @return Id of the matching string; else @c 0.
*/
StringPoolId StringPool_IsInterned(const StringPool* pool, const ddstring_t* str);
DENG_PUBLIC StringPoolId StringPool_IsInterned(const StringPool* pool, const ddstring_t* str);

/**
* Retrieve an immutable copy of the interned string associated with the
Expand All @@ -192,7 +200,7 @@ StringPoolId StringPool_IsInterned(const StringPool* pool, const ddstring_t* str
*
* @return Interned string associated with @a internId. Owned by the pool.
*/
const ddstring_t* StringPool_String(const StringPool* pool, StringPoolId id);
DENG_PUBLIC const ddstring_t* StringPool_String(const StringPool* pool, StringPoolId id);

/**
* Removes a string from the pool.
Expand All @@ -202,7 +210,7 @@ const ddstring_t* StringPool_String(const StringPool* pool, StringPoolId id);
*
* @return @c true, if string @a str was found and removed.
*/
boolean StringPool_Remove(StringPool* pool, const ddstring_t* str);
DENG_PUBLIC boolean StringPool_Remove(StringPool* pool, const ddstring_t* str);

/**
* Removes a string from the pool.
Expand All @@ -212,7 +220,7 @@ boolean StringPool_Remove(StringPool* pool, const ddstring_t* str);
*
* @return @c true if the string was found and removed.
*/
boolean StringPool_RemoveById(StringPool* pool, StringPoolId id);
DENG_PUBLIC boolean StringPool_RemoveById(StringPool* pool, StringPoolId id);

/**
* Iterate over all strings in the pool making a callback for each. Iteration
Expand All @@ -225,30 +233,30 @@ boolean StringPool_RemoveById(StringPool* pool, StringPoolId id);
* @return @c 0 iff iteration completed wholly. Otherwise the non-zero value returned
* by @a callback.
*/
int StringPool_Iterate(const StringPool* pool, int (*callback)(StringPoolId, void*), void* data);
DENG_PUBLIC int StringPool_Iterate(const StringPool* pool, int (*callback)(StringPoolId, void*), void* data);

/**
* Serializes the pool using @a writer.
*
* @param ar StringPool instance.
* @param writer Writer instance.
*/
void StringPool_Write(const StringPool* ar, Writer* writer);
DENG_PUBLIC void StringPool_Write(const StringPool* ar, Writer* writer);

/**
* Deserializes the pool from @a reader.
*
* @param ar StringPool instance.
* @param reader Reader instance.
*/
void StringPool_Read(StringPool* ar, Reader* reader);
DENG_PUBLIC void StringPool_Read(StringPool* ar, Reader* reader);

#if _DEBUG
/**
* Print contents of the pool. For debug.
* @param pool StringPool instance.
*/
void StringPool_Print(const StringPool* pool);
DENG_PUBLIC void StringPool_Print(const StringPool* pool);
#endif

#ifdef __cplusplus
Expand Down
@@ -1,8 +1,9 @@
/**
* @file unittest.h
* @file de/unittest.h
* Macros for unit testing.
*
* @authors Copyright © 2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright &copy; 2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright &copy; 2012 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand Down
11 changes: 7 additions & 4 deletions doomsday/libdeng/libdeng.pro
Expand Up @@ -9,10 +9,6 @@ TARGET = deng1

include(../config.pri)

deng_writertypecheck {
DEFINES += DENG_WRITER_TYPECHECK
}

VERSION = $$DENG_VERSION

# External Dependencies ------------------------------------------------------
Expand Down Expand Up @@ -50,6 +46,10 @@ deng_writertypecheck {
DEFINES += DENG_WRITER_TYPECHECK
}

deng_stringpoolzoneallocs {
DEFINES += DENG_STRINGPOOL_ZONE_ALLOCS
}

# Source Files ---------------------------------------------------------------

# Public headers
Expand All @@ -64,7 +64,9 @@ HEADERS += \
include/de/smoother.h \
include/de/str.h \
include/de/str.hh \
include/de/stringpool.h \
include/de/types.h \
include/de/unittest.h \
include/de/writer.h

# Sources and private headers
Expand All @@ -78,6 +80,7 @@ SOURCES += \
src/reader.c \
src/smoother.cpp \
src/str.c \
src/stringpool.cpp \
src/writer.c

# Installation ---------------------------------------------------------------
Expand Down

0 comments on commit a5427bc

Please sign in to comment.