+2005-12-22 Alp Toker <alp@atoker.com>
+
+ * cilc.cs: Add support for string return types and properties
+ * Test.cs, demo.c: Update tests
+
2005-12-22 Alp Toker <alp@atoker.com>
* cilc.cs: Add support for char, sbyte, byte and double
public double GetDoubleValue ()
{
- return (double)counter;
+ return (double)counter/2;
}
public int GetValue ()
Console.WriteLine ("string: " + arg1string);
}
+ public string MakeUpper (string arg1string)
+ {
+ return arg1string.ToUpper ();
+ }
+
public void Method4 (string arg1string, int arg2int)
{
Console.WriteLine (arg1string + arg2int.ToString ());
C.WriteLine (rettype + "* retval = (" + rettype + "*) mono_object_unbox (mono_runtime_invoke (_mono_method, " + mono_obj + ", " + params_arg + ", NULL));");
C.WriteLine ("return (" + rettype + ") *retval;");
C.WriteLine ("}");
+ } else if (rettype == "const gchar *")
+ {
+ //convert the MonoString to a UTF8 before returning
+ C.WriteLine ("return (" + rettype + ") mono_string_to_utf8 ((MonoString*) mono_runtime_invoke (_mono_method, " + mono_obj + ", " + params_arg + ", NULL));");
} else {
//TODO: this isn't right
C.WriteLine ("return (" + rettype + ") mono_runtime_invoke (_mono_method, " + mono_obj + ", " + params_arg + ", NULL);");
int main () {
DemoTest *my_test;
- //gchar *tmp;
+ const gchar *mystr;
int num;
gdouble num_dbl;
DemoDrink drink;
//run an instance method with arguments
demo_test_echo (my_test, "hello from c");
+ //run an instance method with arguments and a return string
+ mystr = demo_test_make_upper (my_test, "lower to upper");
+ g_printf ("Lower to upper: %s\n", mystr);
+
//run a property set accessor
demo_test_set_title (my_test, "set property from c");
- //run a property set accessor
- //tmp = demo_test_get_title (my_test);
- //g_print (tmp);
+ //run a property get accessor
+ mystr = demo_test_get_title (my_test);
+ g_printf ("Title property: %s\n", mystr);
+
num = demo_test_get_value (my_test);
g_printf ("The counter's value is %d\n", num);