Skip to content

Commit

Permalink
add custom allocator for TinyJS
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Feb 6, 2024
1 parent 372a454 commit 1085d16
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 118 deletions.
6 changes: 3 additions & 3 deletions vstgui/uidescription-scripting/detail/drawcontextobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ DrawContextObject::DrawContextObject ()
throw CScriptException (
"Missing `color` argument in drawContext.setFontColor(color);");
CColor color {};
UIViewCreator::stringToColor (&colorVar->getString (), color, uiDesc);
UIViewCreator::stringToColor (colorVar->getString (), color, uiDesc);
context->setFontColor (color);
},
{"color"});
Expand All @@ -239,7 +239,7 @@ DrawContextObject::DrawContextObject ()
throw CScriptException (
"Missing `color` argument in drawContext.setFillColor(color);");
CColor color {};
UIViewCreator::stringToColor (&colorVar->getString (), color, uiDesc);
UIViewCreator::stringToColor (colorVar->getString (), color, uiDesc);
context->setFillColor (color);
},
{"color"});
Expand All @@ -252,7 +252,7 @@ DrawContextObject::DrawContextObject ()
throw CScriptException (
"Missing `color` argument in drawContext.setFrameColor(color);");
CColor color {};
if (!UIViewCreator::stringToColor (&colorVar->getString (), color, uiDesc))
if (!UIViewCreator::stringToColor (colorVar->getString (), color, uiDesc))
throw CScriptException (
"Unknown `color` argument in drawContext.setFrameColor(color);");
context->setFrameColor (color);
Expand Down
4 changes: 2 additions & 2 deletions vstgui/uidescription-scripting/detail/scriptobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ struct ScriptObject
{
scriptVar->addChild (name, new CScriptVar (static_cast<int64_t> (i)));
}
void addChild (std::string_view name, const std::string& value)
void addChild (std::string_view name, std::string_view value)
{
scriptVar->addChild (name, new CScriptVar (value));
scriptVar->addChild (name, new CScriptVar (TJS::string {value.data (), value.size ()}));
}
void addFunc (std::string_view name, std::function<void (CScriptVar*)>&& func)
{
Expand Down
2 changes: 1 addition & 1 deletion vstgui/uidescription-scripting/detail/uidescscriptobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct UIDescScriptObject : ScriptObject
{
throw CScriptException ("Expect 'name' argument for getTagForName ");
}
std::string name = param->getString ();
auto name = param->getString ();
auto tag = desc->getTagForName (name.data ());
var->setReturnVar (new CScriptVar (static_cast<int64_t> (tag)));
},
Expand Down
10 changes: 5 additions & 5 deletions vstgui/uidescription-scripting/detail/viewscriptobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ViewScriptObject::ViewScriptObject (CView* view, IViewScriptObjectContext* conte
auto key = var->getParameter ("key"sv);
auto value = var->getParameter ("value"sv);
UIAttributes attr;
attr.setAttribute (key->getString (), value->getString ());
attr.setAttribute (key->getString ().data (), value->getString ().data ());
auto result = uiDesc->getViewFactory ()->applyAttributeValues (view, attr, uiDesc);
var->getReturnVar ()->setInt (result);
},
Expand All @@ -41,8 +41,8 @@ ViewScriptObject::ViewScriptObject (CView* view, IViewScriptObjectContext* conte
[uiDesc = context->getUIDescription (), view] (CScriptVar* var) {
auto key = var->getParameter ("key"sv);
std::string result;
if (uiDesc->getViewFactory ()->getAttributeValue (view, key->getString (), result,
uiDesc))
if (uiDesc->getViewFactory ()->getAttributeValue (view, key->getString ().data (),
result, uiDesc))
{
var->getReturnVar ()->setString (result);
}
Expand All @@ -56,7 +56,7 @@ ViewScriptObject::ViewScriptObject (CView* view, IViewScriptObjectContext* conte
[uiDesc = context->getUIDescription (), view] (CScriptVar* var) {
auto typeName = var->getParameter ("typeName"sv);
auto result =
uiDesc->getViewFactory ()->viewIsTypeOf (view, typeName->getString ());
uiDesc->getViewFactory ()->viewIsTypeOf (view, typeName->getString ().data ());
var->getReturnVar ()->setInt (result);
},
{"typeName"});
Expand Down Expand Up @@ -135,7 +135,7 @@ ViewScriptObject::ViewScriptObject (CView* view, IViewScriptObjectContext* conte
else if (value->isDouble ())
propValue = value->getDouble ();
else if (value->isString ())
propValue = value->getString ();
propValue = value->getString ().data ();
auto result = controller->setProperty (view, name->getString (), propValue);
var->getReturnVar ()->setInt (result);
},
Expand Down
Loading

0 comments on commit 1085d16

Please sign in to comment.