[Mono-list] Mono Boolean to C bool

Kevin Heeney koheeney at gmail.com
Sun Nov 16 01:21:17 EST 2008

I am using C to invoke Mono and it is working well.  A few weeks ago  
I hit an issue where I was calling a few functions that returned a  
boolean from Mono.  I changed those functions to return an integer  
( I cast the boolean to an int and did Math.Abs on that int in Mono)  
and just set the returned int to a bool in C.  That worked fine, but  
now I am re-evaluating and cleaning some things up.  What would be  
the best way to take a MonoObject* referencing a Boolean and get a C  
bool out of it (or a integer representing the value of that boolean).

I have a couple of ideas for ways to do this that I know would work,  
but I have a feeling there is an easier way.

In other words, how can I get a C bool (or an int where false=0 and  
true is anything else) out of the monOb in this code:

		MonoMethodDesc *monoMethDesc2 =  mono_method_desc_new  
		MonoMethod *meth2=     mono_method_desc_search_in_class  
(monoMethDesc2, myMonoClass);
		MonoObject* monOb =  mono_runtime_invoke (meth2,  
theObjectThatOwnsTheMethodThatReturnsABoolean, NULL, NULL);

Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20081116/81bec393/attachment.html 

More information about the Mono-list mailing list