/* * plmono_trigdata_get_columns * * Get Columns property value of TriggerData class */ MonoObject* plmono_trigdata_get_columns(MonoClass *trigdata) { MonoVTable *vt; MonoProperty *prop; vt = mono_class_vtable(plmono_get_domain(), trigdata); mono_runtime_class_init(vt); prop = mono_class_get_property_from_name(trigdata, "Columns"); return mono_property_get_value(prop, NULL, NULL, NULL); }
MonoObject* ml_get_info_prop(MonoObject *obj) { MonoClass *klass; MonoProperty *prop; klass = mono_class_get_parent(mono_object_get_class(obj)); prop = mono_class_get_property_from_name(klass, "Info"); return mono_property_get_value(prop, obj, NULL, NULL); }
gchar* ml_get_prop_string(MonoObject *obj, char *field) { MonoClass *klass; MonoProperty *prop; MonoString *str; klass = mono_object_get_class(obj); prop = mono_class_get_property_from_name(klass, field); str = (MonoString*)mono_property_get_value(prop, obj, NULL, NULL); return mono_string_to_utf8(str); }
MonoObject *GDMonoProperty::get_value(MonoObject *p_object, MonoObject **r_exc) { MonoObject *exc = NULL; MonoObject *ret = mono_property_get_value(mono_property, p_object, NULL, &exc); if (exc) { ret = NULL; if (r_exc) { *r_exc = exc; } else { GDMonoUtils::print_unhandled_exception(exc); } } return ret; }
String get_exception_name_and_message(MonoObject *p_ex) { String res; MonoClass *klass = mono_object_get_class(p_ex); MonoType *type = mono_class_get_type(klass); char *full_name = mono_type_full_name(type); res += full_name; mono_free(full_name); res += ": "; MonoProperty *prop = mono_class_get_property_from_name(klass, "Message"); MonoString *msg = (MonoString *)mono_property_get_value(prop, p_ex, NULL, NULL); res += GDMonoMarshal::mono_string_to_godot(msg); return res; }
mono::object CScriptClass::GetPropertyValue(mono::object object, const char *propertyName, bool throwOnFail) { MonoProperty *pProperty = GetMonoProperty(propertyName, false, true); if(pProperty) { MonoObject *pException = nullptr; MonoObject *propertyValue = mono_property_get_value(pProperty, object, nullptr, &pException); if(pException) HandleException(pException); else if(propertyValue) return (mono::object)propertyValue; } else if(throwOnFail) GetMonoScriptSystem()->GetCorlibAssembly()->GetException("System", "MissingMemberException", "Failed to locate property %s in class %s", propertyName, GetName())->Throw(); return nullptr; }
/* * plmono_trigger_build_result * * Build trigger's "NEW" row tuple based on TableRow object content */ Datum plmono_trigger_build_result(TriggerData *trigdata, MonoObject *cols) { MonoClass *rowklass; MonoProperty *item; TupleDesc resdesc; gpointer key, val; char *attname; Oid atttype; Datum *atts; bool *nulls; int i; resdesc = trigdata->tg_relation->rd_att; if (!(atts = palloc(resdesc->natts * sizeof(Datum)))) elog(ERROR, "Not enough memory"); if (!(nulls = palloc(resdesc->natts * sizeof(bool)))) elog(ERROR, "Not enough memory"); rowklass = mono_object_get_class(cols); item = mono_class_get_property_from_name(rowklass, "Item"); for (i = 0; i < resdesc->natts; i++) { attname = NameStr(resdesc->attrs[i]->attname); atttype = resdesc->attrs[i]->atttypid; key = mono_string_new(plmono_get_domain(), attname); /* attribute name */ val = mono_property_get_value(item, cols, &key, NULL); if (atttype != TEXTOID) val = mono_object_unbox(val); atts[i] = plmono_obj_to_datum(val, atttype); nulls[i] = 0; } return PointerGetDatum(heap_form_tuple(resdesc, atts, nulls)); }
static inline void print_report (const gchar *format, ...) { MonoClass *klass; MonoProperty *prop; MonoString *str; char *stack_trace; va_list ap; fprintf (stdout, "-=-=-=-=-=-=- MONO_IOMAP REPORT -=-=-=-=-=-=-\n"); va_start (ap, format); vfprintf (stdout, format, ap); fprintf (stdout, "\n"); va_end (ap); klass = mono_class_from_name (mono_get_corlib (), "System", "Environment"); mono_class_init (klass); prop = mono_class_get_property_from_name (klass, "StackTrace"); str = (MonoString*)mono_property_get_value (prop, NULL, NULL, NULL); stack_trace = mono_string_to_utf8 (str); fprintf (stdout, "-= Stack Trace =-\n%s\n\n", stack_trace); g_free (stack_trace); fflush (stdout); }
MonoObject *property_get_value(MonoProperty *p_prop, void *p_obj, void **p_params, MonoException **p_exc) { GD_MONO_BEGIN_RUNTIME_INVOKE; MonoObject *ret = mono_property_get_value(p_prop, p_obj, p_params, (MonoObject **)p_exc); GD_MONO_END_RUNTIME_INVOKE; return ret; }