1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef OHOS_ACELITE_RENDER_MODULE_H 16 #define OHOS_ACELITE_RENDER_MODULE_H 17 18 #include "non_copyable.h" 19 #include "presets/preset_module.h" 20 21 namespace OHOS { 22 namespace ACELite { 23 class RenderModule final : public PresetModule { 24 public: 25 ACE_DISALLOW_COPY_AND_MOVE(RenderModule); 26 /** 27 * @fn RenderModule::RenderModule() 28 * 29 * @brief Constructor. 30 */ RenderModule()31 RenderModule() : PresetModule(nullptr) {} 32 33 /** 34 * @fn RenderModule::~RenderModule() 35 * 36 * @brief Constructor. 37 */ 38 ~RenderModule() = default; 39 40 void Init() override; 41 Load()42 static void Load() 43 { 44 RenderModule renderModule; 45 renderModule.Init(); 46 } 47 48 private: 49 static jerry_value_t 50 CreateElement(const jerry_value_t tagName, const jerry_value_t options, const jerry_value_t children); 51 52 static jerry_value_t CreateElement(const jerry_value_t func, 53 const jerry_value_t context, 54 const jerry_value_t *args, 55 const jerry_length_t argsNum); 56 57 static jerry_value_t InitStyleSheet(const jerry_value_t func, 58 const jerry_value_t context, 59 const jerry_value_t *args, 60 const jerry_length_t argsNum); 61 62 static jerry_value_t LoopRender(const jerry_value_t func, 63 const jerry_value_t context, 64 const jerry_value_t *args, 65 const jerry_length_t argsNum); 66 67 static jerry_value_t ConditionalRender(const jerry_value_t func, 68 const jerry_value_t context, 69 const jerry_value_t *args, 70 const jerry_length_t argsNum); 71 72 static const char * const FUNC_CREATE_ELEMENT; 73 static const char * const FUNC_INIT_STYLE_SHEET; 74 static const char * const FUNC_LOOP_RENDER; 75 static const char * const FUNC_CONDITIONAL_RENDER; 76 static const int ARG_LENGTH_TAG_ONLY; 77 static const int ARG_LENGTH_WITH_OPTIONS; 78 static const int ARG_LENGTH_WITHOUT_OPTIONS; 79 static const int ARG_LENGTH_RENDER; 80 }; 81 } // namespace ACELite 82 } // namespace OHOS 83 #endif // OHOS_ACELITE_RENDER_MODULE_H 84