public static void Load(Script script)
 {
     ScriptTable Table = script.CreateTable();
     Table.SetValue("encode", script.CreateFunction(new encode()));
     Table.SetValue("decode", script.CreateFunction(new decode(script)));
     script.SetObjectInternal("json", Table);
 }
Exemple #2
0
 //解析文件结构
 private void ParseLayout()
 {
     mFields.Clear();
     mUsedCustoms.Clear();
     for (int i = 0; i < mMaxColumn; ++i)
     {
         PackageField field = new PackageField();
         field.Index   = i;
         field.Comment = mDataTable[0][i];            //第0行是注释
         field.Name    = mDataTable[1][i];            //第1行是字段名
         field.Default = mDataTable[3][i];            //第3行是字段默认值
         var            attribute = mDataTable[2][i]; //第2行是字段属性
         Scorpio.Script script    = new Scorpio.Script();
         script.LoadLibrary();
         if (string.IsNullOrEmpty(attribute))
         {
             field.Attribute = script.CreateTable();
         }
         else
         {
             field.Attribute = (script.LoadString("return {" + attribute + "}") as ScriptTable) ?? script.CreateTable();
         }
         string columnType = mDataTable[4][i];   //第4行是字段类型
         string fieldType  = "";
         if (columnType.StartsWith(Util.ArrayString))
         {
             field.Array = true;
             int iFinalIndex = Util.ArrayString.Length;
             fieldType = columnType.Substring(iFinalIndex, columnType.Length - iFinalIndex);
         }
         else
         {
             field.Array = false;
             fieldType   = columnType;
         }
         field.Type = fieldType;
         bool basic = BasicUtil.HasType(fieldType);
         if (!basic && !mCustoms.ContainsKey(fieldType) && !mEnums.ContainsKey(fieldType))
         {
             throw new System.Exception(string.Format("第[{0}]列的 字段类型[{1}] 不能识别", Util.GetLineName(i), columnType));
         }
         if (i == 0 && (field.Array == true || field.Info.BasicIndex != BasicEnum.INT32))
         {
             throw new System.Exception("第一列的数据类型必须为int32类型");
         }
         field.Enum = mEnums.ContainsKey(fieldType);
         //保存使用的自定义结构
         if (!basic && !field.Enum && !mUsedCustoms.Contains(fieldType))
         {
             mUsedCustoms.Add(fieldType);
         }
         mFields.Add(field);
     }
     if (mFields.Count == 0)
     {
         throw new System.Exception("字段个数为0");
     }
     mKeyName = mFields[0].Name;
 }
 public static void Load(Script script) {
     ScriptTable Table = script.CreateTable();
     Table.SetValue("count", script.CreateFunction(new count(script)));
     Table.SetValue("isparams", script.CreateFunction(new isparams(script)));
     Table.SetValue("isstatic", script.CreateFunction(new isstatic(script)));
     Table.SetValue("getparams", script.CreateFunction(new getparams(script)));
     script.SetObjectInternal("func", Table);
 }
        public static void Load(Script script) {
            ScriptTable Table = script.CreateTable();
			Table.SetValue("PI", script.CreateDouble(PI));
			Table.SetValue("Deg2Rad", script.CreateDouble(Deg2Rad));
			Table.SetValue("Rad2Deg", script.CreateDouble(Rad2Deg));
			Table.SetValue("Epsilon", script.CreateDouble(Epsilon));
			Table.SetValue("min", script.CreateFunction(new min()));
			Table.SetValue("max", script.CreateFunction(new max()));
			Table.SetValue("abs", script.CreateFunction(new abs()));
			Table.SetValue("floor", script.CreateFunction(new floor()));
			Table.SetValue("clamp", script.CreateFunction(new clamp()));
			Table.SetValue("sqrt", script.CreateFunction(new sqrt()));
			Table.SetValue("pow", script.CreateFunction(new pow()));
            script.SetObjectInternal("math", Table);
        }
 public getparams(Script script) {
     m_Script = script;
 }
 public isstatic(Script script) {
     m_Script = script;
 }
 public isparams(Script script) {
     m_Script = script;
 }
 public count(Script script) {
     m_Script = script;
 }
 public CodeObject[] Allow;             //判断条件
 public TempCase(Script script, List<CodeObject> allow, ScriptExecutable executable) {
     this.Allow = allow != null ? allow.ToArray() : new CodeObject[0];
     this.Executable = executable;
 }
 public ScriptString(Script script, string value) : base(script) {
     this.m_Value = value;
 }
 internal ScriptArray(Script script, ScriptValue[] parameters, int length) : this(script) {
     for (var i = 0; i < length; ++i)
     {
         Add(parameters[i]);
     }
 }
 public ScriptArray(Script script) : base(ObjectType.Array, script.TypeArrayValue)
 {
     m_Script  = script;
     m_Objects = ScriptValue.EMPTY;
     m_Length  = 0;
 }
Exemple #13
0
 public ScriptString(Script script, string value) : base(script)
 {
     this.m_Value = value;
 }
 public decode(Script script)
 {
     m_Script = script;
 }