Esempio n. 1
0
		/// <summary>
		/// Used by full reflection.
		/// </summary>
		public PhpField(VariableName name, DPropertyDesc/*!*/ fieldDesc, FieldInfo/*!*/ fieldInfo,
			PropertyInfo exportedProperty)
			: base(fieldDesc, name)
		{
			Debug.Assert(fieldDesc is DPhpFieldDesc);

			this.realField = fieldInfo;
			this.exportedProperty = exportedProperty;
			this.hasInitialValue = realField.IsDefined(typeof(PhpHasInitValueAttribute), false);
			this.builder = null;

			this.implementor = DeclaringPhpType;
		}
Esempio n. 2
0
		/// <summary>
		/// Used by full reflection for fields that are not implemented by their declaring type.
		/// <seealso cref="PhpPublicFieldAttribute"/>
		/// </summary>
		public PhpField(VariableName name, DPropertyDesc/*!*/ fieldDesc, DPropertyDesc/*!*/ implementingFieldDesc,
			bool hasInitialValue, PropertyInfo exportedProperty)
			: base(fieldDesc, name)
		{
			Debug.Assert(fieldDesc is DPhpFieldDesc);

			this.realField = implementingFieldDesc.PhpField.RealField;
			this.exportedProperty = exportedProperty;
			this.hasInitialValue = hasInitialValue;
			this.builder = null;

			this.implementor = implementingFieldDesc.DeclaringType.PhpType;
			this.upgradesVisibility = (IsPublic && implementingFieldDesc.IsProtected);
		}
Esempio n. 3
0
		/// <summary>
		/// Used by subclasses when creating known routines.
		/// </summary>
		public DProperty(DPropertyDesc/*!*/ propertyDesc)
			: base(propertyDesc)
		{
		}
Esempio n. 4
0
		/// <summary>
		/// Used by subclasses.
		/// </summary>
		protected KnownProperty(DPropertyDesc/*!*/ propertyDesc, VariableName name)
			: base(propertyDesc)
		{
			this.name = name;

			// TODO
		}
Esempio n. 5
0
		/// <summary>
		/// Used by full-reflect.
		/// </summary>
		public ClrPropertyBase(DPropertyDesc/*!*/ propertyDesc, VariableName name)
			: base(propertyDesc, name)
		{
		}
Esempio n. 6
0
        /// <summary>
        /// Used by full reflection.
        /// </summary>
        public PhpVisibleProperty(VariableName name, DPropertyDesc/*!*/ fieldDesc, PropertyInfo/*!*/ propertyInfo)
            : base(fieldDesc, name)
        {
            Debug.Assert(fieldDesc is DPhpFieldDesc);
            Debug.Assert(propertyInfo != null);

            this.realProperty = propertyInfo;
        }
Esempio n. 7
0
		/// <summary>
		/// Formats a property name for serialization according to its visibility and declaing type.
		/// </summary>
		/// <param name="property">The property desc.</param>
		/// <param name="propertyName">The property name.</param>
		/// <returns>The property name formatted according to the <paramref name="property"/> as used by PHP serialization.
		/// </returns>
		public static string/*!*/ FormatPropertyName(DPropertyDesc/*!*/ property, string/*!*/ propertyName)
		{
			switch (property.MemberAttributes & PhpMemberAttributes.VisibilityMask)
			{
				case PhpMemberAttributes.Public: return propertyName;
				case PhpMemberAttributes.Protected: return "\0*\0" + propertyName;
				case PhpMemberAttributes.Private: return "\0" + property.DeclaringType.MakeFullName() + "\0" + propertyName;

				default: Debug.Fail(); return null;
			}
		}
Esempio n. 8
0
        public virtual object __construct(ScriptContext context, object @class, object propertyname)
        {
            string propertynameStr = PhpVariable.AsString(propertyname);

            if (@class == null || string.IsNullOrEmpty(propertynameStr))
                return false;

            this.dtype = null;
            this.property = null;

            DObject dobj;
            string str;

            if ((dobj = (@class as DObject)) != null)
            {
                this.dtype = dobj.TypeDesc;
            }
            else if ((str = PhpVariable.AsString(@class)) != null)
            {
                this.dtype = context.ResolveType(str, null, null, null, ResolveTypeFlags.UseAutoload);
            }

            if (this.dtype == null)
                return false;

            if (this.dtype.GetProperty(new VariableName(propertynameStr), dtype, out this.property) == GetMemberResult.NotFound)
            {
                object runtimeValue;
                if (dobj != null && dobj.RuntimeFields != null && dobj.RuntimeFields.TryGetValue(propertynameStr, out runtimeValue))
                {
                    // create desc of runtime field:
                    this.property = new RuntimePhpProperty(dtype,
                        (instance) => ((DObject)instance).GetRuntimeField(this.name, null),
                        (instance, value) => ((DObject)instance).SetRuntimeField(this.name, value, null, null, null));
                    this.property.Member = new KnownRuntimeProperty(this.property, propertynameStr);
                }
                else
                {
                    return false;
                }
            }

            return null;
        }
Esempio n. 9
0
            public KnownRuntimeProperty(DPropertyDesc desc, string name)
                :base(desc, new VariableName(name))
            {

            }