@@ -1695,19 +1695,55 @@ def __init__(self, gen, typeid):
1695
1695
self .c_safe_id = "char_X"
1696
1696
self .rust_extern = "*mut c_char"
1697
1697
1698
- def cpp_arg_func_call (self , var_name , is_output = False ):
1699
- return "{}({})" .format (self .cpptype , var_name )
1698
+ def is_output (self ):
1699
+ return self .is_by_ref and not self .is_const
1700
+
1701
+ def rust_arg_func_decl (self , var_name , is_output = False ):
1702
+ if self .is_output ():
1703
+ return "{}: &mut String" .format (var_name )
1704
+ return "{}: &str" .format (var_name )
1700
1705
1701
1706
def rust_arg_pre_call (self , var_name , is_output = False ):
1707
+ if self .is_output ():
1708
+ return "string_arg_output_send!(via {}_via)" .format (var_name )
1702
1709
return "string_arg!({}{})" .format ("" if self .is_const else "mut " , var_name )
1703
1710
1704
1711
def rust_arg_func_call (self , var_name , is_output = False ):
1712
+ if self .is_output ():
1713
+ return "&mut {}_via" .format (var_name )
1705
1714
if self .is_const :
1706
1715
return "{}.as_ptr()" .format (var_name )
1707
1716
return "{}.as_ptr() as _" .format (var_name ) # fixme: use as_mut_ptr() when it's stabilized
1708
1717
1709
- def rust_arg_func_decl (self , var_name , is_output = False ):
1710
- return "{}: &str" .format (var_name )
1718
+ def rust_extern_arg_func_decl (self , var_name , is_output = False ):
1719
+ if self .is_output ():
1720
+ return "{}: *mut {}" .format (var_name , self .rust_extern )
1721
+ return super (StringTypeInfo , self ).rust_extern_arg_func_decl (var_name , is_output )
1722
+
1723
+ def rust_arg_post_call (self , var_name , is_output = False ):
1724
+ if self .is_output ():
1725
+ return "string_arg_output_receive!({}_via => {})" .format (var_name , var_name )
1726
+ return super (StringTypeInfo , self ).rust_arg_post_call (var_name , is_output )
1727
+
1728
+ def cpp_arg_func_decl (self , var_name , is_output = False ):
1729
+ if self .is_output ():
1730
+ return "{}* {}" .format (self .cpp_extern , var_name )
1731
+ return super (StringTypeInfo , self ).cpp_arg_func_decl (var_name , is_output )
1732
+
1733
+ def cpp_arg_pre_call (self , var_name , is_output = False ):
1734
+ if self .is_output ():
1735
+ return "std::string {}_out" .format (var_name )
1736
+ return super (StringTypeInfo , self ).cpp_arg_pre_call (var_name , is_output )
1737
+
1738
+ def cpp_arg_func_call (self , var_name , is_output = False ):
1739
+ if self .is_output ():
1740
+ return "{}_out" .format (var_name )
1741
+ return "{}({})" .format (self .cpptype , var_name )
1742
+
1743
+ def cpp_arg_post_call (self , var_name , is_output = False ):
1744
+ if self .is_output ():
1745
+ return "*{} = strdup({}_out.c_str())" .format (var_name , var_name )
1746
+ return super (StringTypeInfo , self ).cpp_arg_post_call (var_name , is_output )
1711
1747
1712
1748
def cpp_method_return (self , is_constructor ):
1713
1749
return "return { Error::Code::StsOk, NULL, strdup(ret.c_str()) };"
0 commit comments