Example #1
0
 public void InsertField(int index, UTinyField field)
 {
     Assert.IsFalse(s_FieldsProperty.Contains(this, field));
     Assert.IsTrue(field.DeclaringType == null);
     field.DeclaringType = this;
     s_FieldsProperty.Insert(this, index, field);
 }
Example #2
0
 /// <summary>
 /// Removes the given field from this type
 /// </summary>
 /// <param name="field">The field to remove</param>
 public void RemoveField(UTinyField field)
 {
     Assert.IsTrue(s_FieldsProperty.Contains(this, field));
     Assert.IsTrue(field.DeclaringType == this);
     field.DeclaringType = null;
     s_FieldsProperty.Remove(this, field);
 }
Example #3
0
 public void AddField(UTinyField field)
 {
     Assert.IsFalse(s_FieldsProperty.Contains(this, field));
     Assert.IsTrue(field.DeclaringType == null);
     field.DeclaringType = this;
     s_FieldsProperty.Add(this, field);
 }
Example #4
0
        public static object UpdateField(UTinyField field, object value)
        {
            if (!s_FieldUpdaters.ContainsKey(field.Id))
            {
                return(value);
            }

            return(s_FieldUpdaters[field.Id].UpdateValue(value));
        }
Example #5
0
        public object UpdateField(UTinyField field, object value)
        {
            field.FieldType = (UTinyType.Reference)UTinyType.UInt32;
            field.Refresh(field.DeclaringType.Registry);
            var str = (string)value;

            if (string.IsNullOrEmpty(str))
            {
                return(0);
            }

            return(Convert.ToUInt32(str[0]));
        }
            private static string FieldTypeToIDL(IRegistry registry, UTinyField field)
            {
                // @TODO Use UTinyBuildUtility.GetCSharpTypeName
                var code = field.FieldType.Dereference(registry).TypeCode;

                switch (code)
                {
                case UTinyTypeCode.Boolean: return("bool");

                case UTinyTypeCode.Int8: return("sbyte");

                case UTinyTypeCode.Int16: return("short");

                case UTinyTypeCode.Int32: return("int");

                case UTinyTypeCode.Int64: return("long");

                case UTinyTypeCode.UInt8: return("byte");

                case UTinyTypeCode.UInt16: return("ushort");

                case UTinyTypeCode.UInt32: return("uint");

                case UTinyTypeCode.UInt64: return("ulong");

                case UTinyTypeCode.Float32: return("float");

                case UTinyTypeCode.Float64: return("double");

                case UTinyTypeCode.Char: return("char");

                case UTinyTypeCode.String: return("string");

                case UTinyTypeCode.EntityReference: return("Entity");

                case UTinyTypeCode.UnityObject: return("Entity");

                case UTinyTypeCode.Struct:
                case UTinyTypeCode.Enum:
                    var name   = field.FieldType.Name;
                    var module = GetEnumModule(registry, field.FieldType);
                    if (!string.IsNullOrEmpty(module?.Namespace) && !module.Namespace.Equals("ut"))
                    {
                        name = $"{module.Namespace}.{name}";
                    }
                    return(name);

                default:
                    throw new NotSupportedException($"UTinyTypeCode '{code.ToString()}' is not supported in IDL at the moment");
                }
            }
Example #7
0
        private UTinyField NewField(UTinyId id, string name, Reference type, bool array = false)
        {
            Assert.IsTrue(m_TypeCode == UTinyTypeCode.Component ||
                          m_TypeCode == UTinyTypeCode.Struct ||
                          m_TypeCode == UTinyTypeCode.Enum ||
                          m_TypeCode == UTinyTypeCode.Configuration);

            var field = new UTinyField(this)
            {
                Id            = id,
                Name          = name,
                FieldType     = type,
                Array         = array,
                DeclaringType = this
            };

            return(field);
        }