cleanup TSRMLS_C macro
- only used on PHP 5 (not supported by this ext.) - not needed on PHP 7 - removed from PHP 8
This commit is contained in:
parent
912ab43641
commit
40a2bd60e4
18
pdlib.cc
18
pdlib.cc
@ -103,10 +103,10 @@ const zend_function_entry cnn_face_detection_class_methods[] = {
|
||||
PHP_FE_END
|
||||
};
|
||||
|
||||
zend_object* php_cnn_face_detection_new(zend_class_entry *class_type TSRMLS_DC)
|
||||
zend_object* php_cnn_face_detection_new(zend_class_entry *class_type)
|
||||
{
|
||||
cnn_face_detection *cfd = (cnn_face_detection*)ecalloc(1, sizeof(cnn_face_detection));
|
||||
zend_object_std_init(&cfd->std, class_type TSRMLS_CC);
|
||||
zend_object_std_init(&cfd->std, class_type);
|
||||
object_properties_init(&cfd->std, class_type);
|
||||
cfd->std.handlers = &cnn_face_detection_obj_handlers; //zend_get_std_object_handlers();
|
||||
|
||||
@ -126,10 +126,10 @@ const zend_function_entry face_landmark_detection_class_methods[] = {
|
||||
PHP_FE_END
|
||||
};
|
||||
|
||||
zend_object* php_face_landmark_detection_new(zend_class_entry *class_type TSRMLS_DC)
|
||||
zend_object* php_face_landmark_detection_new(zend_class_entry *class_type)
|
||||
{
|
||||
face_landmark_detection *fld = (face_landmark_detection*)ecalloc(1, sizeof(face_landmark_detection));
|
||||
zend_object_std_init(&fld->std, class_type TSRMLS_CC);
|
||||
zend_object_std_init(&fld->std, class_type);
|
||||
object_properties_init(&fld->std, class_type);
|
||||
fld->std.handlers = &face_landmark_detection_obj_handlers;
|
||||
|
||||
@ -149,10 +149,10 @@ const zend_function_entry face_recognition_class_methods[] = {
|
||||
PHP_FE_END
|
||||
};
|
||||
|
||||
zend_object* php_face_recognition_new(zend_class_entry *class_type TSRMLS_DC)
|
||||
zend_object* php_face_recognition_new(zend_class_entry *class_type)
|
||||
{
|
||||
face_recognition *fr = (face_recognition*)ecalloc(1, sizeof(face_recognition));
|
||||
zend_object_std_init(&fr->std, class_type TSRMLS_CC);
|
||||
zend_object_std_init(&fr->std, class_type);
|
||||
object_properties_init(&fr->std, class_type);
|
||||
fr->std.handlers = &face_recognition_obj_handlers;
|
||||
|
||||
@ -174,7 +174,7 @@ PHP_MINIT_FUNCTION(pdlib)
|
||||
// CnnFaceDetection class definition
|
||||
//
|
||||
INIT_CLASS_ENTRY(ce, "CnnFaceDetection", cnn_face_detection_class_methods);
|
||||
cnn_face_detection_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
cnn_face_detection_ce = zend_register_internal_class(&ce);
|
||||
cnn_face_detection_ce->create_object = php_cnn_face_detection_new;
|
||||
memcpy(&cnn_face_detection_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
cnn_face_detection_obj_handlers.offset = XtOffsetOf(cnn_face_detection, std);
|
||||
@ -183,7 +183,7 @@ PHP_MINIT_FUNCTION(pdlib)
|
||||
// FaceLandmarkDetection class definition
|
||||
//
|
||||
INIT_CLASS_ENTRY(ce, "FaceLandmarkDetection", face_landmark_detection_class_methods);
|
||||
face_landmark_detection_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
face_landmark_detection_ce = zend_register_internal_class(&ce);
|
||||
face_landmark_detection_ce->create_object = php_face_landmark_detection_new;
|
||||
memcpy(&face_landmark_detection_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
face_landmark_detection_obj_handlers.offset = XtOffsetOf(face_landmark_detection, std);
|
||||
@ -192,7 +192,7 @@ PHP_MINIT_FUNCTION(pdlib)
|
||||
// FaceRecognition class definition
|
||||
//
|
||||
INIT_CLASS_ENTRY(ce, "FaceRecognition", face_recognition_class_methods);
|
||||
face_recognition_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
face_recognition_ce = zend_register_internal_class(&ce);
|
||||
face_recognition_ce->create_object = php_face_recognition_new;
|
||||
memcpy(&face_recognition_obj_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
face_recognition_obj_handlers.offset = XtOffsetOf(face_recognition, std);
|
||||
|
@ -66,13 +66,13 @@ ZEND_TSRMLS_CACHE_EXTERN()
|
||||
/* Tries to find given key in array */ \
|
||||
data##key = zend_hash_str_find(hashtable, #key, sizeof(#key)-1); \
|
||||
if (data##key == nullptr) { \
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, #error_key_missing); \
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, #error_key_missing); \
|
||||
return; \
|
||||
} \
|
||||
\
|
||||
/* We also need to check proper type of value in associative array */ \
|
||||
if (Z_TYPE_P(data##key) != IS_LONG) { \
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, #error_key_not_long); \
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, #error_key_not_long); \
|
||||
return; \
|
||||
} \
|
||||
zend_long key = Z_LVAL_P(data##key); \
|
||||
|
@ -20,7 +20,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
||||
if(zend_parse_parameters(ZEND_NUM_ARGS(), "a", &edges_arg) == FAILURE){
|
||||
zend_throw_exception_ex(
|
||||
zend_ce_exception,
|
||||
0 TSRMLS_CC,
|
||||
0,
|
||||
"Unable to parse edges in dlib_chinese_whispers");
|
||||
return;
|
||||
}
|
||||
@ -43,7 +43,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
||||
if (Z_TYPE_P(edge) != IS_ARRAY) {
|
||||
zend_throw_exception_ex(
|
||||
zend_ce_exception,
|
||||
0 TSRMLS_CC,
|
||||
0,
|
||||
"Each edge provided in array needs to be numeric array of 2 elements");
|
||||
return;
|
||||
}
|
||||
@ -55,7 +55,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
||||
if (zend_hash_num_elements(edge_hash) != 2) {
|
||||
zend_throw_exception_ex(
|
||||
zend_ce_exception,
|
||||
0 TSRMLS_CC,
|
||||
0,
|
||||
"Edges need to contain exactly two elements");
|
||||
return;
|
||||
}
|
||||
@ -66,7 +66,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
||||
!zend_hash_index_exists(edge_hash, 1)) {
|
||||
zend_throw_exception_ex(
|
||||
zend_ce_exception,
|
||||
0 TSRMLS_CC,
|
||||
0,
|
||||
"Edge should be numeric array with integer keys");
|
||||
return;
|
||||
}
|
||||
@ -78,7 +78,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
||||
if ((Z_TYPE_P(elem_i) != IS_LONG) || (Z_TYPE_P(elem_j) != IS_LONG)) {
|
||||
zend_throw_exception_ex(
|
||||
zend_ce_exception,
|
||||
0 TSRMLS_CC,
|
||||
0,
|
||||
"Both elements in each edge must be of long type");
|
||||
return;
|
||||
}
|
||||
@ -97,7 +97,7 @@ PHP_FUNCTION(dlib_chinese_whispers)
|
||||
}
|
||||
} catch (exception& e)
|
||||
{
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ PHP_METHOD(CnnFaceDetection, __construct)
|
||||
cnn_face_detection *cfd = Z_CNN_FACE_DETECTION_P(getThis());
|
||||
|
||||
if (NULL == cfd) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to find obj in CnnFaceDetection::__construct()");
|
||||
php_error_docref(NULL, E_ERROR, "Unable to find obj in CnnFaceDetection::__construct()");
|
||||
return;
|
||||
}
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
|
||||
&sz_cnn_face_detection_model_path, &cnn_face_detection_model_path_len) == FAILURE){
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse face_detection_model_path");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse face_detection_model_path");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ PHP_METHOD(CnnFaceDetection, __construct)
|
||||
deserialize(cnn_face_detection_model_path) >> *pnet;
|
||||
cfd->net = pnet;
|
||||
} catch (exception& e) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ PHP_METHOD(CnnFaceDetection, detect)
|
||||
long upsample_num = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &img_path, &img_path_len, &upsample_num) == FAILURE){
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse detect arguments");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse detect arguments");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ PHP_METHOD(CnnFaceDetection, detect)
|
||||
}
|
||||
catch (exception& e)
|
||||
{
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ PHP_FUNCTION(dlib_face_detection)
|
||||
long upsample_num = 0;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &img_path, &img_path_len, &upsample_num) == FAILURE) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse dlib_face_detection arguments");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse dlib_face_detection arguments");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
try {
|
||||
|
@ -78,14 +78,14 @@ PHP_METHOD(FaceLandmarkDetection, __construct)
|
||||
face_landmark_detection *fld = Z_FACE_LANDMARK_DETECTION_P(getThis());
|
||||
|
||||
if (nullptr == fld) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to find obj in FaceLandmarkDetection::__construct()");
|
||||
php_error_docref(NULL, E_ERROR, "Unable to find obj in FaceLandmarkDetection::__construct()");
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse predictor model's path
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
|
||||
&sz_shape_predictor_file_path, &shape_predictor_file_path_len) == FAILURE){
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse shape_predictor_file_path");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse shape_predictor_file_path");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ PHP_METHOD(FaceLandmarkDetection, __construct)
|
||||
fld->sp = new shape_predictor;
|
||||
deserialize(shape_predictor_file_path) >> *(fld->sp);
|
||||
} catch (exception& e) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -115,7 +115,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
|
||||
// Parse path to image and bounding box. Bounding box is associative array of 4 elements - "top", "bottom", "left" and "right".
|
||||
//
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa", &img_path, &img_path_len, &bounding_box) == FAILURE){
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse detect arguments");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse detect arguments");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
|
||||
HashTable *bounding_box_hash = Z_ARRVAL_P(bounding_box);
|
||||
uint32_t bounding_box_num_elements = zend_hash_num_elements(bounding_box_hash);
|
||||
if (bounding_box_num_elements < 4) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Bounding box (second argument) needs to have at least 4 elements");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Bounding box (second argument) needs to have at least 4 elements");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ PHP_METHOD(FaceLandmarkDetection, detect)
|
||||
add_assoc_zval(return_value, "rect", &rect_arr);
|
||||
add_assoc_zval(return_value, "parts", &parts_arr);
|
||||
} catch (exception& e) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ PHP_METHOD(FaceRecognition, __construct)
|
||||
face_recognition *fr = Z_FACE_RECOGNITION_P(getThis());
|
||||
|
||||
if (NULL == fr) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to find obj in FaceRecognition::__construct()");
|
||||
php_error_docref(NULL, E_ERROR, "Unable to find obj in FaceRecognition::__construct()");
|
||||
return;
|
||||
}
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s",
|
||||
&sz_face_recognition_model_path, &face_recognition_model_path_len) == FAILURE){
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse face_recognition_model_path");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse face_recognition_model_path");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ PHP_METHOD(FaceRecognition, __construct)
|
||||
fr->net = new anet_type;
|
||||
deserialize(face_recognition_model_path) >> *(fr->net);
|
||||
} catch (exception& e) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -74,24 +74,24 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
|
||||
long num_jitters = 1;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa|l", &img_path, &img_path_len, &shape, &num_jitters) == FAILURE){
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Unable to parse computeDescriptor arguments");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to parse computeDescriptor arguments");
|
||||
return;
|
||||
}
|
||||
|
||||
HashTable *shape_hash = Z_ARRVAL_P(shape);
|
||||
uint32_t shape_hash_num_elements = zend_hash_num_elements(shape_hash);
|
||||
if (shape_hash_num_elements != 2) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Shape (second argument) needs to have exactly 2 elements - keys \"rect\" and \"parts\"");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Shape (second argument) needs to have exactly 2 elements - keys \"rect\" and \"parts\"");
|
||||
return;
|
||||
}
|
||||
|
||||
zval *rect_zval = zend_hash_str_find(shape_hash, "rect", sizeof("rect")-1);
|
||||
if (rect_zval == nullptr) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Shape (second argument) array needs to have \"rect\" key"); \
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Shape (second argument) array needs to have \"rect\" key"); \
|
||||
return;
|
||||
}
|
||||
if (Z_TYPE_P(rect_zval) != IS_ARRAY) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Value of shape's key \"rect\" must be array");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Value of shape's key \"rect\" must be array");
|
||||
return;
|
||||
}
|
||||
HashTable *rect_hash = Z_ARRVAL_P(rect_zval);
|
||||
@ -104,11 +104,11 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
|
||||
|
||||
zval *parts_zval = zend_hash_str_find(shape_hash, "parts", sizeof("parts")-1);
|
||||
if (parts_zval == nullptr) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Shape (second argument) array needs to have \"parts\" key"); \
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Shape (second argument) array needs to have \"parts\" key"); \
|
||||
return;
|
||||
}
|
||||
if (Z_TYPE_P(parts_zval) != IS_ARRAY) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Value of shape's key \"parts\" must be array");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Value of shape's key \"parts\" must be array");
|
||||
return;
|
||||
}
|
||||
HashTable *parts_hash = Z_ARRVAL_P(parts_zval);
|
||||
@ -117,7 +117,7 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
|
||||
point parts_points[parts_count];
|
||||
|
||||
if ((parts_count != 5) && (parts_count != 68)) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC,
|
||||
zend_throw_exception_ex(zend_ce_exception, 0,
|
||||
"The full_object_detection must use the iBUG 300W 68 point face landmark style or dlib's 5 point style");
|
||||
return;
|
||||
}
|
||||
@ -137,17 +137,17 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
|
||||
PARSE_POINT(x)
|
||||
PARSE_POINT(y)
|
||||
if (num_index > parts_count) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Internal error, bad parsing of parts array");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Internal error, bad parsing of parts array");
|
||||
return;
|
||||
}
|
||||
parts_points[num_index] = point(x, y);
|
||||
} else {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Values from parts array must be arrays with \"x\" and \"y\" keys");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Values from parts array must be arrays with \"x\" and \"y\" keys");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case HASH_KEY_IS_STRING:
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "Parts array must be indexed and it contains string keys");
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "Parts array must be indexed and it contains string keys");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
@ -183,7 +183,7 @@ PHP_METHOD(FaceRecognition, computeDescriptor)
|
||||
add_next_index_double(return_value, d);
|
||||
}
|
||||
} catch (exception& e) {
|
||||
zend_throw_exception_ex(zend_ce_exception, 0 TSRMLS_CC, "%s", e.what());
|
||||
zend_throw_exception_ex(zend_ce_exception, 0, "%s", e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user