[Mono-dev] Change how mono_method_get_param_names works

Rodrigo Kumpera kumpera at gmail.com
Tue Aug 18 17:01:58 EDT 2009


Hi Robert,

I added your suggestions to the wiki page summarizing all 2.8 API
discussions.



On Tue, Aug 18, 2009 at 12:37 PM, Robert Jordan <robertj at gmx.net> wrote:

> Hi Rodrigo,
>
> Rodrigo Kumpera wrote:
> > Hi Paolo,
> >
> > I think that mono_method_get_param_names should be changed to not require
> > the caller to
> > figure out the number of parameters. In adition to that, this function
> has
> > no way to return an
> > error back to the caller.
> >
> > My suggestion is to change it to
> > MonoError mono_method_get_param_names (MonoMethod *method, char **names,
> int
> > *params)
> >
> > On success names points to a g_malloc'd array of *params strings that
> come
> > from assembly memory.
> > On failure names and params are left untouched.
>
> Speaking of which, besides the param names there is another
> bit of information not available from mono_method_* or
> mono_signature_*: the param attributes. I'm using this function
> to obtain them:
>
> /*
>  * same semantics like mono_method_get_param_names
>  */
> void
> mono_method_get_param_attrs (MonoMethod *method, guint32 *attrs)
> {
>        MonoClass *clazz = mono_method_get_class (method);
>        MonoImage *image = mono_class_get_image (clazz);
>        const MonoTableInfo *methodt, *paramt;
>        guint32 idx;
>
>        methodt = mono_image_get_table_info (image, MONO_TABLE_METHOD);
>        paramt = mono_image_get_table_info (image, MONO_TABLE_PARAM);
>
>        idx = mono_method_get_index (method);
>        if (idx > 0) {
>                guint param_index = mono_metadata_decode_row_col (methodt,
> idx - 1,
> MONO_METHOD_PARAMLIST);
>                guint32 cols [MONO_PARAM_SIZE];
>                int i, lastp;
>
>                if (idx < mono_table_info_get_rows (methodt))
>                        lastp = mono_metadata_decode_row_col (methodt, idx,
> MONO_METHOD_PARAMLIST);
>                else
>                        lastp = mono_table_info_get_rows (paramt) + 1;
>
>                for (i = param_index; i < lastp; i++) {
>                        mono_metadata_decode_row (paramt, i - 1, cols,
> MONO_PARAM_SIZE);
>                        if (cols [MONO_PARAM_SEQUENCE])
>                                attrs [cols [MONO_PARAM_SEQUENCE] - 1] =
> cols [MONO_PARAM_FLAGS];
>                }
>        }
> }
>
>
> It would be nice to have a function which is able to obtain
> these infos at a time, maybe mono_method_get_param_infos ()
> returning a MonoParamInfo* (TBD) array.
>
> Robert
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090818/0106ea49/attachment.html 


More information about the Mono-devel-list mailing list