|
| 1 | +// Define module |
| 2 | +// target_namespace means the name exported to JS, could be same as which in other modules |
| 3 | +// native2d at the last means the suffix of binding function name, different modules should use unique name |
| 4 | +// Note: doesn't support number prefix |
| 5 | +%module(target_namespace="render") scene |
| 6 | + |
| 7 | +// Disable some swig warnings, find warning number reference here ( https://www.swig.org/Doc4.1/Warnings.html ) |
| 8 | +#pragma SWIG nowarn=503,302,401,317,402 |
| 9 | + |
| 10 | +// Insert code at the beginning of generated header file (.h) |
| 11 | +%insert(header_file) %{ |
| 12 | +#pragma once |
| 13 | +#include <type_traits> |
| 14 | +#include "bindings/jswrapper/SeApi.h" |
| 15 | +#include "bindings/manual/jsb_conversions.h" |
| 16 | +#include "renderer/scene/RenderSceneInterfaceTypes.h" |
| 17 | +%} |
| 18 | + |
| 19 | +// Insert code at the beginning of generated source file (.cpp) |
| 20 | +%{ |
| 21 | +#include "bindings/auto/jsb_render_scene_auto.h" |
| 22 | + |
| 23 | +using namespace cc; |
| 24 | +using namespace cc::render; |
| 25 | +%} |
| 26 | + |
| 27 | +// ----- Ignore Section ------ |
| 28 | +// Brief: Classes, methods or attributes need to be ignored |
| 29 | +// |
| 30 | +// Usage: |
| 31 | +// |
| 32 | +// %ignore your_namespace::your_class_name; |
| 33 | +// %ignore your_namespace::your_class_name::your_method_name; |
| 34 | +// %ignore your_namespace::your_class_name::your_attribute_name; |
| 35 | +// |
| 36 | +// Note: |
| 37 | +// 1. 'Ignore Section' should be placed before attribute definition and %import/%include |
| 38 | +// 2. namespace is needed |
| 39 | +// |
| 40 | + |
| 41 | +// ----- Rename Section ------ |
| 42 | +// Brief: Classes, methods or attributes needs to be renamed |
| 43 | +// |
| 44 | +// Usage: |
| 45 | +// |
| 46 | +// %rename(rename_to_name) your_namespace::original_class_name; |
| 47 | +// %rename(rename_to_name) your_namespace::original_class_name::method_name; |
| 48 | +// %rename(rename_to_name) your_namespace::original_class_name::attribute_name; |
| 49 | +// |
| 50 | +// Note: |
| 51 | +// 1. 'Rename Section' should be placed before attribute definition and %import/%include |
| 52 | +// 2. namespace is needed |
| 53 | + |
| 54 | +// ----- Module Macro Section ------ |
| 55 | +// Brief: Generated code should be wrapped inside a macro |
| 56 | +// Usage: |
| 57 | +// 1. Configure for class |
| 58 | +// %module_macro(CC_USE_GEOMETRY_RENDERER) cc::pipeline::GeometryRenderer; |
| 59 | +// 2. Configure for member function or attribute |
| 60 | +// %module_macro(CC_USE_GEOMETRY_RENDERER) cc::pipeline::RenderPipeline::geometryRenderer; |
| 61 | +// Note: Should be placed before 'Attribute Section' |
| 62 | + |
| 63 | +// ----- Attribute Section ------ |
| 64 | +// Brief: Define attributes ( JS properties with getter and setter ) |
| 65 | +// Usage: |
| 66 | +// 1. Define an attribute without setter |
| 67 | +// %attribute(your_namespace::your_class_name, cpp_member_variable_type, js_property_name, cpp_getter_name) |
| 68 | +// 2. Define an attribute with getter and setter |
| 69 | +// %attribute(your_namespace::your_class_name, cpp_member_variable_type, js_property_name, cpp_getter_name, cpp_setter_name) |
| 70 | +// 3. Define an attribute without getter |
| 71 | +// %attribute_writeonly(your_namespace::your_class_name, cpp_member_variable_type, js_property_name, cpp_setter_name) |
| 72 | +// |
| 73 | +// Note: |
| 74 | +// 1. Don't need to add 'const' prefix for cpp_member_variable_type |
| 75 | +// 2. The return type of getter should keep the same as the type of setter's parameter |
| 76 | +// 3. If using reference, add '&' suffix for cpp_member_variable_type to avoid generated code using value assignment |
| 77 | +// 4. 'Attribute Section' should be placed before 'Import Section' and 'Include Section' |
| 78 | +// |
| 79 | +%attribute(cc::render::RenderScene, uint32_t, numNodes, getNumNodes); |
| 80 | + |
| 81 | +// ----- Import Section ------ |
| 82 | +// Brief: Import header files which are depended by 'Include Section' |
| 83 | +// Note: |
| 84 | +// %import "your_header_file.h" will not generate code for that header file |
| 85 | +// |
| 86 | + |
| 87 | +// ----- Include Section ------ |
| 88 | +// Brief: Include header files in which classes and methods will be bound |
| 89 | +%include "renderer/scene/RenderSceneInterfaceTypes.h" |
0 commit comments