[go: nahoru, domu]

Skip to content

Commit

Permalink
Add namespace constants for PHP 5
Browse files Browse the repository at this point in the history
  • Loading branch information
rsky committed Dec 4, 2015
1 parent 70dbb43 commit cab4d21
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
12 changes: 9 additions & 3 deletions mecab/mecab5.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,17 +665,23 @@ static PHP_MINIT_FUNCTION(mecab)
{
REGISTER_INI_ENTRIES();

REGISTER_NS_STRING_CONSTANT("MeCab", "VERSION", (char *)mecab_version(), CONST_PERSISTENT | CONST_CS);
PHP_MECAB_REGISTER_NS_CONSTANT(NOR_NODE);
PHP_MECAB_REGISTER_NS_CONSTANT(UNK_NODE);
PHP_MECAB_REGISTER_NS_CONSTANT(BOS_NODE);
PHP_MECAB_REGISTER_NS_CONSTANT(EOS_NODE);
PHP_MECAB_REGISTER_NS_CONSTANT(SYS_DIC);
PHP_MECAB_REGISTER_NS_CONSTANT(USR_DIC);
PHP_MECAB_REGISTER_NS_CONSTANT(UNK_DIC);

REGISTER_STRING_CONSTANT("MECAB_VERSION", (char *)mecab_version(), CONST_PERSISTENT | CONST_CS);
#define PHP_MECAB_REGISTER_CONSTANT(name) \
REGISTER_LONG_CONSTANT(#name, name, CONST_PERSISTENT | CONST_CS)
PHP_MECAB_REGISTER_CONSTANT(MECAB_NOR_NODE);
PHP_MECAB_REGISTER_CONSTANT(MECAB_UNK_NODE);
PHP_MECAB_REGISTER_CONSTANT(MECAB_BOS_NODE);
PHP_MECAB_REGISTER_CONSTANT(MECAB_EOS_NODE);
PHP_MECAB_REGISTER_CONSTANT(MECAB_SYS_DIC);
PHP_MECAB_REGISTER_CONSTANT(MECAB_USR_DIC);
PHP_MECAB_REGISTER_CONSTANT(MECAB_UNK_DIC);
#undef PHP_MECAB_REGISTER_CONSTANT

le_mecab = zend_register_list_destructors_ex(
php_mecab_free_resource, NULL, "mecab", module_number);
Expand Down
17 changes: 7 additions & 10 deletions mecab/mecab7.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,16 +512,13 @@ static PHP_MINIT_FUNCTION(mecab)
REGISTER_INI_ENTRIES();

REGISTER_NS_STRING_CONSTANT("MeCab", "VERSION", (char *)mecab_version(), CONST_PERSISTENT | CONST_CS);
#define PHP_MECAB_REGISTER_CONSTANT(name) \
REGISTER_NS_LONG_CONSTANT("MeCab", #name, MECAB_##name, CONST_PERSISTENT | CONST_CS)
PHP_MECAB_REGISTER_CONSTANT(NOR_NODE);
PHP_MECAB_REGISTER_CONSTANT(UNK_NODE);
PHP_MECAB_REGISTER_CONSTANT(BOS_NODE);
PHP_MECAB_REGISTER_CONSTANT(EOS_NODE);
PHP_MECAB_REGISTER_CONSTANT(SYS_DIC);
PHP_MECAB_REGISTER_CONSTANT(USR_DIC);
PHP_MECAB_REGISTER_CONSTANT(UNK_DIC);
#undef PHP_MECAB_REGISTER_CONSTANT
PHP_MECAB_REGISTER_NS_CONSTANT(NOR_NODE);
PHP_MECAB_REGISTER_NS_CONSTANT(UNK_NODE);
PHP_MECAB_REGISTER_NS_CONSTANT(BOS_NODE);
PHP_MECAB_REGISTER_NS_CONSTANT(EOS_NODE);
PHP_MECAB_REGISTER_NS_CONSTANT(SYS_DIC);
PHP_MECAB_REGISTER_NS_CONSTANT(USR_DIC);
PHP_MECAB_REGISTER_NS_CONSTANT(UNK_DIC);

#define PHP_MECAB_GET_CE(ce, lcname) \
(ce = php_mecab_get_class_entry(lcname, sizeof(lcname) - 1 TSRMLS_CC))
Expand Down
6 changes: 6 additions & 0 deletions mecab/php_mecab_compat5.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@
#define PHP_MECAB_NODE_RETURN_PROPERTY(type, ...) PHP_MECAB_RETURN_PROPERTY(node, type, __VA_ARGS__)
#define PHP_MECAB_PATH_RETURN_PROPERTY(type, ...) PHP_MECAB_RETURN_PROPERTY(path, type, __VA_ARGS__)

#define PHP_MECAB_REGISTER_CONSTANT(name) \
REGISTER_LONG_CONSTANT(#name, name, CONST_PERSISTENT | CONST_CS)

#define PHP_MECAB_REGISTER_NS_CONSTANT(name) \
REGISTER_NS_LONG_CONSTANT("MeCab", #name, MECAB_##name, CONST_PERSISTENT | CONST_CS)

#if PHP_API_VERSION < 20100412
static inline void
object_properties_init(zend_object *object, zend_class_entry *class_type)
Expand Down
3 changes: 3 additions & 0 deletions mecab/php_mecab_compat7.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@
#define PHP_MECAB_NODE_RETURN_PROPERTY(type, ...) PHP_MECAB_RETURN_PROPERTY(node, type, __VA_ARGS__)
#define PHP_MECAB_PATH_RETURN_PROPERTY(type, ...) PHP_MECAB_RETURN_PROPERTY(path, type, __VA_ARGS__)

#define PHP_MECAB_REGISTER_NS_CONSTANT(name) \
REGISTER_NS_LONG_CONSTANT("MeCab", #name, MECAB_##name, CONST_PERSISTENT | CONST_CS)

#endif /* PHP_MECAB_COMPAT_H */

0 comments on commit cab4d21

Please sign in to comment.