4040%attribute(griddb::ExpirationInfo, int , divisionCount, get_division_count, set_division_count);
4141
4242// rename all method to camel cases
43- %rename(getErrorMessage) griddb::GSException::get_message;
4443%rename(" %(lowercamelcase)s" , %$isfunction) " " ;
4544
45+ // "getMessage" is a default final method of Exception class in PHP. So convert name into getErrorMessage
46+ %rename(getErrorMessage) griddb::GSException::get_message;
47+
48+ // "default" is a PHP keyword. So convert name into DEFAULT_TYPE
49+ %rename(DEFAULT_TYPE) griddb::IndexType::DEFAULT;
50+
4651/*
4752 * ignore unnecessary functions
4853 */
531536}
532537
533538/* *
534- * Typemaps for put_row() function
535- */
539+ * Typemaps for RowSet::update() and Container::put() function
540+ * The argument "GSRow *row" is not used in the function body, it only for the purpose of typemap matching pattern
541+ * The actual input data is store in class member and can be get by function getGSRowPtr()
542+ */
536543%typemap(in, fragment = " convertToFieldWithType" ) (GSRow *row)
537544 (HashTable *arr, HashPosition pos, zval* data) {
538- $1 = NULL ;
539- const int size = 60 ;
545+ const int SIZE = 60 ;
540546 if (Z_TYPE_P (&$input) != IS_ARRAY) {
541547 SWIG_PHP_Error (E_ERROR, " Expected an array as input" );
542548 }
556562 zend_hash_move_forward_ex (arr, &pos)) {
557563 GSType type = typeList[pos];
558564 if (!(convertToFieldWithType (tmpRow, pos, data, type))) {
559- char gsType[size ];
565+ char gsType[SIZE ];
560566 sprintf (gsType, " Invalid value for column %d, type should be : %d" , pos, type);
561567 SWIG_PHP_Error (E_ERROR, gsType);
562568 }
569575 */
570576%fragment(" convertToRowKeyFieldWithType" , " header" ) {
571577static bool convertToRowKeyFieldWithType (griddb::Field &field, zval* value, GSType type) {
578+ bool vbool;
572579 field.type = type;
573580
574581 if (Z_TYPE_P (value) == IS_NULL) {
@@ -603,7 +610,10 @@ static bool convertToRowKeyFieldWithType(griddb::Field &field, zval* value, GSTy
603610 field.value .asLong = Z_LVAL_P (value);
604611 break ;
605612 case (GS_TYPE_TIMESTAMP):
606- return convertZvalValueToGSTimestamp (value, &field.value .asTimestamp );
613+ vbool = convertZvalValueToGSTimestamp (value, &field.value .asTimestamp );
614+ if (!vbool) {
615+ return false ;
616+ }
607617 break ;
608618 default :
609619 // Not support for now
@@ -749,8 +759,8 @@ static bool getRowFields(GSRow* row, int columnCount,
749759 */
750760%fragment(" convertTimestampToObject" , " header" ) {
751761static void convertTimestampToObject (GSTimestamp* timestamp, zval* dateTime) {
752- const int size = 60 ;
753- char timeStr[size ];
762+ const int SIZE = 60 ;
763+ char timeStr[SIZE ];
754764 zval functionNameZval;
755765 zval formatStringZval;
756766 zval formattedTimePhp;
@@ -790,7 +800,7 @@ static void convertTimestampToObject(GSTimestamp* timestamp, zval* dateTime) {
790800 bool retVal;
791801 int errorColumn;
792802 GSType errorType;
793- const int size = 60 ;
803+ const int SIZE = 60 ;
794804
795805 // Get row pointer
796806 GSRow* row = arg1->getGSRowPtr ();
@@ -803,7 +813,7 @@ static void convertTimestampToObject(GSTimestamp* timestamp, zval* dateTime) {
803813 return_value);
804814
805815 if (retVal == false ) {
806- char errorMsg[size ];
816+ char errorMsg[SIZE ];
807817 sprintf (errorMsg, " Can't get data for field %d with type %d" , errorColumn, errorType);
808818 SWIG_PHP_Error (E_ERROR, errorMsg);
809819 }
@@ -827,7 +837,7 @@ static void convertTimestampToObject(GSTimestamp* timestamp, zval* dateTime) {
827837%typemap(argout, fragment = " getRowFields" ) (GSRowSetType* type, bool * hasNextRow,
828838 griddb::QueryAnalysisEntry** queryAnalysis, griddb::AggregationResult** aggResult) {
829839
830- const int size = 60 ;
840+ const int SIZE = 60 ;
831841 switch (*$1 ) {
832842 case (GS_ROW_SET_CONTAINER_ROWS): {
833843 bool retVal;
@@ -842,7 +852,7 @@ static void convertTimestampToObject(GSTimestamp* timestamp, zval* dateTime) {
842852 arg1->getGSTypeList (),
843853 &errorColumn, &errorType, return_value);
844854 if (retVal == false ) {
845- char errorMsg[size ];
855+ char errorMsg[SIZE ];
846856 sprintf (errorMsg, " Can't get data for field %d with type%d" , errorColumn, errorType);
847857 SWIG_PHP_Error (E_ERROR, errorMsg);
848858 }
@@ -890,4 +900,16 @@ static void convertTimestampToObject(GSTimestamp* timestamp, zval* dateTime) {
890900 }
891901}
892902
903+ /*
904+ * Typemap for TimestampUtils::get_time_millis: convert DateTime object from target language to timestamp with millisecond in C++ layer
905+ */
906+ %typemap(in, fragement = " convertZvalValueToGSTimestamp" ) (int64_t timestamp){
907+ bool vbool;
908+ GSTimestamp timestampValue;
909+ vbool = convertZvalValueToGSTimestamp (&$input, ×tampValue);
910+ if (!vbool){
911+ SWIG_PHP_Error (E_ERROR, " Expected a DateTime object as input" );
912+ }
913+ $1 = timestampValue;
914+ }
893915
0 commit comments