From fe9d31105d0e0871b78fb7c672e729775b8e2473 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= Date: Fri, 3 Apr 2015 10:47:59 +0200 Subject: [PATCH] [hkl] no more hkl_engine_list_add method the logic was moved into the hkl_engine_init method. The modification was done with a .cocci file. --- hkl/hkl-engine-e4c.c | 18 +++++++++--------- hkl/hkl-engine-e6c.c | 10 +++++----- hkl/hkl-engine-k4c.c | 8 ++++---- hkl/hkl-engine-k6c.c | 24 ++++++++++++------------ hkl/hkl-engine-petra3-p09-eh2.c | 2 +- hkl/hkl-engine-soleil-sirius-turret.c | 8 ++++---- hkl/hkl-engine-soleil-sixs-med.c | 24 ++++++++++++------------ hkl/hkl-engine-template.c | 10 +++++----- hkl/hkl-engine-zaxis.c | 8 ++++---- hkl/hkl-pseudoaxis-private.h | 24 ++---------------------- scripts/enginelist.cocci | 6 ++++++ 11 files changed, 64 insertions(+), 78 deletions(-) create mode 100644 scripts/enginelist.cocci diff --git a/hkl/hkl-engine-e4c.c b/hkl/hkl-engine-e4c.c index 852e6fd5..12140647 100644 --- a/hkl/hkl-engine-e4c.c +++ b/hkl/hkl-engine-e4c.c @@ -216,9 +216,9 @@ static HklEngineList *hkl_engine_list_new_eulerian4C_vertical(const HklFactory * { HklEngineList *self = hkl_engine_list_new(); - hkl_engine_list_add(self, hkl_engine_e4c_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_e4c_psi_new(self)); - hkl_engine_list_add(self, hkl_engine_q_new(self)); + hkl_engine_e4c_hkl_new(self); + hkl_engine_e4c_psi_new(self); + hkl_engine_q_new(self); return self; } @@ -264,9 +264,9 @@ static HklEngineList *hkl_engine_list_new_soleil_mars(const HklFactory *factory) { HklEngineList *self = hkl_engine_list_new(); - hkl_engine_list_add(self, hkl_engine_e4c_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_e4c_psi_new(self)); - hkl_engine_list_add(self, hkl_engine_q_new(self)); + hkl_engine_e4c_hkl_new(self); + hkl_engine_e4c_psi_new(self); + hkl_engine_q_new(self); return self; } @@ -311,9 +311,9 @@ static HklEngineList *hkl_engine_list_new_eulerian4C_horizontal(const HklFactory { HklEngineList *self = hkl_engine_list_new(); - hkl_engine_list_add(self, hkl_engine_e4c_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_e4c_psi_new(self)); - hkl_engine_list_add(self, hkl_engine_q_new(self)); + hkl_engine_e4c_hkl_new(self); + hkl_engine_e4c_psi_new(self); + hkl_engine_q_new(self); return self; } diff --git a/hkl/hkl-engine-e6c.c b/hkl/hkl-engine-e6c.c index e314c057..6f991374 100644 --- a/hkl/hkl-engine-e6c.c +++ b/hkl/hkl-engine-e6c.c @@ -366,11 +366,11 @@ static HklEngineList *hkl_engine_list_new_eulerian6C(const HklFactory *factory) { HklEngineList *self = hkl_engine_list_new(); - hkl_engine_list_add(self, hkl_engine_e6c_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_e6c_psi_new(self)); - hkl_engine_list_add(self, hkl_engine_q2_new(self)); - hkl_engine_list_add(self, hkl_engine_qper_qpar_new(self)); - hkl_engine_list_add(self, hkl_engine_tth2_new(self)); + hkl_engine_e6c_hkl_new(self); + hkl_engine_e6c_psi_new(self); + hkl_engine_q2_new(self); + hkl_engine_qper_qpar_new(self); + hkl_engine_tth2_new(self); return self; } diff --git a/hkl/hkl-engine-k4c.c b/hkl/hkl-engine-k4c.c index f3bd8a49..9247a8d2 100644 --- a/hkl/hkl-engine-k4c.c +++ b/hkl/hkl-engine-k4c.c @@ -422,10 +422,10 @@ static HklEngineList *hkl_engine_list_new_kappa4C_vertical(const HklFactory *fac HklEngineList *self = hkl_engine_list_new(); self->geometries->multiply = hkl_geometry_list_multiply_k4c_real; - hkl_engine_list_add(self, hkl_engine_k4cv_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_eulerians_new(self)); - hkl_engine_list_add(self, hkl_engine_k4cv_psi_new(self)); - hkl_engine_list_add(self, hkl_engine_q_new(self)); + hkl_engine_k4cv_hkl_new(self); + hkl_engine_eulerians_new(self); + hkl_engine_k4cv_psi_new(self); + hkl_engine_q_new(self); return self; } diff --git a/hkl/hkl-engine-k6c.c b/hkl/hkl-engine-k6c.c index 7c8f76f9..224a4d7a 100644 --- a/hkl/hkl-engine-k6c.c +++ b/hkl/hkl-engine-k6c.c @@ -951,12 +951,12 @@ static HklEngineList *hkl_engine_list_new_kappa6C(const HklFactory *factory) HklEngineList *self = hkl_engine_list_new(); self->geometries->multiply = hkl_geometry_list_multiply_k6c_real; - hkl_engine_list_add(self, hkl_engine_k6c_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_eulerians_new(self)); - hkl_engine_list_add(self, hkl_engine_k6c_psi_new(self)); - hkl_engine_list_add(self, hkl_engine_q2_new(self)); - hkl_engine_list_add(self, hkl_engine_qper_qpar_new(self)); - hkl_engine_list_add(self, hkl_engine_tth2_new(self)); + hkl_engine_k6c_hkl_new(self); + hkl_engine_eulerians_new(self); + hkl_engine_k6c_psi_new(self); + hkl_engine_q2_new(self); + hkl_engine_qper_qpar_new(self); + hkl_engine_tth2_new(self); return self; } @@ -1007,12 +1007,12 @@ static HklEngineList *hkl_engine_list_new_soleil_sirius_kappa(const HklFactory * HklEngineList *self = hkl_engine_list_new(); self->geometries->multiply = hkl_geometry_list_multiply_k6c_real; - hkl_engine_list_add(self, hkl_engine_soleil_sirius_kappa_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_eulerians_new(self)); - hkl_engine_list_add(self, hkl_engine_soleil_sirius_kappa_psi_new(self)); - hkl_engine_list_add(self, hkl_engine_q2_new(self)); - hkl_engine_list_add(self, hkl_engine_qper_qpar_new(self)); - hkl_engine_list_add(self, hkl_engine_tth2_new(self)); + hkl_engine_soleil_sirius_kappa_hkl_new(self); + hkl_engine_eulerians_new(self); + hkl_engine_soleil_sirius_kappa_psi_new(self); + hkl_engine_q2_new(self); + hkl_engine_qper_qpar_new(self); + hkl_engine_tth2_new(self); return self; } diff --git a/hkl/hkl-engine-petra3-p09-eh2.c b/hkl/hkl-engine-petra3-p09-eh2.c index de2104a3..984d4d70 100644 --- a/hkl/hkl-engine-petra3-p09-eh2.c +++ b/hkl/hkl-engine-petra3-p09-eh2.c @@ -235,7 +235,7 @@ static HklEngineList *hkl_engine_list_new_petra3_p09_eh2(const HklFactory *facto { HklEngineList *self = hkl_engine_list_new(); - hkl_engine_list_add(self, hkl_engine_petra3_p09_eh2_hkl_new(self)); + hkl_engine_petra3_p09_eh2_hkl_new(self); return self; } diff --git a/hkl/hkl-engine-soleil-sirius-turret.c b/hkl/hkl-engine-soleil-sirius-turret.c index c52d824d..0d2ea36f 100644 --- a/hkl/hkl-engine-soleil-sirius-turret.c +++ b/hkl/hkl-engine-soleil-sirius-turret.c @@ -96,10 +96,10 @@ static HklEngineList *hkl_engine_list_new_soleil_sirius_turret(const HklFactory { HklEngineList *self = hkl_engine_list_new(); - hkl_engine_list_add(self, hkl_engine_soleil_sirius_turret_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_q2_new(self)); - hkl_engine_list_add(self, hkl_engine_qper_qpar_new(self)); - hkl_engine_list_add(self, hkl_engine_tth2_new(self)); + hkl_engine_soleil_sirius_turret_hkl_new(self); + hkl_engine_q2_new(self); + hkl_engine_qper_qpar_new(self); + hkl_engine_tth2_new(self); return self; } diff --git a/hkl/hkl-engine-soleil-sixs-med.c b/hkl/hkl-engine-soleil-sixs-med.c index 5ea501ca..a8b161af 100644 --- a/hkl/hkl-engine-soleil-sixs-med.c +++ b/hkl/hkl-engine-soleil-sixs-med.c @@ -338,10 +338,10 @@ static HklEngineList *hkl_engine_list_new_soleil_sixs_med_2_2(const HklFactory * { HklEngineList *self = hkl_engine_list_new(); - hkl_engine_list_add(self, hkl_engine_soleil_sixs_med_2_2_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_q2_new(self)); - hkl_engine_list_add(self, hkl_engine_qper_qpar_new(self)); - hkl_engine_list_add(self, hkl_engine_tth2_new(self)); + hkl_engine_soleil_sixs_med_2_2_hkl_new(self); + hkl_engine_q2_new(self); + hkl_engine_qper_qpar_new(self); + hkl_engine_tth2_new(self); return self; } @@ -388,10 +388,10 @@ static HklEngineList *hkl_engine_list_new_soleil_sixs_med_1_2(const HklFactory * { HklEngineList *self = hkl_engine_list_new(); - hkl_engine_list_add(self, hkl_engine_soleil_sixs_med_1_2_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_q2_new(self)); - hkl_engine_list_add(self, hkl_engine_qper_qpar_new(self)); - hkl_engine_list_add(self, hkl_engine_tth2_new(self)); + hkl_engine_soleil_sixs_med_1_2_hkl_new(self); + hkl_engine_q2_new(self); + hkl_engine_qper_qpar_new(self); + hkl_engine_tth2_new(self); return self; } @@ -444,10 +444,10 @@ static HklEngineList *hkl_engine_list_new_soleil_sixs_med_2_3(const HklFactory * HklEngineList *self = hkl_engine_list_new(); self->geometries->multiply = hkl_geometry_list_multiply_soleil_sixs_med_2_3; - hkl_engine_list_add(self, hkl_engine_soleil_sixs_med_2_3_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_q2_new(self)); - hkl_engine_list_add(self, hkl_engine_qper_qpar_new(self)); - hkl_engine_list_add(self, hkl_engine_tth2_new(self)); + hkl_engine_soleil_sixs_med_2_3_hkl_new(self); + hkl_engine_q2_new(self); + hkl_engine_qper_qpar_new(self); + hkl_engine_tth2_new(self); return self; } diff --git a/hkl/hkl-engine-template.c b/hkl/hkl-engine-template.c index f5561066..49309faf 100644 --- a/hkl/hkl-engine-template.c +++ b/hkl/hkl-engine-template.c @@ -212,11 +212,11 @@ static HklEngineList *hkl_engine_list_new_eulerian6C(const HklFactory *factory) { HklEngineList *self = hkl_engine_list_new(); - hkl_engine_list_add(self, hkl_engine_e6c_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_e6c_psi_new(self)); - hkl_engine_list_add(self, hkl_engine_q2_new(self)); - hkl_engine_list_add(self, hkl_engine_qper_qpar_new(self)); - hkl_engine_list_add(self, hkl_engine_tth2_new(self)); + hkl_engine_e6c_hkl_new(self); + hkl_engine_e6c_psi_new(self); + hkl_engine_q2_new(self); + hkl_engine_qper_qpar_new(self); + hkl_engine_tth2_new(self); return self; } diff --git a/hkl/hkl-engine-zaxis.c b/hkl/hkl-engine-zaxis.c index 67b842d4..601c7d87 100644 --- a/hkl/hkl-engine-zaxis.c +++ b/hkl/hkl-engine-zaxis.c @@ -136,10 +136,10 @@ static HklEngineList *hkl_engine_list_new_zaxis(const HklFactory *factory) { HklEngineList *self = hkl_engine_list_new(); - hkl_engine_list_add(self, hkl_engine_zaxis_hkl_new(self)); - hkl_engine_list_add(self, hkl_engine_q2_new(self)); - hkl_engine_list_add(self, hkl_engine_qper_qpar_new(self)); - hkl_engine_list_add(self, hkl_engine_tth2_new(self)); + hkl_engine_zaxis_hkl_new(self); + hkl_engine_q2_new(self); + hkl_engine_qper_qpar_new(self); + hkl_engine_tth2_new(self); return self; } diff --git a/hkl/hkl-pseudoaxis-private.h b/hkl/hkl-pseudoaxis-private.h index 9bb7c64c..1dbd9079 100644 --- a/hkl/hkl-pseudoaxis-private.h +++ b/hkl/hkl-pseudoaxis-private.h @@ -383,6 +383,8 @@ static inline void hkl_engine_init(HklEngine *self, self->detector = NULL; self->sample = NULL; self->engines = engines; + + darray_append(*engines, self); } @@ -646,28 +648,6 @@ static inline const HklEngineList *hkl_engine_list_new_copy(const HklEngineList return NULL; } - -/** - * hkl_engine_list_add: (skip) - * @self: the engine list - * @engine: the engine to add - * - * add an #HklEngine to the #HklEngineList - * - * Returns: HKL_SUCCESS or HKL_FAIL - **/ -static inline int hkl_engine_list_add(HklEngineList *self, - HklEngine *engine) -{ - if (!engine) - return FALSE; - - darray_append(*self, engine); - - return TRUE; -} - - /** * hkl_engine_list_clear: (skip) * @self: the engine list to clear diff --git a/scripts/enginelist.cocci b/scripts/enginelist.cocci new file mode 100644 index 00000000..ea19ffd9 --- /dev/null +++ b/scripts/enginelist.cocci @@ -0,0 +1,6 @@ +@@ +expression f; +@@ + +- hkl_engine_list_add(self, f(self)); ++ f(self); -- 2.11.4.GIT