@@ -18,8 +18,8 @@ use std::time::{Duration, Instant};
1818
1919use makepad_script:: {
2020 id, id_lut, script_args_def, script_err_not_allowed, script_err_unexpected, script_value,
21- LiveId , ScriptHandle , ScriptHandleGc , ScriptHandleType , ScriptIp , ScriptThreadId , ScriptValue ,
22- NIL ,
21+ LiveId , ScriptHandle , ScriptHandleGc , ScriptHandleType , ScriptIp , ScriptStringSink ,
22+ ScriptThreadId , ScriptValue , NIL ,
2323} ;
2424use serde:: { de:: DeserializeOwned , Deserialize , Serialize } ;
2525pub use serde_json:: { json, Value as JsonValue } ;
@@ -5793,7 +5793,7 @@ fn install_capability_module(
57935793 )
57945794 }
57955795 } ;
5796- let output = match vm. host . downcast_mut :: < CapabilityHost > ( ) {
5796+ let output = match vm. host . as_any_mut ( ) . downcast_mut :: < CapabilityHost > ( ) {
57975797 Some ( host) => host. call_json ( & tool, & input) ,
57985798 None => {
57995799 return script_err_unexpected ! (
@@ -5841,7 +5841,7 @@ fn install_capability_module(
58415841 )
58425842 }
58435843 } ;
5844- let result = match vm. host . downcast_mut :: < CapabilityHost > ( ) {
5844+ let result = match vm. host . as_any_mut ( ) . downcast_mut :: < CapabilityHost > ( ) {
58455845 Some ( host) => host. begin_async_json ( & tool, & input, max_pending_tools) ,
58465846 None => {
58475847 return script_err_unexpected ! (
@@ -5904,7 +5904,7 @@ fn install_tool_module(runtime: &mut Runtime<CapabilityHost, ()>, max_pending_to
59045904 )
59055905 }
59065906 } ;
5907- let pending = match vm. host . downcast_ref :: < CapabilityHost > ( ) {
5907+ let pending = match vm. host . as_any ( ) . downcast_ref :: < CapabilityHost > ( ) {
59085908 Some ( host) => host. pending ( ) ,
59095909 None => {
59105910 return script_err_unexpected ! (
@@ -5951,7 +5951,9 @@ fn install_tool_module(runtime: &mut Runtime<CapabilityHost, ()>, max_pending_to
59515951 match ready {
59525952 Some ( Ok ( output) ) => match promise_output {
59535953 ToolPromiseOutput :: Text => {
5954- vm. new_string_with ( |_, destination| destination. push_str ( & output) )
5954+ vm. bx . heap . new_bounded_string_with ( |_, destination| {
5955+ destination. append_str ( & output)
5956+ } )
59555957 }
59565958 ToolPromiseOutput :: DecodedJson {
59575959 max_output_bytes,
@@ -5985,22 +5987,25 @@ fn install_tool_module(runtime: &mut Runtime<CapabilityHost, ()>, max_pending_to
59855987 let name = script_text ( vm, script_value ! ( vm, args. name) ) ;
59865988 let input = script_text ( vm, script_value ! ( vm, args. input) ) ;
59875989 let result = match ( name, input) {
5988- ( Ok ( name) , Ok ( input) ) => match vm. host . downcast_mut :: < CapabilityHost > ( ) {
5989- Some ( host) => host. call ( & name, & input) ,
5990- None => {
5991- return script_err_unexpected ! (
5992- vm. bx. threads. cur_ref( ) . trap,
5993- "invalid Octoscript capability host"
5994- )
5990+ ( Ok ( name) , Ok ( input) ) => {
5991+ match vm. host . as_any_mut ( ) . downcast_mut :: < CapabilityHost > ( ) {
5992+ Some ( host) => host. call ( & name, & input) ,
5993+ None => {
5994+ return script_err_unexpected ! (
5995+ vm. bx. threads. cur_ref( ) . trap,
5996+ "invalid Octoscript capability host"
5997+ )
5998+ }
59955999 }
5996- } ,
6000+ }
59976001 ( Err ( error) , _) | ( _, Err ( error) ) => Err ( error) ,
59986002 } ;
59996003
60006004 match result {
6001- Ok ( output) => {
6002- vm. new_string_with ( |_, destination| destination. push_str ( & output) )
6003- }
6005+ Ok ( output) => vm
6006+ . bx
6007+ . heap
6008+ . new_bounded_string_with ( |_, destination| destination. append_str ( & output) ) ,
60046009 Err ( error) => {
60056010 script_err_not_allowed ! ( vm. bx. threads. cur_ref( ) . trap, "{}" , error)
60066011 }
@@ -6016,22 +6021,25 @@ fn install_tool_module(runtime: &mut Runtime<CapabilityHost, ()>, max_pending_to
60166021 let name = script_text ( vm, script_value ! ( vm, args. name) ) ;
60176022 let input = script_json ( vm, script_value ! ( vm, args. input) ) ;
60186023 let result = match ( name, input) {
6019- ( Ok ( name) , Ok ( input) ) => match vm. host . downcast_mut :: < CapabilityHost > ( ) {
6020- Some ( host) => host. call_json ( & name, & input) ,
6021- None => {
6022- return script_err_unexpected ! (
6023- vm. bx. threads. cur_ref( ) . trap,
6024- "invalid Octoscript capability host"
6025- )
6024+ ( Ok ( name) , Ok ( input) ) => {
6025+ match vm. host . as_any_mut ( ) . downcast_mut :: < CapabilityHost > ( ) {
6026+ Some ( host) => host. call_json ( & name, & input) ,
6027+ None => {
6028+ return script_err_unexpected ! (
6029+ vm. bx. threads. cur_ref( ) . trap,
6030+ "invalid Octoscript capability host"
6031+ )
6032+ }
60266033 }
6027- } ,
6034+ }
60286035 ( Err ( error) , _) | ( _, Err ( error) ) => Err ( error) ,
60296036 } ;
60306037
60316038 match result {
6032- Ok ( output) => {
6033- vm. new_string_with ( |_, destination| destination. push_str ( & output) )
6034- }
6039+ Ok ( output) => vm
6040+ . bx
6041+ . heap
6042+ . new_bounded_string_with ( |_, destination| destination. append_str ( & output) ) ,
60356043 Err ( error) => {
60366044 script_err_not_allowed ! ( vm. bx. threads. cur_ref( ) . trap, "{}" , error)
60376045 }
@@ -6047,15 +6055,17 @@ fn install_tool_module(runtime: &mut Runtime<CapabilityHost, ()>, max_pending_to
60476055 let name = script_text ( vm, script_value ! ( vm, args. name) ) ;
60486056 let input = script_text ( vm, script_value ! ( vm, args. input) ) ;
60496057 let result = match ( name, input) {
6050- ( Ok ( name) , Ok ( input) ) => match vm. host . downcast_mut :: < CapabilityHost > ( ) {
6051- Some ( host) => host. begin_async ( & name, & input, max_pending_tools) ,
6052- None => {
6053- return script_err_unexpected ! (
6054- vm. bx. threads. cur_ref( ) . trap,
6055- "invalid Octoscript capability host"
6056- )
6058+ ( Ok ( name) , Ok ( input) ) => {
6059+ match vm. host . as_any_mut ( ) . downcast_mut :: < CapabilityHost > ( ) {
6060+ Some ( host) => host. begin_async ( & name, & input, max_pending_tools) ,
6061+ None => {
6062+ return script_err_unexpected ! (
6063+ vm. bx. threads. cur_ref( ) . trap,
6064+ "invalid Octoscript capability host"
6065+ )
6066+ }
60576067 }
6058- } ,
6068+ }
60596069 ( Err ( error) , _) | ( _, Err ( error) ) => Err ( error) ,
60606070 } ;
60616071
@@ -6084,15 +6094,17 @@ fn install_tool_module(runtime: &mut Runtime<CapabilityHost, ()>, max_pending_to
60846094 let name = script_text ( vm, script_value ! ( vm, args. name) ) ;
60856095 let input = script_json ( vm, script_value ! ( vm, args. input) ) ;
60866096 let result = match ( name, input) {
6087- ( Ok ( name) , Ok ( input) ) => match vm. host . downcast_mut :: < CapabilityHost > ( ) {
6088- Some ( host) => host. begin_async_json ( & name, & input, max_pending_tools) ,
6089- None => {
6090- return script_err_unexpected ! (
6091- vm. bx. threads. cur_ref( ) . trap,
6092- "invalid Octoscript capability host"
6093- )
6097+ ( Ok ( name) , Ok ( input) ) => {
6098+ match vm. host . as_any_mut ( ) . downcast_mut :: < CapabilityHost > ( ) {
6099+ Some ( host) => host. begin_async_json ( & name, & input, max_pending_tools) ,
6100+ None => {
6101+ return script_err_unexpected ! (
6102+ vm. bx. threads. cur_ref( ) . trap,
6103+ "invalid Octoscript capability host"
6104+ )
6105+ }
60946106 }
6095- } ,
6107+ }
60966108 ( Err ( error) , _) | ( _, Err ( error) ) => Err ( error) ,
60976109 } ;
60986110
0 commit comments