aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/basetypes
diff options
context:
space:
mode:
authorGravatar DINH Viet Hoa <hoa@sprw.me>2013-01-21 15:06:46 -0800
committerGravatar DINH Viet Hoa <hoa@sprw.me>2013-01-21 15:06:46 -0800
commit119b654d35db873bb7dbc77e24649462eb1aa4e6 (patch)
treeae42d35a781f94d8fe6994963230b095a1b2340a /src/core/basetypes
parentd998016c04cb1e1dfc9fcf608639bfb5a4147439 (diff)
headers show public API first. cleanup.
Diffstat (limited to 'src/core/basetypes')
-rw-r--r--src/core/basetypes/MCArray.h20
-rw-r--r--src/core/basetypes/MCAssert.h4
-rw-r--r--src/core/basetypes/MCAutoreleasePool.cc5
-rw-r--r--src/core/basetypes/MCAutoreleasePool.h22
-rw-r--r--src/core/basetypes/MCData.h36
-rw-r--r--src/core/basetypes/MCHash.h4
-rw-r--r--src/core/basetypes/MCHashMap.h30
-rw-r--r--src/core/basetypes/MCLog.h4
-rw-r--r--src/core/basetypes/MCMainThread.h4
-rw-r--r--src/core/basetypes/MCObject.h13
-rw-r--r--src/core/basetypes/MCOperation.h15
-rw-r--r--src/core/basetypes/MCOperationCallback.h4
-rw-r--r--src/core/basetypes/MCOperationQueue.h21
-rw-r--r--src/core/basetypes/MCRange.h4
-rw-r--r--src/core/basetypes/MCSet.h20
-rw-r--r--src/core/basetypes/MCString.h39
-rw-r--r--src/core/basetypes/MCUtils.h4
-rw-r--r--src/core/basetypes/MCValue.h68
18 files changed, 195 insertions, 122 deletions
diff --git a/src/core/basetypes/MCArray.h b/src/core/basetypes/MCArray.h
index 9e234b97..c6dd1090 100644
--- a/src/core/basetypes/MCArray.h
+++ b/src/core/basetypes/MCArray.h
@@ -6,25 +6,20 @@
#include <libetpan/libetpan.h>
+#ifdef __cplusplus
+
namespace mailcore {
class String;
class Array : public Object {
- private:
- carray * mArray;
- void init();
public:
Array();
- Array(Array * o);
virtual ~Array();
static Array * array();
static Array * arrayWithObject(Object * obj);
- virtual String * description();
- virtual Object * copy();
-
virtual unsigned int count();
virtual void addObject(Object * obj);
virtual void removeObjectAtIndex(unsigned int idx);
@@ -41,8 +36,19 @@ namespace mailcore {
virtual Array * sortedArray(int (* compare)(void *, void *, void *), void * context);
virtual String * componentsJoinedByString(String * delimiter);
+
+ public: // subclass behavior
+ Array(Array * o);
+ virtual String * description();
+ virtual Object * copy();
+
+ private:
+ carray * mArray;
+ void init();
};
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCAssert.h b/src/core/basetypes/MCAssert.h
index cc13aba8..f2e1f484 100644
--- a/src/core/basetypes/MCAssert.h
+++ b/src/core/basetypes/MCAssert.h
@@ -2,6 +2,8 @@
#define __MAILCORE_MCASSERT_H_
+#ifdef __cplusplus
+
#define MCAssert(cond) mailcore::assertInteral(__FILE__, __LINE__, cond, #cond)
namespace mailcore {
@@ -11,3 +13,5 @@ namespace mailcore {
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCAutoreleasePool.cc b/src/core/basetypes/MCAutoreleasePool.cc
index 6c38982d..38f9630c 100644
--- a/src/core/basetypes/MCAutoreleasePool.cc
+++ b/src/core/basetypes/MCAutoreleasePool.cc
@@ -99,11 +99,6 @@ void AutoreleasePool::autorelease(Object * obj)
pool->add(obj);
}
-String * AutoreleasePool::className()
-{
- return MCSTR("AutoreleasePool");
-}
-
String * AutoreleasePool::description()
{
String * result = String::string();
diff --git a/src/core/basetypes/MCAutoreleasePool.h b/src/core/basetypes/MCAutoreleasePool.h
index ee30de87..583015c9 100644
--- a/src/core/basetypes/MCAutoreleasePool.h
+++ b/src/core/basetypes/MCAutoreleasePool.h
@@ -6,9 +6,20 @@
#include <libetpan/libetpan.h>
#include <pthread.h>
+#ifdef __cplusplus
+
namespace mailcore {
class AutoreleasePool : public Object {
+ public:
+ AutoreleasePool();
+ virtual ~AutoreleasePool();
+
+ static void autorelease(Object * obj);
+
+ public: // subclass behavior
+ virtual String * description();
+
private:
static void init();
static pthread_key_t autoreleasePoolStackKey;
@@ -18,17 +29,10 @@ namespace mailcore {
static void initAutoreleasePoolStackKey();
static AutoreleasePool * currentAutoreleasePool();
virtual void add(Object * obj);
-
- public:
- AutoreleasePool();
- virtual ~AutoreleasePool();
-
- virtual String * className();
- virtual String * description();
-
- static void autorelease(Object * obj);
};
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCData.h b/src/core/basetypes/MCData.h
index d92fa8a6..e14887f0 100644
--- a/src/core/basetypes/MCData.h
+++ b/src/core/basetypes/MCData.h
@@ -5,32 +5,19 @@
#include <mailcore/MCObject.h>
#include <mailcore/MCMessageConstants.h>
+#ifdef __cplusplus
+
namespace mailcore {
class String;
class Data : public Object {
- private:
- char * mBytes;
- unsigned int mLength;
- unsigned int mAllocated;
- void allocate(unsigned int length);
- void reset();
- static String * normalizeCharset(String * charset);
- String * charsetWithFilteredHTMLWithoutHint(bool filterHTML);
-
public:
Data();
Data(int capacity);
- Data(Data * otherData);
Data(const char * bytes, unsigned int length);
virtual ~Data();
- virtual String * description();
- virtual Object * copy();
- virtual bool isEqual(Object * otherObject);
- virtual unsigned int hash();
-
static Data * data();
static Data * dataWithCapacity(int capacity);
static Data * dataWithContentsOfFile(String * filename);
@@ -50,8 +37,27 @@ namespace mailcore {
virtual String * stringWithCharset(const char * charset);
virtual String * charsetWithFilteredHTML(bool filterHTML, String * hintCharset = NULL);
virtual Data * decodedDataUsingEncoding(Encoding encoding);
+
+ public: // subclass behavior
+ Data(Data * otherData);
+ virtual String * description();
+ virtual Object * copy();
+ virtual bool isEqual(Object * otherObject);
+ virtual unsigned int hash();
+
+ private:
+ char * mBytes;
+ unsigned int mLength;
+ unsigned int mAllocated;
+ void allocate(unsigned int length);
+ void reset();
+ static String * normalizeCharset(String * charset);
+ String * charsetWithFilteredHTMLWithoutHint(bool filterHTML);
+
};
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCHash.h b/src/core/basetypes/MCHash.h
index ecce9639..1ae547cd 100644
--- a/src/core/basetypes/MCHash.h
+++ b/src/core/basetypes/MCHash.h
@@ -2,6 +2,8 @@
#define __MAILCORE_MCHASH_H_
+#ifdef __cplusplus
+
namespace mailcore {
unsigned int hashCompute(const char * key, unsigned int len);
@@ -9,3 +11,5 @@ namespace mailcore {
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCHashMap.h b/src/core/basetypes/MCHashMap.h
index ec7955fc..92700190 100644
--- a/src/core/basetypes/MCHashMap.h
+++ b/src/core/basetypes/MCHashMap.h
@@ -4,6 +4,8 @@
#include <mailcore/MCObject.h>
+#ifdef __cplusplus
+
namespace mailcore {
class String;
@@ -12,24 +14,12 @@ namespace mailcore {
typedef HashMapCell HashMapIter;
class HashMap : public Object {
- private:
- unsigned int mAllocated;
- unsigned int mCount;
- void ** mCells;
- HashMapIter * iteratorBegin();
- HashMapIter * iteratorNext(HashMapIter * iter);
- void allocate(unsigned int size);
- void init();
public:
HashMap();
- HashMap(HashMap * o);
virtual ~HashMap();
static HashMap * hashMap();
- virtual String * description();
- virtual Object * copy();
-
virtual unsigned int count();
virtual void setObjectForKey(Object * key, Object * value);
virtual void removeObjectForKey(Object * key);
@@ -37,8 +27,24 @@ namespace mailcore {
virtual Array * allKeys();
virtual Array * allValues();
virtual void removeAllObjects();
+
+ public: // subclass behavior
+ HashMap(HashMap * o);
+ virtual String * description();
+ virtual Object * copy();
+
+ private:
+ unsigned int mAllocated;
+ unsigned int mCount;
+ void ** mCells;
+ HashMapIter * iteratorBegin();
+ HashMapIter * iteratorNext(HashMapIter * iter);
+ void allocate(unsigned int size);
+ void init();
};
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCLog.h b/src/core/basetypes/MCLog.h
index 42246e61..49b18391 100644
--- a/src/core/basetypes/MCLog.h
+++ b/src/core/basetypes/MCLog.h
@@ -4,6 +4,8 @@
#include <stdio.h>
+#ifdef __cplusplus
+
#define MCLog(...) mailcore::logInternal(NULL, __FILE__, __LINE__, 0, __VA_ARGS__)
namespace mailcore {
@@ -17,3 +19,5 @@ namespace mailcore {
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCMainThread.h b/src/core/basetypes/MCMainThread.h
index db8e1141..31819a29 100644
--- a/src/core/basetypes/MCMainThread.h
+++ b/src/core/basetypes/MCMainThread.h
@@ -2,6 +2,8 @@
#define __MAILCORE_MCMAINTHREAD_H
+#ifdef __cplusplus
+
namespace mailcore {
void callOnMainThread(void (*)(void *), void * context);
void callOnMainThreadAndWait(void (*)(void *), void * context);
@@ -9,3 +11,5 @@ namespace mailcore {
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCObject.h b/src/core/basetypes/MCObject.h
index 9e323ebf..beda7471 100644
--- a/src/core/basetypes/MCObject.h
+++ b/src/core/basetypes/MCObject.h
@@ -4,15 +4,13 @@
#include <pthread.h>
+#ifdef __cplusplus
+
namespace mailcore {
class String;
class Object {
- private:
- pthread_mutex_t mLock;
- int mCounter;
- void init();
public:
Object();
virtual ~Object();
@@ -34,8 +32,15 @@ namespace mailcore {
virtual void performMethod(Method method, void * context);
virtual void performMethodOnMainThread(Method method, void * context, bool waitUntilDone = false);
virtual void performMethodAfterDelay(Method method, void * context, double delay);
+
+ private:
+ pthread_mutex_t mLock;
+ int mCounter;
+ void init();
};
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCOperation.h b/src/core/basetypes/MCOperation.h
index 80bd8d30..c873f7e8 100644
--- a/src/core/basetypes/MCOperation.h
+++ b/src/core/basetypes/MCOperation.h
@@ -5,16 +5,13 @@
#include <pthread.h>
#include <mailcore/MCObject.h>
+#ifdef __cplusplus
+
namespace mailcore {
class OperationCallback;
class Operation : public Object {
- private:
- OperationCallback * mCallback;
- bool mCancelled;
- pthread_mutex_t mLock;
-
public:
Operation();
virtual ~Operation();
@@ -26,8 +23,16 @@ namespace mailcore {
virtual bool isCancelled();
virtual void main();
+
+ private:
+ OperationCallback * mCallback;
+ bool mCancelled;
+ pthread_mutex_t mLock;
+
};
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCOperationCallback.h b/src/core/basetypes/MCOperationCallback.h
index e9623c76..7507d413 100644
--- a/src/core/basetypes/MCOperationCallback.h
+++ b/src/core/basetypes/MCOperationCallback.h
@@ -2,6 +2,8 @@
#define __MAILCORE_MCOPERATIONCALLBACK_H_
+#ifdef __cplusplus
+
namespace mailcore {
class Operation;
@@ -14,3 +16,5 @@ namespace mailcore {
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCOperationQueue.h b/src/core/basetypes/MCOperationQueue.h
index c584f33a..d9f7e78f 100644
--- a/src/core/basetypes/MCOperationQueue.h
+++ b/src/core/basetypes/MCOperationQueue.h
@@ -7,12 +7,22 @@
#include <mailcore/MCObject.h>
#include <libetpan/libetpan.h>
+#ifdef __cplusplus
+
namespace mailcore {
class Operation;
class Array;
class OperationQueue : public Object {
+ public:
+ OperationQueue();
+ virtual ~OperationQueue();
+
+ virtual void addOperation(Operation * op);
+
+ virtual unsigned int count();
+
private:
Array * mOperations;
pthread_t mThreadID;
@@ -31,17 +41,10 @@ namespace mailcore {
void checkRunningOnMainThread(void * context);
void checkRunningAfterDelay(void * context);
- public:
- OperationQueue();
- virtual ~OperationQueue();
-
- virtual void addOperation(Operation * op);
-
- virtual unsigned int count();
-
- //virtual void waitUntilAllOperationsAreFinished();
};
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCRange.h b/src/core/basetypes/MCRange.h
index 752c4bec..9b978bfb 100644
--- a/src/core/basetypes/MCRange.h
+++ b/src/core/basetypes/MCRange.h
@@ -2,6 +2,8 @@
#define __MAILCORE_MCRANGE_H_
+#ifdef __cplusplus
+
namespace mailcore {
struct Range {
@@ -13,3 +15,5 @@ namespace mailcore {
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCSet.h b/src/core/basetypes/MCSet.h
index b4a339d4..2d6df20c 100644
--- a/src/core/basetypes/MCSet.h
+++ b/src/core/basetypes/MCSet.h
@@ -4,6 +4,8 @@
#include <mailcore/MCObject.h>
+#ifdef __cplusplus
+
namespace mailcore {
class String;
@@ -11,20 +13,13 @@ namespace mailcore {
class HashMap;
class Set : public Object {
- private:
- HashMap * mHash;
- void init();
public:
Set();
Set(Set * o);
- virtual ~Set();
static Set * set();
static Set * setWithArray(Array * objects);
- virtual String * description();
- virtual Object * copy();
-
virtual unsigned int count();
virtual void addObject(Object * obj);
virtual void removeObject(Object * obj);
@@ -34,8 +29,19 @@ namespace mailcore {
virtual Array * allObjects();
virtual void removeAllObjects();
virtual void addObjectsFromArray(Array * objects);
+
+ public: // subclass behavior
+ virtual ~Set();
+ virtual String * description();
+ virtual Object * copy();
+
+ private:
+ HashMap * mHash;
+ void init();
};
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCString.h b/src/core/basetypes/MCString.h
index 7a71b0f8..4cdee581 100644
--- a/src/core/basetypes/MCString.h
+++ b/src/core/basetypes/MCString.h
@@ -8,37 +8,22 @@
#include <stdarg.h>
#include <unicode/utypes.h>
+#ifdef __cplusplus
+
namespace mailcore {
class Data;
class Array;
class String : public Object {
- private:
- UChar * mUnicodeChars;
- unsigned int mLength;
- unsigned int mAllocated;
- void allocate(unsigned int length);
- void appendCharactersLength(const UChar * unicodeCharacters, unsigned int length);
- void reset();
- int compareWithCaseSensitive(String * otherString, bool caseSensitive);
- void appendBytes(const char * bytes, unsigned int length, const char * charset);
- void appendUTF8CharactersLength(const char * UTF8Characters, unsigned int length);
-
public:
String(const UChar * unicodeChars = NULL);
String(const UChar * unicodeChars, unsigned int length);
String(const char * UTF8Characters);
- String(String * otherString);
String(Data * data, const char * charset);
String(const char * bytes, unsigned int length, const char * charset = NULL);
virtual ~String();
- virtual String * description();
- virtual Object * copy();
- virtual bool isEqual(Object * otherObject);
- virtual unsigned int hash();
-
static String * string();
static String * stringWithUTF8Format(const char * format, ...);
static String * stringWithVUTF8Format(const char * format, va_list ap);
@@ -115,8 +100,28 @@ namespace mailcore {
virtual String * mUTF7DecodedString();
static String * uniquedStringWithUTF8Characters(const char * UTF8Characters);
+
+ public: // subclass behavior
+ String(String * otherString);
+ virtual String * description();
+ virtual Object * copy();
+ virtual bool isEqual(Object * otherObject);
+ virtual unsigned int hash();
+
+ private:
+ UChar * mUnicodeChars;
+ unsigned int mLength;
+ unsigned int mAllocated;
+ void allocate(unsigned int length);
+ void appendCharactersLength(const UChar * unicodeCharacters, unsigned int length);
+ void reset();
+ int compareWithCaseSensitive(String * otherString, bool caseSensitive);
+ void appendBytes(const char * bytes, unsigned int length, const char * charset);
+ void appendUTF8CharactersLength(const char * UTF8Characters, unsigned int length);
};
}
#endif
+
+#endif
diff --git a/src/core/basetypes/MCUtils.h b/src/core/basetypes/MCUtils.h
index 8dbbf5f4..9e3de1ac 100644
--- a/src/core/basetypes/MCUtils.h
+++ b/src/core/basetypes/MCUtils.h
@@ -2,6 +2,8 @@
#define __MAILCORE_MCUTILS_H
+#ifdef __cplusplus
+
#define MC_SAFE_RETAIN(o) ((o) != NULL ? (o)->retain() : NULL)
#define MC_SAFE_COPY(o) ((o) != NULL ? (o)->copy() : NULL)
@@ -32,3 +34,5 @@
#define MCUTF8DESC(obj) ((obj) != NULL ? (obj)->description()->UTF8Characters() : NULL )
#endif
+
+#endif
diff --git a/src/core/basetypes/MCValue.h b/src/core/basetypes/MCValue.h
index 05f499b6..3d66d661 100644
--- a/src/core/basetypes/MCValue.h
+++ b/src/core/basetypes/MCValue.h
@@ -4,46 +4,16 @@
#include <mailcore/MCObject.h>
+#ifdef __cplusplus
+
namespace mailcore {
class String;
class Value : public Object {
- private:
- int mType;
- union {
- bool boolValue;
- char charValue;
- unsigned char unsignedCharValue;
- short shortValue;
- unsigned short unsignedShortValue;
- int intValue;
- unsigned int unsignedIntValue;
- long longValue;
- unsigned long unsignedLongValue;
- long long longLongValue;
- unsigned long long unsignedLongLongValue;
- float floatValue;
- double doubleValue;
- void * pointerValue;
- struct {
- char * data;
- int length;
- } dataValue;
- } mValue;
- Value();
-
public:
- Value(Value * other);
virtual ~Value();
- virtual String * description();
-
- virtual bool isEqual(Object * otherObject);
- virtual unsigned int hash();
-
- Object * copy();
-
static Value * valueWithBoolValue(bool value);
static Value * valueWithCharValue(char value);
static Value * valueWithUnsignedCharValue(unsigned char value);
@@ -73,8 +43,42 @@ namespace mailcore {
virtual double doubleValue();
virtual void * pointerValue();
virtual void dataValue(const char ** p_value, int * p_length);
+
+ public: // subclass behavior
+ Value(Value * other);
+ virtual String * description();
+ virtual bool isEqual(Object * otherObject);
+ virtual unsigned int hash();
+ Object * copy();
+
+ private:
+ int mType;
+ union {
+ bool boolValue;
+ char charValue;
+ unsigned char unsignedCharValue;
+ short shortValue;
+ unsigned short unsignedShortValue;
+ int intValue;
+ unsigned int unsignedIntValue;
+ long longValue;
+ unsigned long unsignedLongValue;
+ long long longLongValue;
+ unsigned long long unsignedLongLongValue;
+ float floatValue;
+ double doubleValue;
+ void * pointerValue;
+ struct {
+ char * data;
+ int length;
+ } dataValue;
+ } mValue;
+ Value();
+
};
}
#endif
+
+#endif