Exemplo n.º 1
0
void MonoEmbedding::Initialize()
{
    // Construct the absolute file path to MonoEmbedding.exe assuming
    // it is located next to edge.node
    Dl_info dlinfo;
    char fullPath[PATH_MAX];
    dladdr((void*)&MonoEmbedding::Initialize, &dlinfo);
    strcpy(fullPath, dlinfo.dli_fname);
    strcpy(fullPath, dirname(fullPath));
    strcat(fullPath, "/MonoEmbedding.exe");

    mono_jit_init (fullPath);
    assembly = mono_domain_assembly_open (mono_domain_get(), fullPath);
    MonoClass* klass = mono_class_from_name(mono_assembly_get_image(assembly), "", "MonoEmbedding");
    MonoMethod* main = mono_class_get_method_from_name(klass, "Main", -1);
    MonoException* exc;
    MonoArray* args = mono_array_new(mono_domain_get(), mono_get_string_class(), 0);
    mono_runtime_exec_main(main, args, (MonoObject**)&exc);

    mono_add_internal_call("ClrFuncInvokeContext::CompleteOnV8ThreadAsynchronousICall", (const void*)&ClrFuncInvokeContext::CompleteOnV8ThreadAsynchronous); 
    mono_add_internal_call("ClrFuncInvokeContext::CompleteOnCLRThreadICall", (const void*)&ClrFuncInvokeContext::CompleteOnCLRThread); 
    mono_add_internal_call("NodejsFuncInvokeContext::CallFuncOnV8ThreadInternal", (const void*)&NodejsFuncInvokeContext::CallFuncOnV8Thread); 
    mono_add_internal_call("NodejsFunc::ExecuteActionOnV8Thread", (const void*)&NodejsFunc::ExecuteActionOnV8Thread); 
    mono_add_internal_call("NodejsFunc::Release", (const void*)&NodejsFunc::Release); 
}
Exemplo n.º 2
0
static gpointer dispatch_callback(SignalData *sig_data, int num_vals, ...)
{
	MonoArray *array;
	MonoObject *obj;
	int i;
	gpointer meth_args[1];
	gpointer purple_obj;
	
	va_list args;
	
	va_start(args, num_vals);
	
	array = mono_array_new(ml_get_domain(), mono_get_object_class(), num_vals);
	
	for (i = 0; i < num_vals; i++) {
		if (purple_value_get_type(sig_data->values[i]) == PURPLE_TYPE_SUBTYPE) {
			purple_obj = va_arg(args, gpointer);
			obj = ml_object_from_purple_subtype(purple_value_get_subtype(sig_data->values[i]), purple_obj);
			mono_array_set(array, MonoObject*, i, obj);
		} else {
			purple_obj = va_arg(args, gpointer);
			obj = ml_object_from_purple_type(purple_value_get_type(sig_data->values[i]), purple_obj);
			mono_array_set(array, MonoObject*, i, obj);
		}
	}
	
	va_end(args);
	
	meth_args[0] = array;
	
	return ml_delegate_invoke(sig_data->func, meth_args);	
}
Exemplo n.º 3
0
MonoBoolean
ves_icall_System_ConsoleDriver_TtySetup (MonoString *keypad, MonoString *teardown, MonoArray **control_chars, int **size)
{
	int dims;

	MONO_ARCH_SAVE_REGS;

	dims = terminal_get_dimensions ();
	if (dims == -1){
		int cols = 0, rows = 0;
				      
		char *str = getenv ("COLUMNS");
		if (str != NULL)
			cols = atoi (str);
		str = getenv ("LINES");
		if (str != NULL)
			rows = atoi (str);

		if (cols != 0 && rows != 0)
			cols_and_lines = (cols << 16) | rows;
		else
			cols_and_lines = -1;
	} else {
		cols_and_lines = dims;
	}
	
	*size = &cols_and_lines;

	/* 17 is the number of entries set in set_control_chars() above.
	 * NCCS is the total size, but, by now, we only care about those 17 values*/
	mono_gc_wbarrier_generic_store (control_chars, (MonoObject*) mono_array_new (mono_domain_get (), mono_defaults.byte_class, 17));
	if (tcgetattr (STDIN_FILENO, &initial_attr) == -1)
		return FALSE;

	mono_attr = initial_attr;
	mono_attr.c_lflag &= ~(ICANON);
	mono_attr.c_iflag &= ~(IXON|IXOFF);
	mono_attr.c_cc [VMIN] = 1;
	mono_attr.c_cc [VTIME] = 0;
	if (tcsetattr (STDIN_FILENO, TCSANOW, &mono_attr) == -1)
		return FALSE;

	set_control_chars (*control_chars, mono_attr.c_cc);
	/* If initialized from another appdomain... */
	if (setup_finished)
		return TRUE;

	keypad_xmit_str = keypad != NULL ? mono_string_to_utf8 (keypad) : NULL;
	
	console_set_signal_handlers ();
	setup_finished = TRUE;
	if (!atexit_called) {
		if (teardown != NULL)
			teardown_str = mono_string_to_utf8 (teardown);

		atexit (tty_teardown);
	}

	return TRUE;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
MonoArray *PoolStringArray_to_mono_array(const PoolStringArray &p_array) {
	MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), p_array.size());

	for (int i = 0; i < p_array.size(); i++) {
		MonoString *boxed = mono_string_from_godot(p_array[i]);
		mono_array_set(ret, MonoString *, i, boxed);
	}

	return ret;
}
Exemplo n.º 8
0
MonoArray *Array_to_mono_array(const Array &p_array) {
	MonoArray *ret = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), p_array.size());

	for (int i = 0; i < p_array.size(); i++) {
		MonoObject *boxed = variant_to_mono_object(p_array[i]);
		mono_array_setref(ret, i, boxed);
	}

	return ret;
}
Exemplo n.º 9
0
/* http://www.dotnet247.com/247reference/msgs/39/195403.aspx
// internal static string[] WindowsIdentity._GetRoles (IntPtr token)
*/
MonoArray*
ves_icall_System_Security_Principal_WindowsIdentity_GetRoles (gpointer token)
{
    MonoArray *array = NULL;
    MonoDomain *domain = mono_domain_get ();
#ifdef HOST_WIN32
    gint32 size = 0;

    MONO_ARCH_SAVE_REGS;

    GetTokenInformation (token, TokenGroups, NULL, size, (PDWORD)&size);
    if (size > 0) {
        TOKEN_GROUPS *tg = g_malloc0 (size);
        if (GetTokenInformation (token, TokenGroups, tg, size, (PDWORD)&size)) {
            int i=0;
            int num = tg->GroupCount;

            array = mono_array_new (domain, mono_get_string_class (), num);

            for (i=0; i < num; i++) {
                gint32 size = 0;
                gunichar2 *uniname = GetSidName (NULL, tg->Groups [i].Sid, &size);

                if (uniname) {
                    MonoString *str = mono_string_new_utf16 (domain, uniname, size);
                    mono_array_setref (array, i, str);
                    g_free (uniname);
                }
            }
        }
        g_free (tg);
    }
#else
    /* POSIX-compliant systems should use IsMemberOfGroupId or IsMemberOfGroupName */
    g_warning ("WindowsIdentity._GetRoles should never be called on POSIX");
#endif
    if (!array) {
        /* return empty array of string, i.e. string [0] */
        array = mono_array_new (domain, mono_get_string_class (), 0);
    }
    return array;
}
Exemplo n.º 10
0
MonoArray*
ves_icall_System_Globalization_CultureInfo_internal_get_cultures (MonoBoolean neutral,
		MonoBoolean specific, MonoBoolean installed)
{
	MonoArray *ret;
	MonoClass *klass;
	MonoCultureInfo *culture;
	MonoDomain *domain;
	const CultureInfoEntry *ci;
	gint i, len;
	gboolean is_neutral;

	domain = mono_domain_get ();

	len = 0;
	for (i = 0; i < NUM_CULTURE_ENTRIES; i++) {
		ci = &culture_entries [i];
		is_neutral = ci->territory == 0;
		if ((neutral && is_neutral) || (specific && !is_neutral))
			len++;
	}

	klass = mono_class_from_name (mono_get_corlib (),
			"System.Globalization", "CultureInfo");

	/* The InvariantCulture is not in culture_entries */
	/* We reserve the first slot in the array for it */
	if (neutral)
		len++;

	ret = mono_array_new (domain, klass, len);

	if (len == 0)
		return ret;

	len = 0;
	if (neutral)
		mono_array_setref (ret, len++, NULL);

	for (i = 0; i < NUM_CULTURE_ENTRIES; i++) {
		ci = &culture_entries [i];
		is_neutral = ci->territory == 0;
		if ((neutral && is_neutral) || (specific && !is_neutral)) {
			culture = (MonoCultureInfo *) mono_object_new (domain, klass);
			mono_runtime_object_init ((MonoObject *) culture);
			construct_culture (culture, ci);
			culture->use_user_override = TRUE;
			mono_array_setref (ret, len++, culture);
		}
	}

	return ret;
}
Exemplo n.º 11
0
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);
}
Exemplo n.º 12
0
MonoArray *godot_icall_DynamicGodotObject_SetMemberList(Object *p_ptr) {
	List<PropertyInfo> property_list;
	p_ptr->get_property_list(&property_list);

	MonoArray *result = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), property_list.size());

	int i = 0;
	for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
		MonoString *boxed = GDMonoMarshal::mono_string_from_godot(E->get().name);
		mono_array_set(result, MonoString *, i, boxed);
		i++;
	}

	return result;
}
Exemplo n.º 13
0
CDynScriptArray::CDynScriptArray(MonoDomain *pDomain, IMonoClass *pContainingType, int size)
{
	CRY_ASSERT(size >= 0);
	CRY_ASSERT(pDomain);

	m_lastIndex = -1;

	m_pElementClass = (pContainingType ? (MonoClass *)(pContainingType)->GetManagedObject() : m_pDefaultElementClass);
	CRY_ASSERT(m_pElementClass);

	m_pObject = (MonoObject *)mono_array_new(pDomain, m_pElementClass, size);
	m_objectHandle = mono_gchandle_new(m_pObject, false);

	m_pClass = NULL;
}
Exemplo n.º 14
0
MonoObject *Dictionary_to_mono_object(const Dictionary &p_dict) {
	MonoArray *keys = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), p_dict.size());
	MonoArray *values = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), p_dict.size());

	int i = 0;
	const Variant *dkey = NULL;
	while ((dkey = p_dict.next(dkey))) {
		mono_array_set(keys, MonoObject *, i, variant_to_mono_object(dkey));
		mono_array_set(values, MonoObject *, i, variant_to_mono_object(p_dict[*dkey]));
		i++;
	}

	GDMonoUtils::MarshalUtils_ArraysToDict arrays_to_dict = CACHED_METHOD_THUNK(MarshalUtils, ArraysToDictionary);

	MonoObject *ex = NULL;
	MonoObject *ret = arrays_to_dict(keys, values, &ex);

	if (ex) {
		mono_print_unhandled_exception(ex);
		ERR_FAIL_V(NULL);
	}

	return ret;
}
Exemplo n.º 15
0
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);
}
Exemplo n.º 16
0
Variant SignalAwaiterHandle::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {

#ifdef DEBUG_ENABLED
	if (conn_target_id && !ObjectDB::get_instance(conn_target_id)) {
		ERR_EXPLAIN("Resumed after await, but class instance is gone");
		ERR_FAIL_V(Variant());
	}
#endif

	if (p_argcount < 1) {
		r_error.error = Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS;
		r_error.argument = 1;
		return Variant();
	}

	Ref<SignalAwaiterHandle> self = *p_args[p_argcount - 1];

	if (self.is_null()) {
		r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
		r_error.argument = p_argcount - 1;
		r_error.expected = Variant::OBJECT;
		return Variant();
	}

	set_completed(true);

	int signal_argc = p_argcount - 1;
	MonoArray *signal_args = mono_array_new(SCRIPTS_DOMAIN, CACHED_CLASS_RAW(MonoObject), signal_argc);

	for (int i = 0; i < signal_argc; i++) {
		MonoObject *boxed = GDMonoMarshal::variant_to_mono_object(*p_args[i]);
		mono_array_set(signal_args, MonoObject *, i, boxed);
	}

	GDMonoUtils::SignalAwaiter_SignalCallback thunk = CACHED_METHOD_THUNK(SignalAwaiter, SignalCallback);

	MonoException *exc = NULL;
	GD_MONO_BEGIN_RUNTIME_INVOKE;
	thunk(get_target(), signal_args, (MonoObject **)&exc);
	GD_MONO_END_RUNTIME_INVOKE;

	if (exc) {
		GDMonoUtils::set_pending_exception(exc);
		ERR_FAIL_V(Variant());
	}

	return Variant();
}
Exemplo n.º 17
0
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;
}
Exemplo n.º 18
0
void GDMonoProperty::set_value(MonoObject *p_object, MonoObject *p_value, MonoObject **r_exc) {
	MonoMethod *prop_method = mono_property_get_set_method(mono_property);

	MonoArray *params = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), 1);
	mono_array_set(params, MonoObject *, 0, p_value);

	MonoObject *exc = NULL;
	mono_runtime_invoke_array(prop_method, p_object, params, &exc);

	if (exc) {
		if (r_exc) {
			*r_exc = exc;
		} else {
			GDMonoUtils::print_unhandled_exception(exc);
		}
	}
}
Exemplo n.º 19
0
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;
}
Exemplo n.º 20
0
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;
}
Exemplo n.º 21
0
static int
mono_attach_load_agent (MonoDomain *domain, char *agent, char *args, MonoObject **exc)
{
	MonoError error;
	MonoAssembly *agent_assembly;
	MonoImage *image;
	MonoMethod *method;
	guint32 entry;
	MonoArray *main_args;
	gpointer pa [1];
	MonoImageOpenStatus open_status;

	agent_assembly = mono_assembly_open (agent, &open_status);
	if (!agent_assembly) {
		fprintf (stderr, "Cannot open agent assembly '%s': %s.\n", agent, mono_image_strerror (open_status));
		g_free (agent);
		return 2;
	}

	/* 
	 * Can't use mono_jit_exec (), as it sets things which might confuse the
	 * real Main method.
	 */
	image = mono_assembly_get_image (agent_assembly);
	entry = mono_image_get_entry_point (image);
	if (!entry) {
		g_print ("Assembly '%s' doesn't have an entry point.\n", mono_image_get_filename (image));
		g_free (agent);
		return 1;
	}

	method = mono_get_method_checked (image, entry, NULL, NULL, &error);
	if (method == NULL){
		g_print ("The entry point method of assembly '%s' could not be loaded due to %s\n", agent, mono_error_get_message (&error));
		mono_error_cleanup (&error);
		g_free (agent);
		return 1;
	}
	
	if (args) {
		main_args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, 1);
		mono_array_set (main_args, MonoString*, 0, mono_string_new (domain, args));
	} else {
Exemplo n.º 22
0
MonoObject *GDMonoMethod::invoke(MonoObject *p_object, const Variant **p_params, MonoObject **r_exc) {
	if (get_return_type().type_encoding != MONO_TYPE_VOID || get_parameters_count() > 0) {
		MonoArray *params = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(MonoObject), get_parameters_count());

		for (int i = 0; i < params_count; i++) {
			MonoObject *boxed_param = GDMonoMarshal::variant_to_mono_object(p_params[i], param_types[i]);
			mono_array_set(params, MonoObject *, i, boxed_param);
		}

		MonoObject *exc = NULL;
		MonoObject *ret = mono_runtime_invoke_array(mono_method, p_object, params, &exc);

		if (exc) {
			ret = NULL;
			if (r_exc) {
				*r_exc = exc;
			} else {
				GDMonoUtils::print_unhandled_exception(exc);
			}
		}

		return ret;
	} else {
		MonoObject *exc = NULL;
		mono_runtime_invoke(mono_method, p_object, NULL, &exc);

		if (exc) {
			if (r_exc) {
				*r_exc = exc;
			} else {
				GDMonoUtils::print_unhandled_exception(exc);
			}
		}

		return NULL;
	}
}
Exemplo n.º 23
0
		return 1;
	}

	method = mono_get_method_checked (image, entry, NULL, NULL, &error);
	if (method == NULL){
		g_print ("The entry point method of assembly '%s' could not be loaded due to %s\n", agent, mono_error_get_message (&error));
		mono_error_cleanup (&error);
		g_free (agent);
		return 1;
	}
	
	if (args) {
		main_args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, 1);
		mono_array_set (main_args, MonoString*, 0, mono_string_new (domain, args));
	} else {
		main_args = (MonoArray*)mono_array_new (domain, mono_defaults.string_class, 0);
	}

	g_free (agent);

	pa [0] = main_args;
	mono_runtime_try_invoke (method, NULL, pa, exc, &error);
	mono_error_raise_exception (&error); /* FIXME don't raise here */

	return 0;
}

/*
 * ipc_connect:
 *
 *   Create a UNIX domain socket and bind it to a file in /tmp.
Exemplo n.º 24
0
void GodotSharpExport::_export_begin(const Set<String> &p_features, bool p_debug, const String &p_path, int p_flags) {

	// TODO right now there is no way to stop the export process with an error

	ERR_FAIL_COND(!GDMono::get_singleton()->is_runtime_initialized());
	ERR_FAIL_NULL(TOOLS_DOMAIN);
	ERR_FAIL_NULL(GDMono::get_singleton()->get_editor_tools_assembly());

	if (FileAccess::exists(GodotSharpDirs::get_project_sln_path())) {
		String build_config = p_debug ? "Debug" : "Release";

		String scripts_metadata_path = GodotSharpDirs::get_res_metadata_dir().plus_file("scripts_metadata." + String(p_debug ? "debug" : "release"));
		Error metadata_err = CSharpProject::generate_scripts_metadata(GodotSharpDirs::get_project_csproj_path(), scripts_metadata_path);
		ERR_FAIL_COND(metadata_err != OK);

		ERR_FAIL_COND(!_add_file(scripts_metadata_path, scripts_metadata_path));

		// Turn export features into defines
		Vector<String> godot_defines;
		for (Set<String>::Element *E = p_features.front(); E; E = E->next()) {
			godot_defines.push_back(E->get());
		}
		ERR_FAIL_COND(!GodotSharpBuilds::build_project_blocking(build_config, godot_defines));

		// Add dependency assemblies

		Map<String, String> dependencies;

		String project_dll_name = ProjectSettings::get_singleton()->get("application/config/name");
		if (project_dll_name.empty()) {
			project_dll_name = "UnnamedProject";
		}

		String project_dll_src_dir = GodotSharpDirs::get_res_temp_assemblies_base_dir().plus_file(build_config);
		String project_dll_src_path = project_dll_src_dir.plus_file(project_dll_name + ".dll");
		dependencies.insert(project_dll_name, project_dll_src_path);

		{
			MonoDomain *export_domain = GDMonoUtils::create_domain("GodotEngine.ProjectExportDomain");
			ERR_FAIL_NULL(export_domain);
			_GDMONO_SCOPE_EXIT_DOMAIN_UNLOAD_(export_domain);

			_GDMONO_SCOPE_DOMAIN_(export_domain);

			GDMonoAssembly *scripts_assembly = NULL;
			bool load_success = GDMono::get_singleton()->load_assembly_from(project_dll_name,
					project_dll_src_path, &scripts_assembly, /* refonly: */ true);

			ERR_EXPLAIN("Cannot load refonly assembly: " + project_dll_name);
			ERR_FAIL_COND(!load_success);

			Vector<String> search_dirs;
			GDMonoAssembly::fill_search_dirs(search_dirs, build_config);
			Error depend_error = _get_assembly_dependencies(scripts_assembly, search_dirs, dependencies);
			ERR_FAIL_COND(depend_error != OK);
		}

		for (Map<String, String>::Element *E = dependencies.front(); E; E = E->next()) {
			String depend_src_path = E->value();
			String depend_dst_path = GodotSharpDirs::get_res_assemblies_dir().plus_file(depend_src_path.get_file());
			ERR_FAIL_COND(!_add_file(depend_src_path, depend_dst_path));
		}
	}

	// Mono specific export template extras (data dir)

	GDMonoClass *export_class = GDMono::get_singleton()->get_editor_tools_assembly()->get_class("GodotSharpTools.Editor", "GodotSharpExport");
	ERR_FAIL_NULL(export_class);
	GDMonoMethod *export_begin_method = export_class->get_method("_ExportBegin", 4);
	ERR_FAIL_NULL(export_begin_method);

	MonoArray *features = mono_array_new(mono_domain_get(), CACHED_CLASS_RAW(String), p_features.size());
	int i = 0;
	for (const Set<String>::Element *E = p_features.front(); E; E = E->next()) {
		MonoString *boxed = GDMonoMarshal::mono_string_from_godot(E->get());
		mono_array_set(features, MonoString *, i, boxed);
		i++;
	}

	MonoBoolean debug = p_debug;
	MonoString *path = GDMonoMarshal::mono_string_from_godot(p_path);
	uint32_t flags = p_flags;
	void *args[4] = { features, &debug, path, &flags };
	MonoException *exc = NULL;
	export_begin_method->invoke_raw(NULL, args, &exc);

	if (exc) {
		GDMonoUtils::debug_print_unhandled_exception(exc);
		ERR_FAIL();
	}
}
Exemplo n.º 25
0
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;
}
Exemplo n.º 26
0
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;
}