Skip to content

Commit 277df7e

Browse files
committed
PHPC-640: TypeWrapper interface
1 parent 8721fad commit 277df7e

File tree

5 files changed

+63
-1
lines changed

5 files changed

+63
-1
lines changed

config.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ if test "$MONGODB" != "no"; then
165165
src/BSON/Serializable.c \
166166
src/BSON/Timestamp.c \
167167
src/BSON/Type.c \
168+
src/BSON/TypeWrapper.c \
168169
src/BSON/Unserializable.c \
169170
src/BSON/UTCDateTime.c \
170171
src/MongoDB/BulkWrite.c \

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if (PHP_MONGODB != "no") {
8484

8585
EXTENSION("mongodb", "php_phongo.c phongo_compat.c", null, PHP_MONGODB_CFLAGS);
8686
ADD_SOURCES(configure_module_dirname + "/src", "bson.c bson-encode.c", "mongodb");
87-
ADD_SOURCES(configure_module_dirname + "/src/BSON", "Binary.c Decimal128.c Javascript.c MaxKey.c MinKey.c ObjectID.c Persistable.c Regex.c Serializable.c Timestamp.c Type.c Unserializable.c UTCDateTime.c", "mongodb");
87+
ADD_SOURCES(configure_module_dirname + "/src/BSON", "Binary.c Decimal128.c Javascript.c MaxKey.c MinKey.c ObjectID.c Persistable.c Regex.c Serializable.c Timestamp.c Type.c TypeWrapper.c Unserializable.c UTCDateTime.c", "mongodb");
8888
ADD_SOURCES(configure_module_dirname + "/src/MongoDB", "BulkWrite.c Command.c Cursor.c CursorId.c Manager.c Monitoring.c Query.c ReadConcern.c ReadPreference.c Server.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c", "mongodb");
8989
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c ConnectionException.c ConnectionTimeoutException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c SSLConnectionException.c UnexpectedValueException.c WriteException.c", "mongodb");
9090
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Monitoring", "CommandFailedEvent.c CommandStartedEvent.c CommandSubscriber.c CommandSucceededEvent.c Subscriber.c", "mongodb");

php_phongo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,6 +2130,7 @@ PHP_MINIT_FUNCTION(mongodb)
21302130
php_phongo_persistable_init_ce(INIT_FUNC_ARGS_PASSTHRU);
21312131
php_phongo_regex_init_ce(INIT_FUNC_ARGS_PASSTHRU);
21322132
php_phongo_timestamp_init_ce(INIT_FUNC_ARGS_PASSTHRU);
2133+
php_phongo_typewrapper_init_ce(INIT_FUNC_ARGS_PASSTHRU);
21332134
php_phongo_utcdatetime_init_ce(INIT_FUNC_ARGS_PASSTHRU);
21342135

21352136
php_phongo_bulkwrite_init_ce(INIT_FUNC_ARGS_PASSTHRU);

php_phongo_classes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ extern zend_class_entry *php_phongo_writeexception_ce;
243243
extern zend_class_entry *php_phongo_bulkwriteexception_ce;
244244

245245
extern zend_class_entry *php_phongo_type_ce;
246+
extern zend_class_entry *php_phongo_typewrapper_ce;
246247
extern zend_class_entry *php_phongo_persistable_ce;
247248
extern zend_class_entry *php_phongo_unserializable_ce;
248249
extern zend_class_entry *php_phongo_serializable_ce;
@@ -273,6 +274,7 @@ extern void php_phongo_regex_init_ce(INIT_FUNC_ARGS);
273274
extern void php_phongo_serializable_init_ce(INIT_FUNC_ARGS);
274275
extern void php_phongo_timestamp_init_ce(INIT_FUNC_ARGS);
275276
extern void php_phongo_type_init_ce(INIT_FUNC_ARGS);
277+
extern void php_phongo_typewrapper_init_ce(INIT_FUNC_ARGS);
276278
extern void php_phongo_utcdatetime_init_ce(INIT_FUNC_ARGS);
277279
extern void php_phongo_unserializable_init_ce(INIT_FUNC_ARGS);
278280

src/BSON/TypeWrapper.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright 2017 MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifdef HAVE_CONFIG_H
18+
# include "config.h"
19+
#endif
20+
21+
#include <php.h>
22+
23+
#include "phongo_compat.h"
24+
#include "php_phongo.h"
25+
26+
zend_class_entry *php_phongo_typewrapper_ce;
27+
28+
/* {{{ MongoDB\BSON\TypeWrapper function entries */
29+
ZEND_BEGIN_ARG_INFO_EX(ai_TypeWrapper_createFromBSONType, 0, 0, 1)
30+
ZEND_ARG_OBJ_INFO(0, type, MongoDB\\BSON\\Type, 0)
31+
ZEND_END_ARG_INFO()
32+
33+
ZEND_BEGIN_ARG_INFO_EX(ai_TypeWrapper_void, 0, 0, 0)
34+
ZEND_END_ARG_INFO()
35+
36+
static zend_function_entry php_phongo_typewrapper_me[] = {
37+
ZEND_FENTRY(createFromBSONType, NULL, ai_TypeWrapper_createFromBSONType, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT|ZEND_ACC_STATIC)
38+
ZEND_ABSTRACT_ME(TypeWrapper, toBSONType, ai_TypeWrapper_void)
39+
PHP_FE_END
40+
};
41+
/* }}} */
42+
43+
void php_phongo_typewrapper_init_ce(INIT_FUNC_ARGS) /* {{{ */
44+
{
45+
zend_class_entry ce;
46+
47+
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\BSON", "TypeWrapper", php_phongo_typewrapper_me);
48+
php_phongo_typewrapper_ce = zend_register_internal_interface(&ce TSRMLS_CC);
49+
} /* }}} */
50+
51+
/*
52+
* Local variables:
53+
* tab-width: 4
54+
* c-basic-offset: 4
55+
* End:
56+
* vim600: noet sw=4 ts=4 fdm=marker
57+
* vim<600: noet sw=4 ts=4
58+
*/

0 commit comments

Comments
 (0)