Exemplo n.º 1
0
        public void MemberValueSet(CLS_Content content, object object_this, string valuename, object value)
        {
            SInstance sin = object_this as SInstance;

            if (sin.member.ContainsKey(valuename))
            {
                if (value != null && value.GetType() != (Type)this.members[valuename].type.type)
                {
                    if (value is SInstance)
                    {
                        if ((value as SInstance).type != (SType)this.members[valuename].type.type)
                        {
                            value = content.environment.GetType((value as SInstance).type).ConvertTo(content, value, this.members[valuename].type.type);
                        }
                    }
                    else if (value is DeleEvent)
                    {
                    }
                    else
                    {
                        value = content.environment.GetType(value.GetType()).ConvertTo(content, value, this.members[valuename].type.type);
                    }
                }
                sin.member[valuename].value = value;
                return;
            }
            throw new NotImplementedException();
        }
Exemplo n.º 2
0
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            var parent = listParam[0].ComputeValue(content);

            if (parent == null)
            {
                throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString());
            }
            ICLS_TypeFunction typefunction = content.environment.GetType(parent.type).function;

            if (parent.type is object)
            {
                SInstance s = parent.value as SInstance;
                if (s != null)
                {
                    typefunction = s.type;
                }
            }
            //var type = content.environment.GetType(parent.type);
            var value = typefunction.MemberValueGet(content, parent.value, membername);

            content.OutStack(this);
            return(value);
            //做数学计算
            //从上下文取值
            //_value = null;
            //return null;
        }
Exemplo n.º 3
0
        public CLS_Content.Value MemberValueGet(CLS_Content content, object object_this, string valuename, bool isBaseCall = false)
        {
            SInstance sin = object_this as SInstance;

            CLS_Content.Value mV;
            if (sin.member.TryGetValue(valuename, out mV))
            {
                return(mV);
            }

            // 判断是否有同名的Get属性
            Member property;

            if (sin.type.propertys.TryGetValue(valuename, out property))
            {
                if (property.getFun != null)
                {
                    return(this.MemberCall(content, sin, property.getFun, null, isBaseCall));
                }
                throw new NotImplementedException("属性无get权限: " + this.Name + "." + valuename);
            }

            // 判断是否有同名的委托函数
            if (sin.type.functions.ContainsKey(valuename))
            {
                CLS_Content.Value v = new CLS_Content.Value();
                v.type  = typeof(DeleFunction);
                v.value = new DeleFunction(this, sin, valuename);
                return(v);
            }

            throw new NotImplementedException("未实现成员字段: " + this.Name + "." + valuename);
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            var parent = listParam[0].ComputeValue(content);

            if (parent == null)
            {
                throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString());
            }
            var    value = listParam[1].ComputeValue(content);
            object setv  = value.value;
            //if(value.type!=parent.type)
            //{
            //    var vtype = content.environment.GetType(value.type);
            //    setv = vtype.ConvertTo(content.environment, setv, parent.type);
            //}
            var typefunction = content.environment.GetType(parent.type).function;

            if (parent.type is object)
            {
                SInstance s = parent.value as SInstance;
                if (s != null)
                {
                    typefunction = s.type;
                }
            }
            typefunction.MemberValueSet(content, parent.value, membername, setv);
            //做数学计算
            //从上下文取值
            //_value = null;
            content.OutStack(this);
            return(null);
        }
Exemplo n.º 5
0
        public void MemberValueSet(CLS_Content content, object object_this, string valuename, object value, bool isBaseCall = false)
        {
            SInstance sin = object_this as SInstance;

            CLS_Content.Value mV;
            if (sin.member.TryGetValue(valuename, out mV))
            {
                mV.value = value;
                mV.FixValueType(content);
                return;
            }

            // 判断是否有同名的Set属性
            Member property;

            if (sin.type.propertys.TryGetValue(valuename, out property))
            {
                if (property.setFun != null)
                {
                    BetterList <CLS_Content.Value> _params = CLS_Content.NewParamList();
                    CLS_Content.Value hideValue            = new CLS_Content.Value()
                    {
                        type = property.type.type, value = value
                    };
                    hideValue.FixValueType(content);
                    _params.Add(hideValue);
                    this.MemberCall(content, object_this, property.setFun, _params, isBaseCall);
                    CLS_Content.PoolParamList(_params);
                    return;
                }
                throw new NotImplementedException("属性无set权限: " + this.Name + "." + valuename);
            }

            throw new NotImplementedException("未实现成员赋值字段: " + this.Name + "." + valuename);
        }
Exemplo n.º 6
0
        public CLS_Content.Value MemberValueGet(CLS_Content environment, object object_this, string valuename)
        {
            SInstance sin = object_this as SInstance;

            if (sin.member.ContainsKey(valuename))
            {
                CLS_Content.Value v = new CLS_Content.Value();
                v.type  = sin.member[valuename].type;
                v.value = sin.member[valuename].value;
                return(v);
            }
            throw new NotImplementedException();
        }
Exemplo n.º 7
0
 CSLE.CLS_Content content; //操作上下文
 public ScriptInstanceState(string scriptTypeName)
 {
     type = ScriptMgr.Instance.env.GetTypeByKeywordQuiet(scriptTypeName);
     if (type == null)
     {
         Debug.LogError("Type:" + scriptTypeName + "不存在于脚本项目中");
         return;
     }
     content          = ScriptMgr.Instance.env.CreateContent();
     inst             = type.function.New(content, null).value as CSLE.SInstance;
     content.CallType = inst.type;
     content.CallThis = inst;
     Debug.Log("inst=" + inst);
 }
 CSLE.CLS_Content content;//操作上下文
 public ScriptInstanceHelper(string scriptTypeName)
 {
     type = ScriptMgr.Instance.env.GetTypeByKeywordQuiet(scriptTypeName);
     if(type==null)
     {
         Debug.LogError("Type:" + scriptTypeName + "不存在于脚本项目中");
         return;
     }
     content =ScriptMgr.Instance.env.CreateContent();
     inst = type.function.New(content, null).value as CSLE.SInstance;
     content.CallType = inst.type;
     content.CallThis = inst;
     Debug.Log("inst=" + inst);
 }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            var parent = listParam[0].ComputeValue(content);

            if (parent == null)
            {
                throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString());
            }
            var typefunction = content.environment.GetType(parent.type).function;

            if (parent.type is object)
            {
                SInstance s = parent.value as SInstance;
                if (s != null)
                {
                    typefunction = s.type;
                }
            }
            List <CLS_Content.Value> _params = new List <CLS_Content.Value>();

            for (int i = 1; i < listParam.Count; i++)
            {
                _params.Add(listParam[i].ComputeValue(content));
            }
            CLS_Content.Value value = null;
            if (cache == null || cache.cachefail)
            {
                cache = new MethodCache();
                value = typefunction.MemberCall(content, parent.value, functionName, _params, cache);
            }
            else
            {
                value = typefunction.MemberCallCache(content, parent.value, _params, cache);
            }
            content.OutStack(this);
            return(value);
            //做数学计算
            //从上下文取值
            //_value = null;
            //return null;
        }
Exemplo n.º 10
0
        public bool TryMemberValueSet(CLS_Content content, SInstance sin, string valuename, object value)
        {
            CLS_Content.Value mV;
            if (sin.member.TryGetValue(valuename, out mV))
            {
                mV.value = value;
                mV.FixValueType(content);
                return(true);
            }

            // 判断是否有同名的Set属性
            Member property;

            if (sin.type.propertys.TryGetValue(valuename, out property))
            {
                if (property.setFun != null)
                {
                    BetterList <CLS_Content.Value> _params = CLS_Content.NewParamList();
                    CLS_Content.Value hideValue            = new CLS_Content.Value()
                    {
                        type = property.type.type, value = value
                    };
                    hideValue.FixValueType(content);
                    _params.Add(hideValue);
                    if (property.bStatic)
                    {
                        this.StaticCall(content, property.setFun, _params);
                    }
                    else
                    {
                        this.MemberCall(content, sin, property.setFun, _params);
                    }
                    CLS_Content.PoolParamList(_params);
                    return(true);
                }
                throw new NotImplementedException("属性无set权限: " + this.Name + "." + valuename);
            }

            return(false);
        }
Exemplo n.º 11
0
        public bool TryMemberValueGet(CLS_Content content, SInstance sin, string valuename, out CLS_Content.Value outVal)
        {
            if (sin.member.TryGetValue(valuename, out outVal))
            {
                return(true);
            }

            // 判断是否有同名的Get属性
            Member property;

            if (sin.type.propertys.TryGetValue(valuename, out property))
            {
                if (property.getFun != null)
                {
                    if (property.bStatic)
                    {
                        outVal = this.StaticCall(content, property.getFun, null);
                    }
                    else
                    {
                        outVal = this.MemberCall(content, sin, property.getFun, null);
                    }
                    return(true);
                }
                throw new NotImplementedException("属性无get权限: " + this.Name + "." + valuename);
            }

            // 判断是否有同名的委托函数
            if (sin.type.functions.ContainsKey(valuename))
            {
                outVal       = new CLS_Content.Value();
                outVal.type  = typeof(DeleFunction);
                outVal.value = new DeleFunction(this, sin, valuename);
                return(true);
            }

            outVal = null;
            return(false);
        }
Exemplo n.º 12
0
        public CLS_Content.Value New(CLS_Content content, BetterList<CLS_Content.Value> _params)
        {
            if (staticMemberContent == null)
                NewStatic(content.environment);

            SInstance scriptInstance = new SInstance();
            scriptInstance.type = this;

            foreach (var pair in this.members)
            {
                Member member = pair.Value;
                if (!member.bStatic)
                {
                    CLS_Content.Value val = new CLS_Content.Value();
                    val.type = member.type.type;
                    if (member.expr_defvalue == null)
                    {
                        val.value = member.type.DefValue;
                    }
                    else
                    {
                        CLS_Content.Value value = member.expr_defvalue.ComputeValue(staticMemberContent);
                        if (member.type.type != value.type)
                        {
                            val.value = content.environment.GetType(value.type).ConvertTo(content, value.value, member.type.type);
                        }
                        else
                        {
                            val.value = value.value;
                        }
                    }
                    scriptInstance.member[pair.Key] = val;
                }
            }

            CLS_Content.Value thisVal = new CLS_Content.Value() { type = this, value = scriptInstance };

            // 加入this关键字
            scriptInstance.member["this"] = thisVal;

            // 加入base关键字
            if (BaseType != null)
                scriptInstance.member["base"] = new CLS_Content.Value() { type = BaseType, value = scriptInstance, breakBlock = 255 };

            // 调用构造函数
            if (this.functions.ContainsKey(this.Name))
                MemberCall(content, scriptInstance, this.Name, _params);

            return thisVal;
        }
Exemplo n.º 13
0
 public DeleFunction(SType stype, SInstance _this, string function)
 {
     this.calltype = stype;
     this.callthis = _this;
     this.function = function;
 }
Exemplo n.º 14
0
        public CLS_Content.Value MemberCall(CLS_Content contentParent, object object_this, string func, BetterList <CLS_Content.Value> _params, bool isBaseCall = false)
        {
            SInstance callThis = object_this as SInstance;

            // 成员函数判断
            Function fun;

            if (this.functions.TryGetValue(func, out fun))
            {
#if UNITY_EDITOR
                if (fun.bStatic)
                {
                    throw new Exception("不能通过实例来调用静态函数: " + this.Name + "." + func);
                }
#endif
                CLS_Content.Value value = null;

                SType callType = this;

                if (isBaseCall)
                {
                    SType          tempType = contentParent.CallType.BaseType;
                    SType.Function tempFun;
                    while (tempType != null)
                    {
                        if (tempType.functions.TryGetValue(func, out tempFun))
                        {
                            if (tempFun.ownerType == null || tempFun.ownerType == tempType)
                            {
                                callType = tempType;
                                fun      = tempFun;
                                break;
                            }
                        }
                        tempType = tempType.BaseType;
                    }
                }
                else
                {
                    if (callType != callThis.type)
                    {
                        SType    tempType = callThis.type;
                        Function tempFun;
                        while (tempType != null)
                        {
                            if (tempType.functions.TryGetValue(func, out tempFun))
                            {
                                if (tempFun.ownerType == null || tempFun.ownerType == tempType)
                                {
                                    callType = tempType;
                                    fun      = tempFun;
                                    break;
                                }
                            }
                            tempType = tempType.BaseType;
                        }
                    }
                    else if (fun.ownerType != null && fun.ownerType != callType)
                    {
                        callType = fun.ownerType;
                    }
                }

                if (fun.expr_runtime != null)
                {
                    CLS_Content content = CLS_Content.NewContent(contentParent.environment);
#if UNITY_EDITOR
                    contentParent.InStackContent(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的
#endif
                    content.CallType = callType;
                    content.CallThis = callThis;

                    for (int i = 0, count = fun._paramtypes.Count; i < count; i++)
                    {
                        content.DefineAndSet(fun._paramnames[i], fun._paramtypes[i].type, _params[i].value);
                    }

                    value = fun.expr_runtime.ComputeValue(content);
                    if (value != null)
                    {
                        value.breakBlock = 0;
                    }
#if UNITY_EDITOR
                    contentParent.OutStackContent(content);
#endif
                    CLS_Content.PoolContent(content);
                }

                return(value);
            }

            // 委托判断
            CLS_Content.Value mDeleVal;
            if (callThis.member.TryGetValue(func, out mDeleVal))
            {
                Delegate dele = mDeleVal.value as Delegate;
                if (dele != null)
                {
                    CLS_Content.Value value = new CLS_Content.Value();
                    value.type = null;
                    object[] objs = CLS_Content.ParamObjsArray[_params.size];
                    for (int i = 0; i < _params.size; i++)
                    {
                        objs[i] = _params[i].value;
                    }
                    value.value = dele.DynamicInvoke(objs);
                    if (value.value != null)
                    {
                        value.type = value.value.GetType();
                    }
                    value.breakBlock = 0;
                    return(value);
                }
            }
            throw new NotImplementedException("未实现成员函数: " + this.Name + "." + func);
        }
Exemplo n.º 15
0
    void GetSortMembers(SInstance sInstance, out List<CLS_Content.Value> values, out List<string> keywords)
    {
        if (sInstance.type.sortProtoFieldKeys == null)
        {
            List<string> tempKeys = new List<string>();
            foreach (var pair in sInstance.type.members)
            {
                if (pair.Value.sortIndex > 0)
                {
                    for (int i = tempKeys.Count; i < pair.Value.sortIndex; i++)
                    {
                        tempKeys.Add("");
                    }
                    tempKeys[pair.Value.sortIndex - 1] = pair.Key;
                }
            }

            sInstance.type.sortProtoFieldKeys = new List<string>();
            foreach (string key in tempKeys)
            {
                if (!string.IsNullOrEmpty(key))
                    sInstance.type.sortProtoFieldKeys.Add(key);
            }
        }

        keywords = sInstance.type.sortProtoFieldKeys;
        values = new List<CLS_Content.Value>();
        foreach (string key in keywords)
        {
            values.Add(sInstance.member[key]);
        }
    }
Exemplo n.º 16
0
    void WriteSInstance(ProtoWriter writer, SInstance sInstance)
    {
        List<CLS_Content.Value> values;
        List<string> keywords;
        GetSortMembers(sInstance, out values, out keywords);

        // 写入流
        for (int i = 0, count = values.Count; i < count; i++)
        {
            int fieldNumber = i + 1;
            Type memberT = values[i].type;
            object memberV = values[i].value;

            if (memberV == null)
                continue;

            if (memberT == null)
                memberT = typeof(SInstance);

            Type itemType = GetItemType(memberT);
            if (itemType != null)
            {
                // 数组判断
                if (memberT.IsArray)
                {
                    IList arr = (IList)memberV;
                    for (int j = 0, len = arr.Count; j < len; j++)
                    {
                        WriteField(writer, arr[j], itemType, fieldNumber);
                    }
                }
                // 列表判断
                else
                {
                    IEnumerable list = (IEnumerable)memberV;
                    foreach (object subItem in list)
                    {
                        WriteField(writer, subItem, itemType, fieldNumber);
                    }
                }
            }
            else
            {
                WriteField(writer, memberV, memberT, fieldNumber);
            }
        }
    }
Exemplo n.º 17
0
    void ReadSInstance(ProtoReader reader, SInstance sInstance, CLS_Environment environment)
    {
        List<CLS_Content.Value> values;
        List<string> keywords;
        GetSortMembers(sInstance, out values, out keywords);

        int fieldNumber = 0;
        while ((fieldNumber = reader.ReadFieldHeader()) > 0)
        {
            Type memberT = values[fieldNumber - 1].type;
            CLS_Content.Value memberV = values[fieldNumber - 1];
            string sClassName = keywords[fieldNumber - 1];

            if (memberT == null)
            {
                memberT = typeof(SInstance);
                sClassName = ((SType)memberV.type).Name;
            }

            Type itemType = GetItemType(memberT);
            if (itemType != null)
            {
                sClassName = sInstance.type.members[sClassName].type.keyword;

                // 数组判断
                if (memberT.IsArray)
                {
                    string itemClass = sClassName.Substring(0, sClassName.Length - 2);  // 从 xxx[] 中提取xxx
                    BasicList list = new BasicList();
                    do
                    {
                        list.Add(ReadField(reader, itemType, itemClass, environment));
                    } while (reader.TryReadFieldHeader(fieldNumber));
                    Array result = Array.CreateInstance(itemType, list.Count);
                    list.CopyTo(result, 0);
                    memberV.value = result;
                }
                // 列表判断
                else
                {
                    string itemClass = sClassName.Substring(5, sClassName.Length - 6);  // 从 List<xxx> 中提取xxx
                    ICLS_Type iType = environment.GetTypeByKeywordQuiet(sClassName);
                    CLS_Content content = CLS_Content.NewContent(environment);
                    memberV.value = iType.function.New(content, m_emptyParams).value;
                    CLS_Content.PoolContent(content);
                    IList list = (IList)memberV.value;
                    do
                    {
                        list.Add(ReadField(reader, itemType, itemClass, environment));
                    } while (reader.TryReadFieldHeader(fieldNumber));
                }
            }
            else
            {
                memberV.value = ReadField(reader, memberT, sClassName, environment);
            }
        }
    }
Exemplo n.º 18
0
    // 调用脚本实例成员函数
    public object Call(SInstance scriptInstance, string funName, params object[] _params)
    {
        if (scriptInstance == null)
            return null;

        #if UNITY_EDITOR
        try
        {

            if (!scriptInstance.type.functions.ContainsKey(funName))
            {
                Debug.LogWarning(string.Format("Call({0}.{1}): fun not found!", scriptInstance.type.Name, funName));
                return null;
            }
        #endif
            BetterList<CLS_Content.Value> paramList = ScriptParamConvert(_params);
            CLS_Content.Value retVal = scriptInstance.type.MemberCall(m_clsContent, scriptInstance, funName, paramList);
            CLS_Content.PoolParamList(paramList);
            return retVal != null ? retVal.value : null;
        #if UNITY_EDITOR
        }
        catch (System.Exception ex)
        {
            Debug.LogError(DumpStack(ex));
            return null;
        }
        #endif
    }
Exemplo n.º 19
0
    IEnumerator RunScriptEntryCoroutine(string clsEntryName, MonoBehaviour behaviour, params object[] startParams)
    {
        m_clsContent = m_clsEnv.CreateContent();
        m_clsCurEntry = (SInstance)this.NewInstance(clsEntryName);

        this.SetMember(m_clsCurEntry, "behaviour", behaviour);

        yield return behaviour.StartCoroutine((IEnumerator)this.Call(m_clsCurEntry, "Start", startParams));

        this.Call(m_clsCurEntry, "UpdatePrevious");
    }
Exemplo n.º 20
0
        public bool TryMemberValueSet(CLS_Content content, SInstance sin, string valuename, object value)
        {
            CLS_Content.Value mV;
            if (sin.member.TryGetValue(valuename, out mV))
            {
                mV.value = value;
                mV.FixValueType(content);
                return true;
            }

            // 判断是否有同名的Set属性
            Member property;
            if (sin.type.propertys.TryGetValue(valuename, out property))
            {
                if (property.setFun != null)
                {
                    BetterList<CLS_Content.Value> _params = CLS_Content.NewParamList();
                    CLS_Content.Value hideValue = new CLS_Content.Value() { type = property.type.type, value = value };
                    hideValue.FixValueType(content);
                    _params.Add(hideValue);
                    if (property.bStatic)
                        this.StaticCall(content, property.setFun, _params);
                    else
                        this.MemberCall(content, sin, property.setFun, _params);
                    CLS_Content.PoolParamList(_params);
                    return true;
                }
                throw new NotImplementedException("属性无set权限: " + this.Name + "." + valuename);
            }

            return false;
        }
Exemplo n.º 21
0
        public CLS_Content.Value New(CLS_Content content, BetterList <CLS_Content.Value> _params)
        {
            if (staticMemberContent == null)
            {
                NewStatic(content.environment);
            }

            SInstance scriptInstance = new SInstance();

            scriptInstance.type = this;

            foreach (var pair in this.members)
            {
                Member member = pair.Value;
                if (!member.bStatic)
                {
                    CLS_Content.Value val = new CLS_Content.Value();
                    val.type = member.type.type;
                    if (member.expr_defvalue == null)
                    {
                        val.value = member.type.DefValue;
                    }
                    else
                    {
                        CLS_Content.Value value = member.expr_defvalue.ComputeValue(staticMemberContent);
                        if (member.type.type != value.type)
                        {
                            val.value = content.environment.GetType(value.type).ConvertTo(content, value.value, member.type.type);
                        }
                        else
                        {
                            val.value = value.value;
                        }
                    }
                    scriptInstance.member[pair.Key] = val;
                }
            }

            CLS_Content.Value thisVal = new CLS_Content.Value()
            {
                type = this, value = scriptInstance
            };

            // 加入this关键字
            scriptInstance.member["this"] = thisVal;

            // 加入base关键字
            if (BaseType != null)
            {
                scriptInstance.member["base"] = new CLS_Content.Value()
                {
                    type = BaseType, value = scriptInstance, breakBlock = 255
                }
            }
            ;

            // 调用构造函数
            if (this.functions.ContainsKey(this.Name))
            {
                MemberCall(content, scriptInstance, this.Name, _params);
            }

            return(thisVal);
        }

        void NewStatic(ICLS_Environment env)
        {
            staticMemberContent = CLS_Content.NewContent(env);
            staticMemberValues  = new Dictionary <string, CLS_Content.Value>();

            // 先初始化基类静态数据
            if (BaseType != null)
            {
                BaseType.NewStatic(env);

                // 拷贝基类的静态数据
                foreach (var pair in BaseType.staticMemberValues)
                {
                    staticMemberValues.Add(pair.Key, pair.Value);
                }
            }

            // 添加自身的静态成员数据
            foreach (var pair in this.members)
            {
                if (pair.Value.bStatic && !staticMemberValues.ContainsKey(pair.Key))
                {
                    CLS_Content.Value val = new CLS_Content.Value();
                    val.type = pair.Value.type.type;
                    if (pair.Value.expr_defvalue == null)
                    {
                        val.value = pair.Value.type.DefValue;
                    }
                    else
                    {
                        CLS_Content.Value value = pair.Value.expr_defvalue.ComputeValue(staticMemberContent);
                        if (pair.Value.type.type != value.type)
                        {
                            val.value = env.GetType(value.type).ConvertTo(staticMemberContent, value.value, pair.Value.type.type);
                        }
                        else
                        {
                            val.value = value.value;
                        }
                    }
                    staticMemberValues[pair.Key] = val;
                }
            }
        }
Exemplo n.º 22
0
    // 赋值脚本实例成员
    public void SetMember(SInstance scriptInstance, string memName, object val)
    {
        if (scriptInstance == null)
            return;

        #if UNITY_EDITOR
        try
        {

            if (!scriptInstance.type.members.ContainsKey(memName))
            {
                Debug.LogWarning(string.Format("SetMember({0}.{1}): mem not found!", scriptInstance.type.Name, memName));
                return;
            }
        #endif
            scriptInstance.type.MemberValueSet(m_clsContent, scriptInstance, memName, val);
        #if UNITY_EDITOR
        }
        catch (System.Exception ex)
        {
            Debug.LogError(DumpStack(ex));
            return;
        }
        #endif
    }
Exemplo n.º 23
0
        public bool TryMemberValueGet(CLS_Content content, SInstance sin, string valuename, out CLS_Content.Value outVal)
        {
            if (sin.member.TryGetValue(valuename, out outVal))
                return true;

            // 判断是否有同名的Get属性
            Member property;
            if (sin.type.propertys.TryGetValue(valuename, out property))
            {
                if (property.getFun != null)
                {
                    if (property.bStatic)
                        outVal = this.StaticCall(content, property.getFun, null);
                    else
                        outVal = this.MemberCall(content, sin, property.getFun, null);
                    return true;
                }
                throw new NotImplementedException("属性无get权限: " + this.Name + "." + valuename);
            }

            // 判断是否有同名的委托函数
            if (sin.type.functions.ContainsKey(valuename))
            {
                outVal = new CLS_Content.Value();
                outVal.type = typeof(DeleFunction);
                outVal.value = new DeleFunction(this, sin, valuename);
                return true;
            }

            outVal = null;
            return false;
        }
Exemplo n.º 24
0
 public DeleFunction(SType stype, SInstance _this, string function)
 {
     this.calltype = stype;
     this.callthis = _this;
     this.function = function;
 }
Exemplo n.º 25
0
 //=====================================================
 void Clear()
 {
     if (m_clsCurEntry != null)
     {
         this.Call(m_clsCurEntry, "Clear");
         m_clsCurEntry = null;
     }
 }