/* INFO: toplevel udt_clr_method_call */ caddr_t dotnet_call (caddr_t * type_vec, int n_args, int _asm_type, caddr_t asm_name, caddr_t type, caddr_t method, void *udt, int sec_unrestricted) { MonoArray *v_args, *i_array = NULL, *o_array = NULL; MonoObject *mono_list; caddr_t ret = NULL; MonoDomain *domain = virtuoso_domain; get_mono_thread (); v_args = MAKE_PARAM_ARRAY (domain, 7); if (param_to_mono_array (type_vec, n_args, &i_array, &o_array)) sqlr_new_error ("22023", "MN009", "Can't convert parameters"); SET_INT_ARG (domain, v_args, 0, _asm_type); SET_INT_ARG (domain, v_args, 1, sec_unrestricted); SET_STRING_ARG (domain, v_args, 2, asm_name); SET_STRING_ARG (domain, v_args, 3, type); SET_STRING_ARG (domain, v_args, 4, method); mono_array_set (v_args, gpointer, 5, i_array); mono_array_set (v_args, gpointer, 6, o_array); mono_list = call_mono (VIRTCLR_NAME, "VInvoke:call_method_asm", v_args, domain); ret = sa_to_dk ((MonoArray *) mono_list, 0, 0, NULL); return ret; }
MonoArray * list_serial_devices (void) { MonoArray *array; #if defined(linux) /* Linux serial files are of the form ttyS[0-9]+ */ GSList *l, *list = NULL; GDir* dir = g_dir_open ("/dev", 0, NULL); const char *filename; int i = 0; while ((filename = g_dir_read_name (dir))) { if (filename) { if (!strncmp (filename, "ttyS", 4)) list = g_slist_append (list, g_strconcat ("/dev/", filename, NULL)); } } g_dir_close (dir); array = mono_array_new (mono_domain_get (), mono_get_string_class (), g_slist_length (list)); for (l = list; l; l = l->next) { mono_array_set (array, gpointer, i++, mono_string_new (mono_domain_get (), (char*)l->data)); g_free (l->data); } g_slist_free (list); #else #warning "list_serial_devices isn't ported to this OS" #endif return array; }
MonoArray *PoolRealArray_to_mono_array(const PoolRealArray &p_array) { MonoArray *ret = mono_array_new(mono_domain_get(), REAL_T_MONOCLASS, p_array.size()); for (int i = 0; i < p_array.size(); i++) { mono_array_set(ret, real_t, i, p_array[i]); } return ret; }
MonoArray *PoolByteArray_to_mono_array(const PoolByteArray &p_array) { MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(uint8_t), p_array.size()); for (int i = 0; i < p_array.size(); i++) { mono_array_set(ret, uint8_t, i, p_array[i]); } return ret; }
caddr_t clr_deserialize (dk_session_t * ses, long mode, caddr_t asm_name, caddr_t type, void *udt) { MonoArray *v_args = NULL, *bin_data; MonoArray *mono_list; int len; caddr_t in_values, bin_data_ptr; MonoDomain *domain = virtuoso_domain; get_mono_thread (); in_values = (caddr_t) scan_session_boxing (ses); if (DV_TYPE_OF (in_values) != DV_BIN) return (caddr_t) box_num (0); len = box_length (in_values); bin_data = mono_array_new (domain, mono_get_byte_class(), len); bin_data_ptr = mono_array_addr (bin_data, char, 0); memcpy (bin_data_ptr, in_values, len); if (in_values) dk_free_tree (in_values); v_args = MAKE_PARAM_ARRAY (domain, 4); mono_array_set (v_args, gpointer, 0, bin_data); SET_INT_ARG (domain, v_args, 1, mode); SET_STRING_ARG (domain, v_args, 2, asm_name); SET_STRING_ARG (domain, v_args, 3, type); QR_RESET_CTX { mono_list = (MonoArray *) call_mono (VIRTCLR_NAME, "VInvoke:obj_deserialize", v_args, domain); } QR_RESET_CODE { caddr_t err; POP_QR_RESET; err = thr_get_error_code (THREAD_CURRENT_THREAD); if (ARRAYP (err)) log_error ("Mono Deserialization error : [%s] [%s]", ERR_STATE(err), ERR_MESSAGE (err)); else log_error ("Mono Deserialization error : unknown"); dk_free_tree (err); return 0; } END_QR_RESET; return sa_to_dk ((MonoArray *) mono_list, 0, 0, udt); }
/* INFO: toplevel udt_clr_member_mutator */ caddr_t dotnet_set_property (caddr_t *type_vec, long inst, caddr_t prop_name) { MonoArray *v_args, *i_array = NULL, *o_array = NULL; MonoObject *mono_list; caddr_t ret = NULL; MonoDomain *domain = virtuoso_domain; get_mono_thread (); v_args = MAKE_PARAM_ARRAY (domain, 4); if (param_to_mono_array (type_vec, 1, &i_array, &o_array)) sqlr_new_error ("22023", "MN008", "Can't convert parameters"); SET_INT_ARG (domain, v_args, 0, inst); SET_STRING_ARG (domain, v_args, 1, prop_name); mono_array_set (v_args, gpointer, 2, i_array); mono_array_set (v_args, gpointer, 3, o_array); mono_list = call_mono (VIRTCLR_NAME, "VInvoke:set_prop", v_args, domain); ret = sa_to_dk ((MonoArray *) mono_list, 0, 0, NULL); return ret; }
/* INFO: toplevel udt_clr_instantiate_class */ int create_instance (caddr_t *type_vec, int n_args, long _mode, caddr_t asm_name, caddr_t type, void * udt) { MonoArray *v_args, *i_array = NULL, *o_array = NULL; MonoObject *mono_list; int len, ret = 0; MonoDomain *domain = virtuoso_domain; get_mono_thread (); v_args = MAKE_PARAM_ARRAY (domain, 5); if (param_to_mono_array (type_vec, n_args, &i_array, &o_array)) sqlr_new_error ("22023", "MN010", "Can't convert parameters"); SET_INT_ARG (domain, v_args, 0, _mode); SET_STRING_ARG (domain, v_args, 1, asm_name); SET_STRING_ARG (domain, v_args, 2, type); mono_array_set (v_args, gpointer, 3, i_array); mono_array_set (v_args, gpointer, 4, o_array); mono_list = call_mono (VIRTCLR_NAME, "VInvoke:create_ins_asm", v_args, domain); len = mono_array_length ((MonoArray*)mono_list); if (len == 2) { caddr_t aret = sa_to_dk ((MonoArray *) mono_list, 0, 1, udt); ret = unbox (aret); dk_free_box (aret); } else GPF_T1 ("create_instance"); return ret; }
void ves_icall_System_Globalization_CompareInfo_assign_sortkey (MonoCompareInfo *this_obj, MonoSortKey *key, MonoString *source, gint32 options) { MonoArray *arr; gint32 keylen, i; keylen=mono_string_length (source); arr=mono_array_new (mono_domain_get (), mono_get_byte_class (), keylen); for(i=0; i<keylen; i++) { mono_array_set (arr, guint8, i, mono_string_chars (source)[i]); } MONO_OBJECT_SETREF (key, key, arr); }
MonoArray *PoolVector2Array_to_mono_array(const PoolVector2Array &p_array) { MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Vector2), p_array.size()); for (int i = 0; i < p_array.size(); i++) { #ifdef YOLOCOPY mono_array_set(ret, Vector2, i, p_array[i]); #else real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 2, i); const Vector2 &elem = p_array[i]; raw[0] = elem.x; raw[1] = elem.y; #endif } return ret; }
MonoArray *PoolColorArray_to_mono_array(const PoolColorArray &p_array) { MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(Color), p_array.size()); for (int i = 0; i < p_array.size(); i++) { #ifdef YOLOCOPY mono_array_set(ret, Color, i, p_array[i]); #else real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 4, i); const Color &elem = p_array[i]; raw[0] = elem.r; raw[1] = elem.g; raw[2] = elem.b; raw[3] = elem.a; #endif } return ret; }
static MonoArray * glist_to_array (GList *list, MonoClass *eclass) { MonoDomain *domain = mono_domain_get (); MonoArray *res; int len, i; if (!list) return NULL; len = g_list_length (list); res = mono_array_new (domain, eclass, len); for (i = 0; list; list = list->next, i++) mono_array_set (res, gpointer, i, list->data); return res; }
static MonoArray* create_group_sizes_array (const gint *gs, gint ml) { MonoArray *ret; int i, len = 0; for (i = 0; i < ml; i++) { if (gs [i] == -1) break; len++; } ret = mono_array_new_cached (mono_domain_get (), mono_get_int32_class (), len); for(i = 0; i < len; i++) mono_array_set (ret, gint32, i, gs [i]); return ret; }
static MonoArray* create_group_sizes_array (const gint *gs, gint ml, MonoError *error) { MonoArray *ret; int i, len = 0; error_init (error); for (i = 0; i < ml; i++) { if (gs [i] == -1) break; len++; } ret = mono_array_new_cached (mono_domain_get (), mono_get_int32_class (), len, error); return_val_if_nok (error, NULL); for(i = 0; i < len; i++) mono_array_set (ret, gint32, i, gs [i]); return ret; }
static void set_control_chars (MonoArray *control_chars, const guchar *cc) { /* The index into the array comes from corlib/System/ControlCharacters.cs */ #ifdef VINTR mono_array_set (control_chars, gchar, 0, cc [VINTR]); #endif #ifdef VQUIT mono_array_set (control_chars, gchar, 1, cc [VQUIT]); #endif #ifdef VERASE mono_array_set (control_chars, gchar, 2, cc [VERASE]); #endif #ifdef VKILL mono_array_set (control_chars, gchar, 3, cc [VKILL]); #endif #ifdef VEOF mono_array_set (control_chars, gchar, 4, cc [VEOF]); #endif #ifdef VTIME mono_array_set (control_chars, gchar, 5, cc [VTIME]); #endif #ifdef VMIN mono_array_set (control_chars, gchar, 6, cc [VMIN]); #endif #ifdef VSWTC mono_array_set (control_chars, gchar, 7, cc [VSWTC]); #endif #ifdef VSTART mono_array_set (control_chars, gchar, 8, cc [VSTART]); #endif #ifdef VSTOP mono_array_set (control_chars, gchar, 9, cc [VSTOP]); #endif #ifdef VSUSP mono_array_set (control_chars, gchar, 10, cc [VSUSP]); #endif #ifdef VEOL mono_array_set (control_chars, gchar, 11, cc [VEOL]); #endif #ifdef VREPRINT mono_array_set (control_chars, gchar, 12, cc [VREPRINT]); #endif #ifdef VDISCARD mono_array_set (control_chars, gchar, 13, cc [VDISCARD]); #endif #ifdef VWERASE mono_array_set (control_chars, gchar, 14, cc [VWERASE]); #endif #ifdef VLNEXT mono_array_set (control_chars, gchar, 15, cc [VLNEXT]); #endif #ifdef VEOL2 mono_array_set (control_chars, gchar, 16, cc [VEOL2]); #endif }
MonoObject* JniManager::toMonoObject(JNIEnv* env, jobject obj) { assert(env); MonoDomain* monoDomain = getMonoDomain(); MonoObject* result = NULL; jclass clazz = env->GetObjectClass(obj); jstring clazzName = (jstring)env->CallObjectMethod(clazz, typeConverter->getClassName); string className = string(typeConverter->convertToC<string>(env, clazzName)); if (className == "java.lang.Integer") { int value = typeConverter->convertToC<int>(env, obj); result = mono_value_box(monoDomain, mono_get_int32_class(), &value); } if (className == "java.lang.String") { string value = typeConverter->convertToC<string>(env, obj); result = (MonoObject*)mono_string_new(monoDomain, value.c_str()); } if (className == "java.lang.Boolean") { bool value = typeConverter->convertToC<bool>(env, obj); result = (MonoObject*)mono_value_box(monoDomain, mono_get_boolean_class(), &value); } if (className == "java.lang.Character") { char value = typeConverter->convertToC<char>(env, obj); result = (MonoObject*)mono_value_box(monoDomain, mono_get_char_class(), &value); } if (className == "java.lang.Long") { long value = typeConverter->convertToC<long>(env, obj); result = (MonoObject*)mono_value_box(monoDomain, mono_get_int64_class(), &value); } if (className == "java.lang.Short") { short value = typeConverter->convertToC<short>(env, obj); result = (MonoObject*)mono_value_box(monoDomain, mono_get_int16_class(), &value); } if (className =="java.lang.Byte") { byte value = typeConverter->convertToC<byte>(env, obj); result = (MonoObject*)mono_value_box(monoDomain, mono_get_byte_class(), &value); } if (className == "java.lang.Double" ) { double value = typeConverter->convertToC<double>(env, obj); result = (MonoObject*)mono_value_box(monoDomain, mono_get_double_class(), &value); } if (className == "java.lang.Float" ) { float value = typeConverter->convertToC<float>(env, obj); result = (MonoObject*)mono_value_box(monoDomain, mono_get_single_class(), &value); } if (className == "[B") { vector<byte> value = typeConverter->convertToC< vector<byte> >(env, obj); int vectorSize = value.size(); MonoArray *data = mono_array_new (monoDomain, mono_get_byte_class (), vectorSize); for (int i=0; i<vectorSize; i++) { mono_array_set(data, uint8_t, i, value[i]); } result = (MonoObject*)data; } env->DeleteLocalRef(obj); return result; }
static int param_to_mono_array (caddr_t *list_args, int n_args, MonoArray ** p_i_array, MonoArray **p_o_array) { caddr_t * line; MonoObject *arg = NULL; MonoDomain *domain = virtuoso_domain; MonoArray *i_array, *o_array; guint32 is_object; int inx; i_array = (MonoArray*)mono_array_new (domain, mono_get_object_class (), n_args); o_array = (MonoArray*)mono_array_new (domain, mono_get_intptr_class (), n_args); for (inx = 0; inx < n_args; ++inx) { line = (caddr_t *) list_args[inx]; is_object = 0; if (DV_TYPE_OF (line[1]) == DV_DB_NULL) { arg = NULL; goto put_it; } if (!strncmp (line[0], "System.String", sizeof ("System.String")) || !strncmp (line[0], "String", sizeof ("String"))) { if (!DV_STRINGP (line[1])) goto convert_error; arg = (MonoObject *) mono_string_new (domain, line[1]); } else if (!strncmp (line[0], "Int32", sizeof ("Int32")) || !strncmp (line[0], "System.Int32", sizeof ("System.Int32")) || !strncmp (line[0], "int", sizeof ("int"))) { gint32 ivalue; if (DV_TYPE_OF (line[1]) != DV_LONG_INT) goto convert_error; ivalue = unbox (line[1]); arg = mono_value_box (domain, mono_get_int32_class (), &ivalue); } else if (!strncmp (line[0], "System.Single", sizeof ("System.Single")) || !strncmp (line[0], "Single", sizeof ("Single"))) { float flt_value; if (DV_TYPE_OF (line[1]) != DV_SINGLE_FLOAT) goto convert_error; flt_value = unbox_float (line[1]); arg = mono_value_box (domain, mono_get_single_class (), &flt_value); } else if (!strncmp (line[0], "System.Data.SqlTypes.SqlDouble", sizeof ("System.Data.SqlTypes.SqlDouble")) || !strncmp (line[0], "System.Double", sizeof ("System.Double")) || !strncmp (line[0], "Double", sizeof ("Double"))) { double dbl_value; if (DV_TYPE_OF (line[1]) != DV_DOUBLE_FLOAT) goto convert_error; dbl_value = unbox_double (line[1]); arg = mono_value_box (domain, mono_get_double_class (), &dbl_value); } else /*if (!strncmp (line[0], "CLRObject", sizeof ("CLRObject"))) */ { gint32 ivalue; if (DV_TYPE_OF (line[1]) != DV_LONG_INT) goto convert_error; is_object = unbox (line[1]); arg = mono_value_box (domain, mono_get_int32_class (), &ivalue); } put_it: mono_array_set (i_array, gpointer, inx, arg); mono_array_set (o_array, gpointer, inx, (gpointer) is_object); } *p_i_array = i_array; *p_o_array = o_array; return 0; convert_error: sqlr_new_error ("22023", "XXXXX", "wrong or unknown type"); return 0; }