public static IFnInfo LarvalIFnInfo(object key, IFn fn, object[] fastKeys) { var inf = new IFnInfo(key, fn, null); inf.fastKeys = fastKeys; return(inf); }
public void CompleteBuild() { isBuilding = false; ifnInfos_ = new IFnInfo[buildingIfnInfos.Count]; int i = 0; foreach (var e in buildingIfnInfos) { ifnInfos_[i] = new IFnInfo(e.Key, e.Value); i++; } // or could clear it buildingIfnInfos = null; //InvalidateIndexes(); }
public void AddFunction(Keyword key, IFn f) { if (!(f is Var)) { // TODO this can be optimized var configMap = (IPersistentMap)GetConfigVar.invoke(); var policy = configMap.valAt(NonSerializableHooksKeyword) as Keyword; if (policy == null || policy == WarningKeyword) { Debug.LogWarningFormat("Non-serializable hook {2} attached to object {0} at key {1}.\n" + "This GameObject will throw an exception if cloned, saved into " + "a scene or prefab, or viewed in the inspector.\n" + "This warning can be disabled or turned into an error in your configuration.edn " + "file.", gameObject, key, f); } else if (policy == ErrorKeyword) { throw new InvalidOperationException(string.Format("Non-serializable hook {2} attached to object {0} at key {1}", gameObject, key, f)); } else if (policy != AllowKeyword) { // TODO what is a better place for this validation? throw new InvalidOperationException(string.Format("Unrecognized value {0} for configuration key {1}", policy, NonSerializableHooksKeyword)); } } FullInit(); if (isBuilding) { buildingIfnInfos.Add(key, f); } else { // just treat it like an associative array for now for (int i = 0; i < ifnInfos.Length; i++) { if (ifnInfos[i].key == key) { ifnInfos[i] = new IFnInfo(key, f); //InvalidateIndexes(); return; } } ifnInfos = Arcadia.Util.ArrayAppend(ifnInfos, new IFnInfo(key, f)); //InvalidateIndexes(); } }
public void RealizeVars() { if (varsRealized) { return; } // keyNames won't be there yet for fresh object // TODO: might want to clear them out after realizing vars PlayModeInitialization.Initialize1(); if (keyNames != null) { ifnInfos = new IFnInfo[keyNames.Length]; // create vars for (int i = 0; i < keyNames.Length; i++) { var kn = keyNames[i]; var vn = varNames[i]; Keyword k = Keyword.intern(kn); Symbol vsym = Symbol.intern(vn); Var v = RT.var(vsym.Namespace, vsym.Name); ifnInfos[i] = new IFnInfo(k, v); } varsRealized = true; // require namespaces for vars in a second pass for (int i = 0; i < ifnInfos.Length; i++) { Var v = (Var)ifnInfos[i].fn; Arcadia.Util.require(v.Namespace.getName()); } return; } varsRealized = true; }
public void RemoveAllFunctions() { ifnInfos = new IFnInfo[0]; }