Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
9f6aceaa
Commit
9f6aceaa
authored
Dec 12, 2017
by
Bo Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add PROTOBUF_ENABLE_TIMESTAMP to let user decide whether timestamp util
can be used at install time.
parent
b1386e77
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
message.c
php/ext/google/protobuf/message.c
+12
-1
test.sh
php/tests/test.sh
+1
-1
No files found.
php/ext/google/protobuf/message.c
View file @
9f6aceaa
...
...
@@ -29,9 +29,12 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <php.h>
#include <ext/date/php_date.h>
#include <stdlib.h>
#ifdef PROTOBUF_ENABLE_TIMESTAMP
#include <ext/date/php_date.h>
#endif
#include "protobuf.h"
#include "utf8.h"
...
...
@@ -1121,6 +1124,7 @@ PHP_PROTO_FIELD_ACCESSORS(Timestamp, timestamp, Seconds, "seconds")
PHP_PROTO_FIELD_ACCESSORS
(
Timestamp
,
timestamp
,
Nanos
,
"nanos"
)
PHP_METHOD
(
Timestamp
,
fromDateTime
)
{
#ifdef PROTOBUF_ENABLE_TIMESTAMP
zval
*
datetime
;
zval
member
;
...
...
@@ -1149,9 +1153,13 @@ PHP_METHOD(Timestamp, fromDateTime) {
storage
=
message_data
(
self
);
memory
=
slot_memory
(
self
->
descriptor
->
layout
,
storage
,
field
);
*
(
int32_t
*
)
memory
=
0
;
#else
zend_error
(
E_USER_ERROR
,
"fromDateTime needs date extension."
);
#endif
}
PHP_METHOD
(
Timestamp
,
toDateTime
)
{
#ifdef PROTOBUF_ENABLE_TIMESTAMP
zval
datetime
;
php_date_instantiate
(
php_date_get_date_ce
(),
&
datetime
TSRMLS_CC
);
php_date_obj
*
dateobj
=
UNBOX
(
php_date_obj
,
&
datetime
);
...
...
@@ -1184,6 +1192,9 @@ PHP_METHOD(Timestamp, toDateTime) {
zval
*
datetime_ptr
=
&
datetime
;
PHP_PROTO_RETVAL_ZVAL
(
datetime_ptr
);
#else
zend_error
(
E_USER_ERROR
,
"toDateTime needs date extension."
);
#endif
}
// -----------------------------------------------------------------------------
...
...
php/tests/test.sh
View file @
9f6aceaa
...
...
@@ -5,7 +5,7 @@ pushd ../ext/google/protobuf/
make clean
||
true
set
-e
# Add following in configure for debug: --enable-debug CFLAGS='-g -O0'
phpize
&&
./configure
CFLAGS
=
'-g -O0'
&&
make
phpize
&&
./configure
CFLAGS
=
'-g -O0
-DPROTOBUF_ENABLE_TIMESTAMP
'
&&
make
popd
tests
=(
array_test.php encode_decode_test.php generated_class_test.php generated_phpdoc_test.php map_field_test.php well_known_test.php generated_service_test.php descriptors_test.php
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment