Re: [Mono-list] mono embedding in c++: how to get a array from C# code?

2015-11-08 Thread sunsflower
//I reckon that mono_field_get_value will return a MonoArray,
//Try something a bit like this:
//
//MonoArray* monoArray = NULL;
//mono_field_get_value(obj, field, monoArrayl);
//MonoString *monoString = mono_array_get(monoArray, MonoString *, 0)
//char *s = mono_string_to_utf8(monoString); // copy this into a buffer that
you manage
//mono_free(s);

and how can I pass a pointer to mono?...

stuct test
{
int index;
string name;
};


MonoMethod* method = mono_class_get_method_from_name(klass, "testfunc", 2);
MonoException* ex;
typedef int(__stdcall *func)(MonoObject*, test*, MonoException**);
func f1 = (func)(mono_method_get_unmanaged_thunk(method));
test t1;

something like this? but C# won't accept a pointer except in unsafe context.
is there some other way of doing this - to read from a pointer to a struct
in C# and change it? or should I just pass the struct as a value?



--
View this message in context: 
http://mono.1490590.n4.nabble.com/mono-embedding-in-c-how-to-get-a-array-from-C-code-tp4666903p4666907.html
Sent from the Mono - General mailing list archive at Nabble.com.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] mono embedding in c++: how to get a array from C# code?

2015-11-08 Thread sunsflower
thanks, it did work! only I need to pass a monoarray** to this function
"mono_field_get_value(obj, field, );" . Mono is so poor
documented, but it is really good!



--
View this message in context: 
http://mono.1490590.n4.nabble.com/mono-embedding-in-c-how-to-get-a-array-from-C-code-tp4666903p4666906.html
Sent from the Mono - General mailing list archive at Nabble.com.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] mono embedding in c++: how to get a array from C# code?

2015-11-07 Thread sunsflower
I've tried to use a monoclassfield but it doesn't work with a string array in
C#. the return value is invalide. 
c++:

MonoClassField* field;
field = mono_class_get_field_from_name(klass, "entry");
char* val[100];
MonoString* monoval[100];
mono_field_get_value(obj, field, monoval);  
val[0] = mono_string_to_utf8(monoval[0]);

C#

public class SAssemblies
{
string[] entry = new string[] {
"add",
"subtract"
};
}

thanks!



--
View this message in context: 
http://mono.1490590.n4.nabble.com/mono-embedding-in-c-how-to-get-a-array-from-C-code-tp4666903.html
Sent from the Mono - General mailing list archive at Nabble.com.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


[Mono-list] embedding mono: how to pass c++ pointer to and from CLI?

2016-02-07 Thread sunsflower
is there a way to pass a pointer to C# and pass it back to native functions?
for example I have a newMesh function in c++ which returns a pointer to a
Mesh class instance. How can I represent this pointer in C#? And if I have a
drawMesh method in c++ as an internal call method, how can I pass the
pointer I get in C# to this call of drawMesh?
thanks!



--
View this message in context: 
http://mono.1490590.n4.nabble.com/embedding-mono-how-to-pass-c-pointer-to-and-from-CLI-tp4667381.html
Sent from the Mono - General mailing list archive at Nabble.com.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] embedding mono: how to pass c++ pointer to and from CLI?

2016-02-09 Thread sunsflower
and...how to pass an array from c# to c++? 



--
View this message in context: 
http://mono.1490590.n4.nabble.com/embedding-mono-how-to-pass-c-pointer-to-and-from-CLI-tp4667381p4667406.html
Sent from the Mono - General mailing list archive at Nabble.com.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


Re: [Mono-list] embedding mono: how to pass c++ pointer to and from CLI?

2016-02-07 Thread sunsflower
anyone knows anything about this? thanks very much!



--
View this message in context: 
http://mono.1490590.n4.nabble.com/embedding-mono-how-to-pass-c-pointer-to-and-from-CLI-tp4667381p4667386.html
Sent from the Mono - General mailing list archive at Nabble.com.
___
Mono-list maillist  -  Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list