Skip to content

Commit 5638c99

Browse files
committed
code reformat & update package.xml
1 parent dd1eaa9 commit 5638c99

File tree

4 files changed

+756
-634
lines changed

4 files changed

+756
-634
lines changed

SeasClick.cpp

Lines changed: 109 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ map<int, Client*> clientMap;
4545

4646
#ifdef COMPILE_DL_SEASCLICK
4747
extern "C" {
48-
ZEND_GET_MODULE(SeasClick)
48+
ZEND_GET_MODULE(SeasClick)
4949
}
5050
#endif
5151

5252
PHP_FUNCTION(SeasClick_version)
5353
{
54-
SC_RETURN_STRINGL(PHP_SEASCLICK_VERSION, strlen(PHP_SEASCLICK_VERSION));
54+
SC_RETURN_STRINGL(PHP_SEASCLICK_VERSION, strlen(PHP_SEASCLICK_VERSION));
5555
}
5656

5757
static PHP_METHOD(SEASCLICK_RES_NAME, __construct);
@@ -81,9 +81,10 @@ ZEND_ARG_INFO(0, params)
8181
ZEND_END_ARG_INFO()
8282

8383
/* {{{ SeasClick_functions[] */
84-
const zend_function_entry SeasClick_functions[] = {
85-
PHP_FE(SeasClick_version, NULL)
86-
PHP_FE_END
84+
const zend_function_entry SeasClick_functions[] =
85+
{
86+
PHP_FE(SeasClick_version, NULL)
87+
PHP_FE_END
8788
};
8889
/* }}} */
8990

@@ -116,61 +117,62 @@ PHP_MINIT_FUNCTION(SeasClick)
116117
zend_declare_property_bool(SeasClick_ce, "compression", strlen("compression"), false, ZEND_ACC_PROTECTED TSRMLS_CC);
117118

118119
SeasClick_ce->ce_flags = ZEND_ACC_IMPLICIT_PUBLIC;
119-
return SUCCESS;
120+
return SUCCESS;
120121
}
121122
/* }}} */
122123

123124
/* {{{ PHP_MSHUTDOWN_FUNCTION
124125
*/
125126
PHP_MSHUTDOWN_FUNCTION(SeasClick)
126127
{
127-
return SUCCESS;
128+
return SUCCESS;
128129
}
129130
/* }}} */
130131

131132
/* {{{ PHP_RINIT_FUNCTION
132133
*/
133134
PHP_RINIT_FUNCTION(SeasClick)
134135
{
135-
return SUCCESS;
136+
return SUCCESS;
136137
}
137138
/* }}} */
138139

139140
/* {{{ PHP_RSHUTDOWN_FUNCTION
140141
*/
141142
PHP_RSHUTDOWN_FUNCTION(SeasClick)
142143
{
143-
return SUCCESS;
144+
return SUCCESS;
144145
}
145146
/* }}} */
146147

147148
/* {{{ PHP_MINFO_FUNCTION
148149
*/
149150
PHP_MINFO_FUNCTION(SeasClick)
150151
{
151-
php_info_print_table_start();
152-
php_info_print_table_header(2, "SeasClick support", "enabled");
152+
php_info_print_table_start();
153+
php_info_print_table_header(2, "SeasClick support", "enabled");
153154
php_info_print_table_row(2, "Version", PHP_SEASCLICK_VERSION);
154155
php_info_print_table_row(2, "Author", "SeasX Group[email: [email protected]]");
155-
php_info_print_table_end();
156+
php_info_print_table_end();
156157

157-
DISPLAY_INI_ENTRIES();
158+
DISPLAY_INI_ENTRIES();
158159
}
159160
/* }}} */
160161

161162
/* {{{ SeasClick_module_entry
162163
*/
163-
zend_module_entry SeasClick_module_entry = {
164-
STANDARD_MODULE_HEADER,
165-
SEASCLICK_RES_NAME,
166-
SeasClick_functions,
167-
PHP_MINIT(SeasClick),
168-
PHP_MSHUTDOWN(SeasClick),
169-
PHP_RINIT(SeasClick),
170-
PHP_RSHUTDOWN(SeasClick),
171-
PHP_MINFO(SeasClick),
172-
PHP_SEASCLICK_VERSION,
173-
STANDARD_MODULE_PROPERTIES
164+
zend_module_entry SeasClick_module_entry =
165+
{
166+
STANDARD_MODULE_HEADER,
167+
SEASCLICK_RES_NAME,
168+
SeasClick_functions,
169+
PHP_MINIT(SeasClick),
170+
PHP_MSHUTDOWN(SeasClick),
171+
PHP_RINIT(SeasClick),
172+
PHP_RSHUTDOWN(SeasClick),
173+
PHP_MINFO(SeasClick),
174+
PHP_SEASCLICK_VERSION,
175+
STANDARD_MODULE_PROPERTIES
174176
};
175177
/* }}} */
176178

@@ -181,14 +183,15 @@ PHP_METHOD(SEASCLICK_RES_NAME, __construct)
181183
zval *connectParames;
182184

183185
#ifndef FAST_ZPP
184-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &connectParames) == FAILURE) {
186+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &connectParames) == FAILURE)
187+
{
185188
return;
186189
}
187190
#else
188191
#undef IS_UNDEF
189192
#define IS_UNDEF Z_EXPECTED_LONG
190193
ZEND_PARSE_PARAMETERS_START(1, 1)
191-
Z_PARAM_ARRAY(connectParames)
194+
Z_PARAM_ARRAY(connectParames)
192195
ZEND_PARSE_PARAMETERS_END();
193196
#undef IS_UNDEF
194197
#define IS_UNDEF 0
@@ -222,10 +225,11 @@ PHP_METHOD(SEASCLICK_RES_NAME, __construct)
222225
zval *compression = sc_zend_read_property(SeasClick_ce, this_obj, "compression", sizeof("compression") - 1, 0);
223226

224227
ClientOptions Options = ClientOptions()
225-
.SetHost(Z_STRVAL_P(host))
226-
.SetPort(Z_LVAL_P(port))
227-
.SetPingBeforeQuery(false);
228-
if (Z_TYPE_P(compression) == IS_TRUE) {
228+
.SetHost(Z_STRVAL_P(host))
229+
.SetPort(Z_LVAL_P(port))
230+
.SetPingBeforeQuery(false);
231+
if (Z_TYPE_P(compression) == IS_TRUE)
232+
{
229233
Options = Options.SetCompressionMethod(CompressionMethod::LZ4);
230234
}
231235

@@ -250,13 +254,16 @@ PHP_METHOD(SEASCLICK_RES_NAME, __construct)
250254
Options = Options.SetPassword(Z_STRVAL_P(value));
251255
}
252256

253-
try {
257+
try
258+
{
254259
Client *client = new Client(Options);
255260
int key = Z_OBJ_HANDLE(*this_obj);
256261

257262
clientMap.insert(std::pair<int, Client*>(key, client));
258263

259-
} catch (const std::exception& e) {
264+
}
265+
catch (const std::exception& e)
266+
{
260267
sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
261268
}
262269

@@ -280,9 +287,12 @@ void getInsertSql(string *sql, char *table_name, zval *columns)
280287
SC_HASHTABLE_FOREACH_START2(columns_ht, key, keylen, keytype, pzval)
281288
{
282289
convert_to_string(pzval);
283-
if (index >= (count - 1)) {
290+
if (index >= (count - 1))
291+
{
284292
fields_section << (string)Z_STRVAL_P(pzval);
285-
} else {
293+
}
294+
else
295+
{
286296
fields_section << (string)Z_STRVAL_P(pzval) << ",";
287297
}
288298
index++;
@@ -300,24 +310,28 @@ PHP_METHOD(SEASCLICK_RES_NAME, select)
300310
zval* params = NULL;
301311

302312
#ifndef FAST_ZPP
303-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &sql, &l_sql, &params) == FAILURE) {
313+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &sql, &l_sql, &params) == FAILURE)
314+
{
304315
return;
305316
}
306317
#else
307318
#undef IS_UNDEF
308319
#define IS_UNDEF Z_EXPECTED_LONG
309320
ZEND_PARSE_PARAMETERS_START(1, 2)
310-
Z_PARAM_STRING(sql, l_sql)
311-
Z_PARAM_OPTIONAL
312-
Z_PARAM_ARRAY(params)
321+
Z_PARAM_STRING(sql, l_sql)
322+
Z_PARAM_OPTIONAL
323+
Z_PARAM_ARRAY(params)
313324
ZEND_PARSE_PARAMETERS_END();
314325
#undef IS_UNDEF
315326
#define IS_UNDEF 0
316327
#endif
317-
try {
328+
try
329+
{
318330
string sql_s = (string)sql;
319-
if (ZEND_NUM_ARGS() > 1 && params != NULL) {
320-
if (Z_TYPE_P(params) != IS_ARRAY) {
331+
if (ZEND_NUM_ARGS() > 1 && params != NULL)
332+
{
333+
if (Z_TYPE_P(params) != IS_ARRAY)
334+
{
321335
throw std::runtime_error("The second argument to the select function must be an array");
322336
}
323337

@@ -341,21 +355,25 @@ PHP_METHOD(SEASCLICK_RES_NAME, select)
341355
array_init(return_value);
342356

343357
client->Select(sql_s, [return_value](const Block& block)
358+
{
359+
zval *return_tmp;
360+
for (size_t row = 0; row < block.GetRowCount(); ++row)
344361
{
345-
zval *return_tmp;
346-
for (size_t row = 0; row < block.GetRowCount(); ++row) {
347-
SC_MAKE_STD_ZVAL(return_tmp);
348-
array_init(return_tmp);
349-
for (size_t column = 0; column < block.GetColumnCount(); ++column) {
350-
string column_name = block.GetColumnName(column);
351-
convertToZval(return_tmp, block[column], row, column_name, 0);
352-
}
353-
add_next_index_zval(return_value, return_tmp);
362+
SC_MAKE_STD_ZVAL(return_tmp);
363+
array_init(return_tmp);
364+
for (size_t column = 0; column < block.GetColumnCount(); ++column)
365+
{
366+
string column_name = block.GetColumnName(column);
367+
convertToZval(return_tmp, block[column], row, column_name, 0);
354368
}
369+
add_next_index_zval(return_value, return_tmp);
355370
}
356-
);
371+
}
372+
);
357373

358-
} catch (const std::exception& e) {
374+
}
375+
catch (const std::exception& e)
376+
{
359377
sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
360378
}
361379
}
@@ -373,22 +391,24 @@ PHP_METHOD(SEASCLICK_RES_NAME, insert)
373391
string sql;
374392

375393
#ifndef FAST_ZPP
376-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szz", &table, &l_table, &columns, &values) == FAILURE) {
394+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szz", &table, &l_table, &columns, &values) == FAILURE)
395+
{
377396
return;
378397
}
379398
#else
380399
#undef IS_UNDEF
381400
#define IS_UNDEF Z_EXPECTED_LONG
382401
ZEND_PARSE_PARAMETERS_START(3, 3)
383-
Z_PARAM_STRING(table, l_table)
384-
Z_PARAM_ARRAY(columns)
385-
Z_PARAM_ARRAY(values)
402+
Z_PARAM_STRING(table, l_table)
403+
Z_PARAM_ARRAY(columns)
404+
Z_PARAM_ARRAY(values)
386405
ZEND_PARSE_PARAMETERS_END();
387406
#undef IS_UNDEF
388407
#define IS_UNDEF 0
389408
#endif
390409

391-
try {
410+
try
411+
{
392412
HashTable *columns_ht = Z_ARRVAL_P(columns);
393413
HashTable *values_ht = Z_ARRVAL_P(values);
394414
size_t columns_count = zend_hash_num_elements(columns_ht);
@@ -411,11 +431,13 @@ PHP_METHOD(SEASCLICK_RES_NAME, insert)
411431

412432
SC_HASHTABLE_FOREACH_START2(values_ht, str_key, str_keylen, keytype, pzval)
413433
{
414-
if (Z_TYPE_P(pzval) != IS_ARRAY) {
434+
if (Z_TYPE_P(pzval) != IS_ARRAY)
435+
{
415436
throw std::runtime_error("The insert function needs to pass in a two-dimensional array");
416437
}
417438
fzval = sc_zend_hash_index_find(Z_ARRVAL_P(pzval), i);
418-
if (NULL == fzval) {
439+
if (NULL == fzval)
440+
{
419441
throw std::runtime_error("The number of parameters inserted per line is inconsistent");
420442
}
421443
sc_zval_add_ref(fzval);
@@ -432,11 +454,12 @@ PHP_METHOD(SEASCLICK_RES_NAME, insert)
432454
int key = Z_OBJ_HANDLE(*getThis());
433455
Client *client = clientMap.at(key);
434456

435-
client->InsertQuery(sql, [&blockQuery](const Block& block) {
436-
blockQuery = block;
437-
}
438-
);
439-
457+
client->InsertQuery(sql, [&blockQuery](const Block& block)
458+
{
459+
blockQuery = block;
460+
}
461+
);
462+
440463
Block blockInsert;
441464
size_t index = 0;
442465

@@ -450,7 +473,9 @@ PHP_METHOD(SEASCLICK_RES_NAME, insert)
450473
client->InsertData(blockInsert);
451474
sc_zval_ptr_dtor(&return_should);
452475

453-
} catch (const std::exception& e) {
476+
}
477+
catch (const std::exception& e)
478+
{
454479
sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
455480
}
456481
RETURN_TRUE;
@@ -466,25 +491,29 @@ PHP_METHOD(SEASCLICK_RES_NAME, execute)
466491
zval* params = NULL;
467492

468493
#ifndef FAST_ZPP
469-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &sql, &l_sql, &params) == FAILURE) {
494+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &sql, &l_sql, &params) == FAILURE)
495+
{
470496
return;
471497
}
472498
#else
473499
#undef IS_UNDEF
474500
#define IS_UNDEF Z_EXPECTED_LONG
475501
ZEND_PARSE_PARAMETERS_START(1, 2)
476-
Z_PARAM_STRING(sql, l_sql)
477-
Z_PARAM_OPTIONAL
478-
Z_PARAM_ARRAY(params)
502+
Z_PARAM_STRING(sql, l_sql)
503+
Z_PARAM_OPTIONAL
504+
Z_PARAM_ARRAY(params)
479505
ZEND_PARSE_PARAMETERS_END();
480506
#undef IS_UNDEF
481507
#define IS_UNDEF 0
482508
#endif
483509

484-
try {
510+
try
511+
{
485512
string sql_s = (string)sql;
486-
if (ZEND_NUM_ARGS() > 1 && params != NULL) {
487-
if (Z_TYPE_P(params) != IS_ARRAY) {
513+
if (ZEND_NUM_ARGS() > 1 && params != NULL)
514+
{
515+
if (Z_TYPE_P(params) != IS_ARRAY)
516+
{
488517
throw std::runtime_error("The second argument to the select function must be an array");
489518
}
490519

@@ -506,7 +535,9 @@ PHP_METHOD(SEASCLICK_RES_NAME, execute)
506535
Client *client = clientMap.at(key);
507536
client->Execute(sql_s);
508537

509-
} catch (const std::exception& e) {
538+
}
539+
catch (const std::exception& e)
540+
{
510541
sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
511542
}
512543
RETURN_TRUE;
@@ -517,13 +548,16 @@ PHP_METHOD(SEASCLICK_RES_NAME, execute)
517548
*/
518549
PHP_METHOD(SEASCLICK_RES_NAME, __destruct)
519550
{
520-
try {
551+
try
552+
{
521553
int key = Z_OBJ_HANDLE(*getThis());
522554
Client *client = clientMap.at(key);
523555
delete client;
524556
clientMap.erase(key);
525557

526-
} catch (const std::exception& e) {
558+
}
559+
catch (const std::exception& e)
560+
{
527561
sc_zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC);
528562
}
529563
RETURN_TRUE;
File renamed without changes.

0 commit comments

Comments
 (0)