Skip to content

Commit

Permalink
tidy build
Browse files Browse the repository at this point in the history
  • Loading branch information
krakjoe committed Aug 27, 2014
1 parent 1627ee5 commit 256f398
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
10 changes: 9 additions & 1 deletion api.h
Expand Up @@ -61,7 +61,15 @@ PHP_USTRING_API zend_string* php_ustring_getCodepage(zval *that TSRMLS_DC);
PHP_USTRING_API void php_ustring_setDefaultCodepage(const char *value, int32_t len TSRMLS_DC);
PHP_USTRING_API zend_string* php_ustring_getDefaultCodepage(TSRMLS_D);

PHP_USTRING_API zend_class_entry* ce_UString;
PHP_USTRING_API extern zend_class_entry* ce_UString;

#ifdef ZTS
#define UG(v) TSRMG(ustring_globals_id, zend_ustring_globals *, v)
#else
#define UG(v) (ustring_globals.v)
#endif

ZEND_EXTERN_MODULE_GLOBALS(ustring);
/* }}} */

#endif /* PHP_USTRING_API_H */
Expand Down
19 changes: 13 additions & 6 deletions backend/icu.cpp
Expand Up @@ -18,9 +18,20 @@
#ifndef PHP_USTRING_BACKEND_ICU
#define PHP_USTRING_BACKEND_ICU

#include "unicode/unistr.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

extern "C" {
# include "php.h"
# include "php_ini.h"
# include "ext/standard/info.h"
# include "php_ustring.h"
# include "../api.h"
# include "backend/api.h"
}

#include "backend/api.h"
#include "unicode/unistr.h"

typedef struct _php_ustring_t {
UnicodeString *val;
Expand All @@ -37,10 +48,6 @@ typedef struct _php_ustring_iterator_t {

#define php_ustring_fetch(o) ((php_ustring_t*) (((char*)Z_OBJ_P(o)) - XtOffsetOf(php_ustring_t, std)))

#define STR_PAD_LEFT 0
#define STR_PAD_RIGHT 1
#define STR_PAD_BOTH 2

static inline php_ustring_t *php_ustring_copy(php_ustring_t *target, php_ustring_t *source)
{
target->val = new UnicodeString(*source->val);
Expand Down
8 changes: 6 additions & 2 deletions config.m4
Expand Up @@ -10,6 +10,10 @@ if test "$PHP_USTRING" != "no"; then

PHP_REQUIRE_CXX()
PHP_ADD_LIBRARY(stdc++,,USTRING_SHARED_LIBADD)

PHP_NEW_EXTENSION(ustring, ustring.cpp, $ext_shared,, -D__STDC_LIMIT_MACROS)

dnl should be configured with some switch when more than one backend exists

PHP_USTRING_SOURCE="ustring.cpp backend/icu.cpp"

PHP_NEW_EXTENSION(ustring, $PHP_USTRING_SOURCE, $ext_shared,, -D__STDC_LIMIT_MACROS)
fi
4 changes: 4 additions & 0 deletions php_ustring.h
Expand Up @@ -37,6 +37,10 @@ ZEND_BEGIN_MODULE_GLOBALS(ustring)
zval defaultpad;
ZEND_END_MODULE_GLOBALS(ustring)

#define STR_PAD_LEFT 0
#define STR_PAD_RIGHT 1
#define STR_PAD_BOTH 2

#endif /* PHP_USTRING_H */

/*
Expand Down
18 changes: 4 additions & 14 deletions ustring.cpp
Expand Up @@ -22,32 +22,22 @@
#include "config.h"
#endif

#ifdef _WIN32
#include "unicode/unistr.h"
#endif

extern "C" {
# include "php.h"
# include "php_ini.h"
# include "ext/standard/info.h"
# include "php_ustring.h"
# include "api.h"
# include "backend/api.h"
}

ZEND_DECLARE_MODULE_GLOBALS(ustring);

#ifdef ZTS
#define UG(v) TSRMG(ustring_globals_id, zend_ustring_globals *, v)
#else
#define UG(v) (ustring_globals.v)
#endif
extern php_ustring_backend_t php_ustring_defaults;

/*
* Do some magical ifdef'ing maybe ?
*/
#include "backend/icu.cpp"
php_ustring_backend_t *php_ustring_backend = &php_ustring_defaults;

PHP_USTRING_API php_ustring_backend_t *php_ustring_backend = &php_ustring_defaults;
zend_class_entry *ce_UString;

PHP_USTRING_API void php_ustring_construct(zval *that, const char *value, int32_t vlen, const char *codepage, int32_t clen TSRMLS_DC) {
php_ustring_backend->construct(that, value, vlen, codepage, clen TSRMLS_CC);
Expand Down

0 comments on commit 256f398

Please sign in to comment.