Skip to content

Commit f1031fe

Browse files
committed
PHON-96: Create MongoDB\Exception interface
1 parent 6919b41 commit f1031fe

File tree

4 files changed

+95
-4
lines changed

4 files changed

+95
-4
lines changed

config.m4

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,12 @@ if test "$PHONGO" != "no"; then
167167
src/MongoDB/WriteConcern.c \
168168
src/MongoDB/WriteConcernError.c \
169169
src/MongoDB/WriteError.c \
170-
src/MongoDB/WriteException.c \
171170
src/MongoDB/WriteResult.c \
172171
";
172+
PHONGO_MONGODB_EXCEPTIONS="\
173+
src/MongoDB/Exception.c \
174+
src/MongoDB/WriteException.c \
175+
";
173176

174177
YAJL_SOURCES="\
175178
yajl_version.c \
@@ -257,10 +260,12 @@ MONGOC_SOURCES_SASL=mongoc-sasl.c
257260
PHP_ADD_SOURCES(PHP_EXT_DIR(phongo), $PHONGO_BSON)
258261
PHP_ADD_SOURCES(PHP_EXT_DIR(phongo), $PHONGO_BSON_CLASSES)
259262
PHP_ADD_SOURCES(PHP_EXT_DIR(phongo), $PHONGO_MONGODB_CLASSES)
263+
PHP_ADD_SOURCES(PHP_EXT_DIR(phongo), $PHONGO_MONGODB_EXCEPTIONS)
260264
else
261265
PHP_ADD_SOURCES_X(PHP_EXT_DIR(phongo), $PHONGO_BSON, [$STD_CFLAGS $MAINTAINER_CFLAGS $COVERAGE_CFLAGS], shared_objects_phongo, yes)
262266
PHP_ADD_SOURCES_X(PHP_EXT_DIR(phongo), $PHONGO_BSON_CLASSES, [$STD_CFLAGS $MAINTAINER_CFLAGS $COVERAGE_CFLAGS], shared_objects_phongo, yes)
263267
PHP_ADD_SOURCES_X(PHP_EXT_DIR(phongo), $PHONGO_MONGODB_CLASSES, [$STD_CFLAGS $MAINTAINER_CFLAGS $COVERAGE_CFLAGS], shared_objects_phongo, yes)
268+
PHP_ADD_SOURCES_X(PHP_EXT_DIR(phongo), $PHONGO_MONGODB_EXCEPTIONS, [$STD_CFLAGS $MAINTAINER_CFLAGS $COVERAGE_CFLAGS], shared_objects_phongo, yes)
264269
fi
265270

266271
dnl libmongoc stuff {{{

php_phongo.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,9 +1395,11 @@ PHP_MINIT_FUNCTION(phongo)
13951395
PHP_MINIT(WriteConcern)(INIT_FUNC_ARGS_PASSTHRU);
13961396
PHP_MINIT(WriteConcernError)(INIT_FUNC_ARGS_PASSTHRU);
13971397
PHP_MINIT(WriteError)(INIT_FUNC_ARGS_PASSTHRU);
1398-
PHP_MINIT(WriteException)(INIT_FUNC_ARGS_PASSTHRU);
13991398
PHP_MINIT(WriteResult)(INIT_FUNC_ARGS_PASSTHRU);
14001399

1400+
PHP_MINIT(Exception)(INIT_FUNC_ARGS_PASSTHRU);
1401+
PHP_MINIT(WriteException)(INIT_FUNC_ARGS_PASSTHRU);
1402+
14011403
PHP_MINIT(Type)(INIT_FUNC_ARGS_PASSTHRU);
14021404
PHP_MINIT(Binary)(INIT_FUNC_ARGS_PASSTHRU);
14031405
PHP_MINIT(Javascript)(INIT_FUNC_ARGS_PASSTHRU);

php_phongo_classes.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ extern PHONGO_API zend_class_entry *php_phongo_writebatch_ce;
186186
extern PHONGO_API zend_class_entry *php_phongo_writeconcern_ce;
187187
extern PHONGO_API zend_class_entry *php_phongo_writeconcernerror_ce;
188188
extern PHONGO_API zend_class_entry *php_phongo_writeerror_ce;
189-
extern PHONGO_API zend_class_entry *php_phongo_writeexception_ce;
190189
extern PHONGO_API zend_class_entry *php_phongo_writeresult_ce;
191190

191+
extern PHONGO_API zend_class_entry *php_phongo_exception_ce;
192+
extern PHONGO_API zend_class_entry *php_phongo_writeexception_ce;
193+
192194
extern PHONGO_API zend_class_entry *php_phongo_type_ce;
193195
extern PHONGO_API zend_class_entry *php_phongo_binary_ce;
194196
extern PHONGO_API zend_class_entry *php_phongo_int32_ce;
@@ -216,9 +218,11 @@ PHP_MINIT_FUNCTION(WriteBatch);
216218
PHP_MINIT_FUNCTION(WriteConcern);
217219
PHP_MINIT_FUNCTION(WriteConcernError);
218220
PHP_MINIT_FUNCTION(WriteError);
219-
PHP_MINIT_FUNCTION(WriteException);
220221
PHP_MINIT_FUNCTION(WriteResult);
221222

223+
PHP_MINIT_FUNCTION(Exception);
224+
PHP_MINIT_FUNCTION(WriteException);
225+
222226
PHP_MINIT_FUNCTION(Type);
223227
PHP_MINIT_FUNCTION(Binary);
224228
PHP_MINIT_FUNCTION(Javascript);

src/MongoDB/Exception.c

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
+---------------------------------------------------------------------------+
3+
| PHP Driver for MongoDB |
4+
+---------------------------------------------------------------------------+
5+
| Copyright 2013-2014 MongoDB, Inc. |
6+
| |
7+
| Licensed under the Apache License, Version 2.0 (the "License"); |
8+
| you may not use this file except in compliance with the License. |
9+
| You may obtain a copy of the License at |
10+
| |
11+
| http://www.apache.org/licenses/LICENSE-2.0 |
12+
| |
13+
| Unless required by applicable law or agreed to in writing, software |
14+
| distributed under the License is distributed on an "AS IS" BASIS, |
15+
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16+
| See the License for the specific language governing permissions and |
17+
| limitations under the License. |
18+
+---------------------------------------------------------------------------+
19+
| Copyright (c) 2014, MongoDB, Inc. |
20+
+---------------------------------------------------------------------------+
21+
*/
22+
23+
#ifdef HAVE_CONFIG_H
24+
# include "config.h"
25+
#endif
26+
27+
/* External libs */
28+
#include <bson.h>
29+
#include <mongoc.h>
30+
31+
/* PHP Core stuff */
32+
#include <php.h>
33+
#include <php_ini.h>
34+
#include <ext/standard/info.h>
35+
#include <Zend/zend_interfaces.h>
36+
#include <ext/spl/spl_iterators.h>
37+
/* Our Compatability header */
38+
#include "php_compat_53.h"
39+
40+
/* Our stuffz */
41+
#include "php_phongo.h"
42+
#include "php_bson.h"
43+
#include <ext/spl/spl_exceptions.h>
44+
45+
46+
PHONGO_API zend_class_entry *php_phongo_exception_ce;
47+
48+
/* {{{ MongoDB\Exception */
49+
50+
static zend_function_entry php_phongo_exception_me[] = {
51+
PHP_FE_END
52+
};
53+
54+
/* }}} */
55+
56+
57+
/* {{{ PHP_MINIT_FUNCTION */
58+
PHP_MINIT_FUNCTION(Exception)
59+
{
60+
(void)type;
61+
(void)module_number;
62+
zend_class_entry ce;
63+
64+
INIT_NS_CLASS_ENTRY(ce, "MongoDB", "Exception", php_phongo_exception_me);
65+
php_phongo_exception_ce = zend_register_internal_interface(&ce TSRMLS_CC);
66+
67+
return SUCCESS;
68+
}
69+
/* }}} */
70+
71+
72+
73+
/*
74+
* Local variables:
75+
* tab-width: 4
76+
* c-basic-offset: 4
77+
* End:
78+
* vim600: noet sw=4 ts=4 fdm=marker
79+
* vim<600: noet sw=4 ts=4
80+
*/

0 commit comments

Comments
 (0)