static void StreamSystemPrototypeKey <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, BlamEngine engine, ref Values.KGuid systemGuid) where TDoc : class where TCursor : class { s.StreamAttribute("guid", ref systemGuid); if (s.IsReading) { string invalid_guid_msg = null; if (systemGuid == Values.KGuid.Empty) { invalid_guid_msg = "Invalid system guid: "; } else if (EngineRegistry.TryGetRegisteredSystem(systemGuid) == null) { invalid_guid_msg = "Unknown system guid: "; } if (invalid_guid_msg != null) { s.ThrowReadException(new System.IO.InvalidDataException( invalid_guid_msg + systemGuid.ToString(Values.KGuid.kFormatHyphenated, Util.InvariantCultureInfo))); } } }
public static void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, ref BlamEngineTargetHandle value) where TDoc : class where TCursor : class { bool reading = s.IsReading; var build = reading ? EngineBuildHandle.None : value.Build; var platform_index = reading ? TypeExtensions.kNone : value.TargetPlatformIndex; var rsrc_model_index = reading ? TypeExtensions.kNone : value.ResourceModelIndex; EngineBuildHandle.Serialize(s, ref build); if (!build.IsNone) { if (EngineTargetPlatform.SerializeId(s, "targetPlatform", ref platform_index, true)) { EngineRegistry.SerializeResourceModelId(s, "resourceModel", ref rsrc_model_index, true); } } if (reading) { value = new BlamEngineTargetHandle(build, platform_index, rsrc_model_index); } }
public BlamEngineTargetHandle(EngineBuildHandle buildHandle, int platformIndex, int resourceModelIndex) { Contract.Requires <ArgumentOutOfRangeException>(EngineTargetPlatform.IsValidIndex(platformIndex)); Contract.Requires <ArgumentOutOfRangeException>(EngineRegistry.IsValidResourceModelIndex(resourceModelIndex) || (platformIndex.IsNone() && resourceModelIndex.IsNone())); InitializeHandle(out mHandle, buildHandle, platformIndex, resourceModelIndex); }
void LoadExternsBegin() { using (var s = EngineRegistry.OpenEngineSystemTagElementStream( Engine, Prototype.SystemMetadata.Guid, Prototype.ExternsFile)) { s.Owner = Prototype; SerializeExtern(s); } }
void RegisterSystem() { if (Engine.EngineRegistry.Systems.ContainsKey(Guid)) { throw new InvalidOperationException(string.Format( "An engine system other than {0} is already registered with the {1} guid", EngineSystemType.Name, Guid.ToString(Values.KGuid.kFormatHyphenated))); } EngineRegistry.Register(this); }
void RegisterSystem() { if (Engine.EngineRegistry.Systems.ContainsKey(SystemGuid)) { throw new InvalidOperationException(string.Format(Util.InvariantCultureInfo, "An engine system other than {0} is already registered with the {1} guid", EngineSystemType.Name, GetSystemGuidString())); } EngineRegistry.Register(this); }
EngineSystemBase TryGetSystem(Values.KGuid systemGuid) { if (!SupportsSystem(systemGuid)) { return(null); } var system_metadata = EngineRegistry.TryGetRegisteredSystem(systemGuid); Contract.Assume(system_metadata != null); return(GetNewOrExistingSystem(system_metadata)); }
//internal uint Handle { get { return mHandle; } } static void InitializeHandle(out uint handle, EngineBuildHandle buildHandle, int platformIndex, int resourceModelIndex) { if (platformIndex.IsNone() && resourceModelIndex.IsNone()) { resourceModelIndex = 0; } var encoder = new Bitwise.HandleBitEncoder(); EngineRegistry.BitEncodeResourceModelIndex(ref encoder, resourceModelIndex); EngineTargetPlatform.BitEncodeIndex(ref encoder, platformIndex); encoder.Encode32(buildHandle.Handle, EngineBuildHandle.Bitmask); Contract.Assert(encoder.UsedBitCount == BlamEngineTargetHandle.BitCount); handle = encoder.GetHandle32(); }
EngineSystemBase GetSystem(Values.KGuid systemGuid, EngineBuildHandle forBuild) { if (!SupportsSystem(systemGuid)) { string system_display_name = EngineRegistry.GetSystemDebugDisplayString(systemGuid); string msg = string.Format("{0} doesn't support the system {1}", forBuild.ToDisplayString(), system_display_name); throw new InvalidOperationException(msg); } var system_metadata = EngineRegistry.TryGetRegisteredSystem(systemGuid); Contract.Assume(system_metadata != null); return(GetNewOrExistingSystem(system_metadata)); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { bool reading = s.IsReading; var engine = KSoft.Debug.TypeCheck.CastReference <BlamEngine>(s.UserData); if (reading) { Engine = engine; } else { Contract.Assert(engine == Engine); } if (reading) { var system_guid = Values.KGuid.Empty; s.StreamAttribute("guid", ref system_guid); SystemMetadata = EngineRegistry.TryGetRegisteredSystem(system_guid); if (SystemMetadata == null) { string msg = string.Format(Util.InvariantCultureInfo, "No system is registered with the GUID {0}", system_guid.ToString(Values.KGuid.kFormatHyphenated, Util.InvariantCultureInfo)); s.ThrowReadException(new System.IO.InvalidDataException(msg)); } } else { Contract.Assert(false, "Writing not supported"); } s.StreamAttribute("externs", this, o => o.ExternsFile); }