| 1 | = Summary = |
| 2 | |
| 3 | * EFL port should adhere to the WebKit Coding Style basically.(http://www.webkit.org/coding/coding-style.html) |
| 4 | * Do not use '''abbreviation''' except for public APIs |
| 5 | * Do not use '''Eina_Bool''' type except for public APIs |
| 6 | * Place '*' operator to data type |
| 7 | * Use '''static_cast<...>''' for type casting |
| 8 | |
| 9 | |
| 10 | = Example = |
| 11 | |
| 12 | == Do not use abbreviation except for public APIs == |
| 13 | |
| 14 | === Public APIs === |
| 15 | |
| 16 | {{{ |
| 17 | EAPI void ewk_view_bg_color_set('''Evas_Object *o, int r, int g, int b, int a'''); |
| 18 | }}} |
| 19 | |
| 20 | === Implementation === |
| 21 | {{{ |
| 22 | void ewk_view_bg_color_set('''Evas_Object* ewkView, int red, int green, int blue, int alpha''') |
| 23 | { |
| 24 | EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); |
| 25 | EINA_SAFETY_ON_NULL_RETURN(smartData->api); |
| 26 | EINA_SAFETY_ON_NULL_RETURN(smartData->api->bg_color_set); |
| 27 | |
| 28 | if (alpha < 0) { |
| 29 | WRN("Alpha less than zero (%d).", alpha); |
| 30 | alpha = 0; |
| 31 | } else if (alpha > 255) { |
| 32 | WRN("Alpha is larger than 255 (%d).", alpha); |
| 33 | alpha = 255; |
| 34 | } |
| 35 | ... |
| 36 | } |
| 37 | }}} |
| 38 | |
| 39 | == Do not use Eina_Bool type except for public APIs == |
| 40 | |
| 41 | === Public APIs === |
| 42 | |
| 43 | {{{ |
| 44 | EAPI '''Eina_Bool''' ewk_view_scale_set(Evas_Object *o, float scale_factor, Evas_Coord cx, Evas_Coord cy); |
| 45 | }}} |
| 46 | |
| 47 | === Implementation === |
| 48 | |
| 49 | {{{ |
| 50 | '''Eina_Bool''' ewk_view_scale_set(Evas_Object* ewkView, float scaleFactor, Evas_Coord centerX, Evas_Coord centerY) |
| 51 | { |
| 52 | EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); |
| 53 | EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false); |
| 54 | |
| 55 | float currentScaleFactor = ewk_view_scale_get(ewkView); |
| 56 | if (currentScaleFactor == -1) |
| 57 | return '''false'''; |
| 58 | int x, y; |
| 59 | ewk_frame_scroll_pos_get(smartData->main_frame, &x, &y); |
| 60 | |
| 61 | x = static_cast<int>(((x + centerX) / currentScaleFactor) * scaleFactor) - centerX; |
| 62 | y = static_cast<int>(((y + centerY) / currentScaleFactor) * scaleFactor) - centerY; |
| 63 | priv->page->setPageScaleFactor(scaleFactor, WebCore::LayoutPoint(x, y)); |
| 64 | return '''true'''; |
| 65 | } |
| 66 | }}} |
| 67 | |
| 68 | |
| 69 | == Place '*' operator to data type == |
| 70 | |
| 71 | === Right === |
| 72 | |
| 73 | {{{ |
| 74 | static void _ewk_view_smart_show('''Evas_Object* ewkView''') |
| 75 | }}} |
| 76 | |
| 77 | === Wrong === |
| 78 | |
| 79 | {{{ |
| 80 | static void _ewk_view_smart_show('''Evas_Object *ewkView''') |
| 81 | }}} |
| 82 | |
| 83 | == Use static_cast for type casting == |
| 84 | |
| 85 | === Right === |
| 86 | |
| 87 | {{{ |
| 88 | Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data); |
| 89 | }}} |
| 90 | |
| 91 | === Wrong === |
| 92 | |
| 93 | {{{ |
| 94 | Ewk_View_Smart_Data* smartData = (Ewk_View_Smart_Data*)data; |
| 95 | }}} |