return res;
}
-#ifndef DISABLE_JIT
static int
emit_marshal_custom (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec,
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifdef DISABLE_JIT
+ if (action == MARSHAL_ACTION_CONV_IN && t->type == MONO_TYPE_VALUETYPE)
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ return conv_arg;
+#else
MonoType *mtype;
MonoClass *mklass;
static MonoClass *ICustomMarshaler = NULL;
default:
g_assert_not_reached ();
}
-
return conv_arg;
+#endif
+
}
static int
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifndef DISABLE_JIT
MonoMethodBuilder *mb = m->mb;
switch (action) {
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifndef DISABLE_JIT
MonoMethodBuilder *mb = m->mb;
MonoClass *klass, *date_time_class;
int pos = 0, pos2;
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifdef DISABLE_JIT
+ switch (action) {
+ case MARSHAL_ACTION_CONV_IN:
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ break;
+ case MARSHAL_ACTION_MANAGED_CONV_IN:
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ break;
+ }
+#else
MonoMethodBuilder *mb = m->mb;
MonoMarshalNative encoding = mono_marshal_get_string_encoding (m->piinfo, spec);
MonoMarshalConv conv = mono_marshal_get_string_to_ptr_conv (m->piinfo, spec);
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
+
static int
emit_marshal_safehandle (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec, int conv_arg,
MonoType **conv_arg_type, MarshalAction action)
{
+#ifdef DISABLE_JIT
+ if (action == MARSHAL_ACTION_CONV_IN)
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+#else
MonoMethodBuilder *mb = m->mb;
switch (action){
default:
printf ("Unhandled case for MarshalAction: %d\n", action);
}
-
+#endif
return conv_arg;
}
+
static int
emit_marshal_handleref (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec, int conv_arg,
MonoType **conv_arg_type, MarshalAction action)
{
+#ifdef DISABLE_JIT
+ if (action == MARSHAL_ACTION_CONV_IN)
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+#else
MonoMethodBuilder *mb = m->mb;
switch (action){
default:
fprintf (stderr, "Unhandled case for MarshalAction: %d\n", action);
}
-
+#endif
return conv_arg;
}
+
static int
emit_marshal_object (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec,
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifdef DISABLE_JIT
+ if (action == MARSHAL_ACTION_CONV_IN)
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+#else
MonoMethodBuilder *mb = m->mb;
MonoClass *klass = mono_class_from_mono_type (t);
int pos, pos2, loc;
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
+#ifndef DISABLE_JIT
#ifndef DISABLE_COM
}
#endif /* DISABLE_COM */
+#endif /* DISABLE_JIT */
static gboolean
mono_pinvoke_is_unicode (MonoMethodPInvoke *piinfo)
}
}
+
static int
emit_marshal_array (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec,
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifdef DISABLE_JIT
+ switch (action) {
+ case MARSHAL_ACTION_CONV_IN:
+ *conv_arg_type = &mono_defaults.object_class->byval_arg;
+ break;
+ case MARSHAL_ACTION_MANAGED_CONV_IN:
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ break;
+ }
+#else
MonoMethodBuilder *mb = m->mb;
MonoClass *klass = mono_class_from_mono_type (t);
gboolean need_convert, need_free;
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
+static MonoType*
+marshal_boolean_conv_in_get_local_type (MonoMarshalSpec *spec, guint8 *ldc_op /*out*/)
+{
+ if (spec == NULL) {
+ return &mono_defaults.int32_class->byval_arg;
+ } else {
+ switch (spec->native) {
+ case MONO_NATIVE_I1:
+ case MONO_NATIVE_U1:
+ return &mono_defaults.byte_class->byval_arg;
+ case MONO_NATIVE_VARIANTBOOL:
+ if (ldc_op) *ldc_op = CEE_LDC_I4_M1;
+ return &mono_defaults.int16_class->byval_arg;
+ case MONO_NATIVE_BOOLEAN:
+ return &mono_defaults.int32_class->byval_arg;
+ default:
+ g_warning ("marshalling bool as native type %x is currently not supported", spec->native);
+ return &mono_defaults.int32_class->byval_arg;
+ }
+ }
+}
+
+static MonoClass*
+marshal_boolean_managed_conv_in_get_conv_arg_class (MonoMarshalSpec *spec, guint8 *ldop/*out*/)
+{
+ MonoClass* conv_arg_class = mono_defaults.int32_class;
+ if (spec) {
+ switch (spec->native) {
+ case MONO_NATIVE_I1:
+ case MONO_NATIVE_U1:
+ conv_arg_class = mono_defaults.byte_class;
+ if (ldop) *ldop = CEE_LDIND_I1;
+ break;
+ case MONO_NATIVE_VARIANTBOOL:
+ conv_arg_class = mono_defaults.int16_class;
+ if (ldop) *ldop = CEE_LDIND_I2;
+ break;
+ case MONO_NATIVE_BOOLEAN:
+ break;
+ default:
+ g_warning ("marshalling bool as native type %x is currently not supported", spec->native);
+ }
+ }
+ return conv_arg_class;
+}
+
static int
emit_marshal_boolean (EmitMarshalContext *m, int argnum, MonoType *t,
MonoMarshalSpec *spec,
int conv_arg, MonoType **conv_arg_type,
MarshalAction action)
{
+#ifdef DISABLE_JIT
+ switch (action) {
+ case MARSHAL_ACTION_CONV_IN:
+ if (t->byref)
+ *conv_arg_type = &mono_defaults.int_class->byval_arg;
+ else
+ *conv_arg_type = marshal_boolean_conv_in_get_local_type (spec, NULL);
+ break;
+
+ case MARSHAL_ACTION_MANAGED_CONV_IN: {
+ MonoClass* conv_arg_class = marshal_boolean_managed_conv_in_get_conv_arg_class (spec, NULL);
+ if (t->byref)
+ *conv_arg_type = &conv_arg_class->this_arg;
+ else
+ *conv_arg_type = &conv_arg_class->byval_arg;
+ break;
+ }
+
+ }
+#else
MonoMethodBuilder *mb = m->mb;
switch (action) {
int label_false;
guint8 ldc_op = CEE_LDC_I4_1;
- if (spec == NULL) {
- local_type = &mono_defaults.int32_class->byval_arg;
- } else {
- switch (spec->native) {
- case MONO_NATIVE_I1:
- case MONO_NATIVE_U1:
- local_type = &mono_defaults.byte_class->byval_arg;
- break;
- case MONO_NATIVE_VARIANTBOOL:
- local_type = &mono_defaults.int16_class->byval_arg;
- ldc_op = CEE_LDC_I4_M1;
- break;
- case MONO_NATIVE_BOOLEAN:
- local_type = &mono_defaults.int32_class->byval_arg;
- break;
- default:
- g_warning ("marshalling bool as native type %x is currently not supported", spec->native);
- local_type = &mono_defaults.int32_class->byval_arg;
- break;
- }
- }
+ local_type = marshal_boolean_conv_in_get_local_type (spec, &ldc_op);
if (t->byref)
*conv_arg_type = &mono_defaults.int_class->byval_arg;
else
guint8 ldop = CEE_LDIND_I4;
int label_null, label_false;
+ conv_arg_class = marshal_boolean_managed_conv_in_get_conv_arg_class (spec, &ldop);
conv_arg = mono_mb_add_local (mb, &mono_defaults.boolean_class->byval_arg);
- if (spec) {
- switch (spec->native) {
- case MONO_NATIVE_I1:
- case MONO_NATIVE_U1:
- conv_arg_class = mono_defaults.byte_class;
- ldop = CEE_LDIND_I1;
- break;
- case MONO_NATIVE_VARIANTBOOL:
- conv_arg_class = mono_defaults.int16_class;
- ldop = CEE_LDIND_I2;
- break;
- case MONO_NATIVE_BOOLEAN:
- break;
- default:
- g_warning ("marshalling bool as native type %x is currently not supported", spec->native);
- }
- }
-
if (t->byref)
*conv_arg_type = &conv_arg_class->this_arg;
else
default:
g_assert_not_reached ();
}
-
+#endif
return conv_arg;
}
MonoMarshalSpec *spec, int conv_arg,
MonoType **conv_arg_type, MarshalAction action)
{
+#ifndef DISABLE_JIT
MonoMethodBuilder *mb = m->mb;
switch (action) {
default:
break;
}
-
+#endif
return conv_arg;
}
MonoMarshalSpec *spec, int conv_arg,
MonoType **conv_arg_type, MarshalAction action)
{
+#ifndef DISABLE_JIT
MonoMethodBuilder *mb = m->mb;
switch (action) {
default:
break;
}
-
+#endif
return conv_arg;
}
MonoMarshalSpec *spec, int conv_arg,
MonoType **conv_arg_type, MarshalAction action)
{
+#ifndef DISABLE_JIT
MonoMethodBuilder *mb = m->mb;
switch (action) {
default:
break;
}
-
+#endif
return conv_arg;
}
else
return emit_marshal_object (m, argnum, t, spec, conv_arg, conv_arg_type, action);
}
-
return conv_arg;
}
+#ifndef DISABLE_JIT
/**
* mono_marshal_emit_native_wrapper:
* @image: the image to use for looking up custom marshallers
mono_mb_emit_byte (mb, CEE_RET);
}
-
#endif /* DISABLE_JIT */
+
G_GNUC_UNUSED static void
code_for (MonoMethod *method) {
MonoMethodHeader *header = mono_method_get_header (method);
return res;
}
-#ifndef DISABLE_JIT
/*
* mono_marshal_emit_managed_wrapper:
*
void
mono_marshal_emit_managed_wrapper (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, uint32_t target_handle)
{
+#ifdef DISABLE_JIT
+ MonoMethodSignature *sig, *csig;
+ int i;
+
+ sig = m->sig;
+ csig = m->csig;
+
+ /* we first do all conversions */
+ for (i = 0; i < sig->param_count; i ++) {
+ MonoType *t = sig->params [i];
+
+ switch (t->type) {
+ case MONO_TYPE_OBJECT:
+ case MONO_TYPE_CLASS:
+ case MONO_TYPE_VALUETYPE:
+ case MONO_TYPE_ARRAY:
+ case MONO_TYPE_SZARRAY:
+ case MONO_TYPE_STRING:
+ case MONO_TYPE_BOOLEAN:
+ emit_marshal (m, i, sig->params [i], mspecs [i + 1], 0, &csig->params [i], MARSHAL_ACTION_MANAGED_CONV_IN);
+ }
+ }
+#else
MonoMethodSignature *sig, *csig;
int i, *tmp_locals;
gboolean closed = FALSE;
if (closed)
g_free (sig);
+#endif
}
-#endif /* DISABLE_JIT */
static void
mono_marshal_set_callconv_from_modopt (MonoMethod *method, MonoMethodSignature *csig)
mono_custom_attrs_free (cinfo);
}
-#ifndef DISABLE_JIT
mono_marshal_emit_managed_wrapper (mb, invoke_sig, mspecs, &m, method, target_handle);
-#endif
if (!target_handle) {
WrapperInfo *info;
/* FIXME: Implement VTFIXUP_TYPE_FROM_UNMANAGED_RETAIN_APPDOMAIN. */
-#ifndef DISABLE_JIT
mono_marshal_emit_managed_wrapper (mb, sig, mspecs, &m, method, 0);
+#ifndef DISABLE_JIT
mb->dynamic = 1;
#endif
method = mono_mb_create_method (mb, csig, sig->param_count + 16);