@@ -7,106 +7,106 @@ namespace HostApi {
77 SetTargetFPS (60 );
88 }
99
10- static JSDrawOptions parse_draw_options (const qjs ::Value& optionsObj) {
10+ static JSDrawOptions parse_draw_options (const qjswrapper ::Value& optionsObj) {
1111 JSDrawOptions options;
1212
1313 if (!optionsObj.is_object ()) {
1414 return options;
1515 }
1616
17- if (const qjs ::Value colorProp = optionsObj.get_property (" color" ); !colorProp.is_undefined ()) {
17+ if (const qjswrapper ::Value colorProp = optionsObj.get_property (" color" ); !colorProp.is_undefined ()) {
1818 if (const auto v = colorProp.as <JSColor>()) options.color = v.value ();
1919 }
2020
2121 return options;
2222
2323 }
2424
25- static JSTextOptions parse_text_options (const qjs ::Value& optionsObj) {
25+ static JSTextOptions parse_text_options (const qjswrapper ::Value& optionsObj) {
2626 JSTextOptions options;
2727
2828 if (!optionsObj.is_object ()) {
2929 return options;
3030 }
3131
32- if (const qjs ::Value fontProp = optionsObj.get_property (" font" ); !fontProp.is_undefined ()) {
32+ if (const qjswrapper ::Value fontProp = optionsObj.get_property (" font" ); !fontProp.is_undefined ()) {
3333 if (const auto v = fontProp.as <JSFont>()) options.font = JSFont (v.value ());
3434 }
3535
36- if (const qjs ::Value colorProp = optionsObj.get_property (" color" ); !colorProp.is_undefined ()) {
36+ if (const qjswrapper ::Value colorProp = optionsObj.get_property (" color" ); !colorProp.is_undefined ()) {
3737 if (const auto v = colorProp.as <JSColor>()) options.color = v.value ();
3838 }
3939
40- if (const qjs ::Value rotProp = optionsObj.get_property (" rotation" ); rotProp.is_number ()) {
40+ if (const qjswrapper ::Value rotProp = optionsObj.get_property (" rotation" ); rotProp.is_number ()) {
4141 if (const auto v = rotProp.as <float >()) options.rotation = v.value ();
4242 }
4343
44- if (const qjs ::Value sizeProp = optionsObj.get_property (" fontSize" ); sizeProp.is_number ()) {
44+ if (const qjswrapper ::Value sizeProp = optionsObj.get_property (" fontSize" ); sizeProp.is_number ()) {
4545 if (const auto v = sizeProp.as <float >()) options.fontSize = v.value ();
4646 }
4747
48- if (const qjs ::Value spacingProp = optionsObj.get_property (" spacing" ); spacingProp.is_number ()) {
48+ if (const qjswrapper ::Value spacingProp = optionsObj.get_property (" spacing" ); spacingProp.is_number ()) {
4949 if (const auto v = spacingProp.as <float >()) options.spacing = v.value ();
5050 }
5151
52- if (const qjs ::Value originProp = optionsObj.get_property (" origin" ); !originProp.is_undefined ()) {
52+ if (const qjswrapper ::Value originProp = optionsObj.get_property (" origin" ); !originProp.is_undefined ()) {
5353 if (const auto v = originProp.as <JSVector2>()) options.origin = v.value ();
5454 }
5555
5656 return options;
5757 }
5858
59- static qjs ::Value create_update_context_object (const qjs ::Value& user_app) {
59+ static qjswrapper ::Value create_update_context_object (const qjswrapper ::Value& user_app) {
6060
6161 const auto js_ctx = user_app.context ();
6262
6363 // Context
64- qjs ::Value update_obj = qjs ::Value::create_object (js_ctx);
64+ qjswrapper ::Value update_obj = qjswrapper ::Value::create_object (js_ctx);
6565
6666 return update_obj;
6767
6868 }
6969
70- static qjs ::Value create_draw_render_object (const qjs ::Value& user_app) {
70+ static qjswrapper ::Value create_draw_render_object (const qjswrapper ::Value& user_app) {
7171
7272 const auto js_ctx = user_app.context ();
7373
7474 // Context
75- qjs ::Value render2d_obj = qjs ::Value::create_object (js_ctx)
75+ qjswrapper ::Value render2d_obj = qjswrapper ::Value::create_object (js_ctx)
7676 .set_function (" drawFPS" , [](const JSVector2 position) {
7777 ::DrawFPS (static_cast <int >(position.x), static_cast<int>(position.y));
7878 });
7979
8080 // Draw Shapes
81- qjs ::Value shapeObj = qjs ::Value::create_object (render2d_obj.context ())
81+ qjswrapper ::Value shapeObj = qjswrapper ::Value::create_object (render2d_obj.context ())
8282 .set_function (" drawPixel" , [](const JSVector2 position, const JSColor color) {
8383 ::DrawPixelV (position, color);
8484 })
85- .set_function (" drawLine" , [](const JSVector2 startPosition, const JSVector2 endPosition, const qjs ::Value &drawOptions) {
85+ .set_function (" drawLine" , [](const JSVector2 startPosition, const JSVector2 endPosition, const qjswrapper ::Value &drawOptions) {
8686 const JSDrawOptions draw_options = parse_draw_options (drawOptions);
8787 ::DrawLineV (startPosition, endPosition, draw_options.color);
8888 })
89- .set_function (" drawRectangle" , [](const JSRectangle rect, const qjs ::Value &drawOptions) {
89+ .set_function (" drawRectangle" , [](const JSRectangle rect, const qjswrapper ::Value &drawOptions) {
9090 const JSDrawOptions draw_options = parse_draw_options (drawOptions);
9191 ::DrawRectanglePro (rect, draw_options.origin, draw_options.rotation, draw_options.color);
9292 })
93- .set_function (" drawCircle" , [](const JSVector2 center, const float radius, const qjs ::Value &drawOptions) {
93+ .set_function (" drawCircle" , [](const JSVector2 center, const float radius, const qjswrapper ::Value &drawOptions) {
9494 const JSDrawOptions draw_options = parse_draw_options (drawOptions);
9595 ::DrawCircleV (center, radius, draw_options.color);
9696 })
97- .set_function (" drawTriangle" , [](const JSVector2 point1, const JSVector2 point2, const JSVector2 point3, const qjs ::Value &drawOptions) {
97+ .set_function (" drawTriangle" , [](const JSVector2 point1, const JSVector2 point2, const JSVector2 point3, const qjswrapper ::Value &drawOptions) {
9898 const JSDrawOptions draw_options = parse_draw_options (drawOptions);
9999 ::DrawTriangle (point1, point2, point3, draw_options.color);
100100 })
101- .set_function (" drawEllipse" , [](const JSVector2 center, const float radiusH, const float radiusV, const qjs ::Value &drawOptions) {
101+ .set_function (" drawEllipse" , [](const JSVector2 center, const float radiusH, const float radiusV, const qjswrapper ::Value &drawOptions) {
102102 const JSDrawOptions draw_options = parse_draw_options (drawOptions);
103103 ::DrawEllipseV (center, radiusH, radiusV, draw_options.color);
104104 });
105105 render2d_obj.set_variable (" shapes" , shapeObj);
106106
107107 // Text
108- qjs ::Value textObj = qjs ::Value::create_object (render2d_obj.context ())
109- .set_function (" drawText" , [](const JSVector2 position, const std::string &text, const qjs ::Value &optionsObj) {
108+ qjswrapper ::Value textObj = qjswrapper ::Value::create_object (render2d_obj.context ())
109+ .set_function (" drawText" , [](const JSVector2 position, const std::string &text, const qjswrapper ::Value &optionsObj) {
110110
111111 // Extract options using our helper function
112112 JSTextOptions options = parse_text_options (optionsObj);
@@ -130,8 +130,8 @@ namespace HostApi {
130130 render2d_obj.set_variable (" text" , textObj);
131131
132132 // Render 2d layer
133- qjs ::Value render_obj = qjs ::Value::create_object (js_ctx);
134- render_obj.set_function (" withLayer2D" , [render2d_obj](const qjs ::Value& callback) {
133+ qjswrapper ::Value render_obj = qjswrapper ::Value::create_object (js_ctx);
134+ render_obj.set_function (" withLayer2D" , [render2d_obj](const qjswrapper ::Value& callback) {
135135 if (callback.is_function ()) {
136136 std::ignore = callback.call ({render2d_obj});
137137 }
@@ -140,14 +140,14 @@ namespace HostApi {
140140 return render_obj;
141141 }
142142
143- void JSApplication::Run (const qjs ::Value& user_app) {
143+ void JSApplication::Run (const qjswrapper ::Value& user_app) {
144144
145- const qjs ::Value on_init_func = user_app.get_property (" onInit" );
146- const qjs ::Value on_update_func = user_app.get_property (" onUpdate" );
147- const qjs ::Value on_draw_func = user_app.get_property (" onDraw" );
145+ const qjswrapper ::Value on_init_func = user_app.get_property (" onInit" );
146+ const qjswrapper ::Value on_update_func = user_app.get_property (" onUpdate" );
147+ const qjswrapper ::Value on_draw_func = user_app.get_property (" onDraw" );
148148
149- qjs ::Value update_obj = create_update_context_object (user_app);
150- qjs ::Value render_obj = create_draw_render_object (user_app);
149+ qjswrapper ::Value update_obj = create_update_context_object (user_app);
150+ qjswrapper ::Value render_obj = create_draw_render_object (user_app);
151151
152152 if (on_init_func.is_function ()) {
153153 std::ignore = on_init_func.call ({}, user_app);
@@ -173,7 +173,7 @@ namespace HostApi {
173173 }
174174 }
175175
176- void register_hapi_application (qjs ::Engine &engine, qjs ::ModuleBuilder &module ) {
176+ void register_hapi_application (qjswrapper ::Engine &engine, qjswrapper ::ModuleBuilder &module ) {
177177 auto app = engine.make_class <JSApplication>(" Application" )
178178 .add_constructor <int , int , std::string>()
179179 .add_method (" run" , &JSApplication::Run)
0 commit comments