-
Notifications
You must be signed in to change notification settings - Fork 52
/
metadoc.c
55 lines (44 loc) · 1.63 KB
/
metadoc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "bucket.h"
#include "cas.h"
#include "transcoding.h"
#include "exception.h"
zend_class_entry *metadoc_ce;
zend_function_entry metadoc_methods[] = {
{ NULL, NULL, NULL }
};
void couchbase_init_metadoc(INIT_FUNC_ARGS) {
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "CouchbaseMetaDoc", metadoc_methods);
metadoc_ce = zend_register_internal_class(&ce TSRMLS_CC);
zend_declare_property_null(metadoc_ce, "error", strlen("error"), ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_null(metadoc_ce, "value", strlen("value"), ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_null(metadoc_ce, "flags", strlen("flags"), ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_null(metadoc_ce, "cas", strlen("cas"), ZEND_ACC_PUBLIC TSRMLS_CC);
}
int make_metadoc_error(zval *doc, lcb_error_t err TSRMLS_DC)
{
zapval zerror;
object_init_ex(doc, metadoc_ce);
make_lcb_exception(&zerror, err, NULL TSRMLS_CC);
zend_update_property(metadoc_ce, doc, "error", sizeof("error") - 1,
zapval_zvalptr(zerror) TSRMLS_CC);
zapval_destroy(zerror);
return SUCCESS;
}
int make_metadoc(zval *doc, zapval *value, zapval *flags, zapval *cas TSRMLS_DC)
{
object_init_ex(doc, metadoc_ce);
if (value) {
zend_update_property(metadoc_ce, doc,
"value", sizeof("value") - 1, zapval_zvalptr_p(value) TSRMLS_CC);
}
if (flags) {
zend_update_property(metadoc_ce, doc,
"flags", sizeof("flags") - 1, zapval_zvalptr_p(flags) TSRMLS_CC);
}
if (cas) {
zend_update_property(metadoc_ce, doc,
"cas", sizeof("cas") - 1, zapval_zvalptr_p(cas) TSRMLS_CC);
}
return SUCCESS;
}