/// <summary> /// Get a list of <see cref="IFeature"/> removing this enumerant. /// </summary> /// <param name="registry"> /// A <see cref="Registry"/> holding the registry information. /// </param> /// <returns> /// It returns a <see cref="T:IEnumerable{IFeature}"/> listing all features removing this enumerant. /// </returns> private IEnumerable <IFeature> GetFeaturesRemovingEnum(RegistryContext ctx) { List <IFeature> features = new List <IFeature>(); // Features foreach (Feature feature in ctx.Registry.Features) { if (feature.Api != null && !ctx.IsSupportedApi(feature.Api)) { continue; } int requirementIndex = feature.Removals.FindIndex(delegate(FeatureCommand item) { if (item.Api != null && !ctx.IsSupportedApi(item.Api)) { return(false); } int enumIndex = item.Enums.FindIndex(delegate(FeatureCommand.Item subitem) { return(subitem.Name == Name); }); return(enumIndex != -1); }); if (requirementIndex != -1) { features.Add(feature); } } return(features); }
public IEnumerable <IFeature> AllFeatures(RegistryContext ctx) { foreach (Feature feature in Features) { if (ctx.IsSupportedApi(feature.Api)) { yield return(feature); } } List <Extension> extensions = new List <Extension>(Extensions); extensions.RemoveAll(delegate(Extension item) { return(item.Supported != null && !ctx.IsSupportedApi(item.Supported)); }); extensions.Sort(delegate(Extension x, Extension y) { int xIndex = ExtensionIndices.GetIndex(x.Name); int yIndex = ExtensionIndices.GetIndex(y.Name); if (xIndex != yIndex) { return(xIndex.CompareTo(yIndex)); } else { return(x.Name.CompareTo(y.Name)); } }); foreach (Extension extension in extensions) { yield return(extension); } }
/// <summary> /// Reduce a <see cref="Command"/> name, removing type suffixes. /// </summary> /// <param name="ctx"> /// A <see cref="RegistryContext"/> defining OpenGL specification information. /// </param> /// <param name="specificationName"> /// A <see cref="String"/> that specifies the command name. /// </param> /// <returns> /// It returns a <see cref="String"/> that is the reduced name (suitable for overriding commands) of /// <paramref name="specificationName"/>. /// </returns> public string GetOverridableName(RegistryContext ctx, string specificationName) { if (String.IsNullOrEmpty(specificationName)) throw new ArgumentNullException("specificationName"); // Extract extension string nameExtension = null; foreach (string word in ctx.ExtensionsDictionary.Words) { if (specificationName.EndsWith(word)) { nameExtension = word; break; } } if (nameExtension != null) specificationName = specificationName.Substring(0, specificationName.Length - nameExtension.Length); string postfix = specificationName; foreach (string word in Words) { postfix = postfix.Replace(word, String.Empty); if (postfix.Length == 0) break; } if ((postfix.Length > 0) && specificationName.EndsWith(postfix) && (ctx.ExtensionsDictionary.HasWord(postfix) == false)) specificationName = specificationName.Substring(0, specificationName.Length - postfix.Length); if (nameExtension != null) specificationName += nameExtension; return (specificationName); }
public virtual void WriteDebugAssertion(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { switch (LengthMode) { case CommandParameterLengthMode.Constant: // Note: // - The argument must be an Array instance if (IsManagedArray(ctx, parentCommand)) { sw.WriteLine("Debug.Assert({0}.Length >= {1});", ImplementationName, LengthConstant); } break; case CommandParameterLengthMode.ArgumentMultiple: uint multiple = LengthMultiple; // Note: // - The array must provide 'n' elements for each unit in counter parameter if (IsManagedArray(ctx, parentCommand) && multiple > 1) { sw.WriteLine("Debug.Assert({0}.Length > 0 && ({0}.Length % {1}) == 0, \"empty or not multiple of {1}\");", ImplementationName, multiple); } break; } }
internal static new bool IsCompatible(RegistryContext ctx, Command parentCommand, CommandParameter param) { if (String.IsNullOrEmpty(param.Length) || !param.IsManagedArray(ctx, parentCommand)) { return(false); } string sizeParamName; switch (param.LengthMode) { case CommandParameterLengthMode.ArgumentReference: sizeParamName = param.Length; break; case CommandParameterLengthMode.ArgumentMultiple: sizeParamName = param.LengthArgument; break; default: return(false); } if (sizeParamName == null) { return(false); } if (parentCommand.Parameters.FindIndex(delegate(CommandParameter item) { return(item.Name == sizeParamName); }) < 0) { return(false); } return(true); }
public override void WriteCallLogArgParam(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { if (IsArrayLengthParameter(this, ctx, parentCommand)) { CommandParameter arrayParam = GetArrayParameter(this, ctx, parentCommand); switch (arrayParam.LengthMode) { case CommandParameterLengthMode.ArgumentReference: sw.Write("{0}.Length", arrayParam.GetDelegateCallVarName(parentCommand)); break; case CommandParameterLengthMode.ArgumentMultiple: uint multiple = arrayParam.LengthMultiple; if (multiple > 1) { sw.Write("{0}.Length / {1}", arrayParam.GetDelegateCallVarName(parentCommand), multiple); } else { sw.Write("{0}.Length", arrayParam.GetDelegateCallVarName(parentCommand)); } break; } } else { base.WriteCallLogArgParam(sw, ctx, parentCommand); } }
internal static CommandParameter GetArrayParameter(CommandParameter param, RegistryContext ctx, Command parentCommand) { List <CommandParameter> arrayParams = parentCommand.Parameters.FindAll(delegate(CommandParameter item) { // - no len? if (String.IsNullOrEmpty(item.Length)) { return(false); } // - len="count" if (item.Length == param.Name) { return(true); } // - len="count*3" if (Regex.IsMatch(item.Length, param.Name + @"\*\d+")) { return(true); } return(false); }); if (arrayParams.Count > 0) { return(arrayParams[0]); } else { return(null); } }
public UsersManager( IOptions <AppSettings> appSettings, ILoginManager loginManager, UserManager <User> userManager, RoleManager <IdentityRole> roleManager, ApplicationDbContext applicationDbContext, IAuthManager authManager, IOrganizationsManager organizationsManager, IUtils utils, ILogger <UsersManager> logger, RegistryContext registryContext, IConfigurationHelper <AppSettings> configurationHelper) { _roleManager = roleManager; _authManager = authManager; _organizationsManager = organizationsManager; _utils = utils; _logger = logger; _registryContext = registryContext; _configurationHelper = configurationHelper; _applicationDbContext = applicationDbContext; _loginManager = loginManager; _userManager = userManager; _appSettings = appSettings.Value; }
public Employee Get(int id) { using (var context = new RegistryContext()) { return(context.Employees.FirstOrDefault(x => x.id == id)); } }
private string GetReturnValueExpression(RegistryContext ctx) { // The implementation returned type string returnType = GetImplementationReturnType(ctx); // The delegate returned type string delegateReturnType = DelegateReturnType; // Returned value must be marshalled as string bool marshalReturnedString = HasReturnValue && (returnType.ToLower() == "string") && (delegateReturnType.ToLower() != "string"); // Returned value must be marshalled as structure bool marshalReturnedStruct = HasReturnValue && (DelegateReturnType == "IntPtr") && (GetImplementationReturnType(ctx) != "IntPtr"); if (marshalReturnedString) { return(String.Format("Marshal.PtrToStringAnsi({0})", ReturnVariableName)); } else if (marshalReturnedStruct) { return(String.Format("({1})Marshal.PtrToStructure({0}, typeof({1}))", ReturnVariableName, GetImplementationReturnType(ctx))); } else if (returnType != delegateReturnType) { return(String.Format("({1}){0}", ReturnVariableName, GetImplementationReturnType(ctx))); } else { return(String.Format("{0}", ReturnVariableName)); } }
/// <summary> /// Link other information against this enumerant. /// </summary> /// <param name="ctx"> /// A <see cref="RegistryContext"/> holding the registry information to link. /// </param> internal void Link(RegistryContext ctx) { foreach (Enumerant enumerant in Enums) { // Link enumerant.ParentEnumerantBlock = this; if ((enumerant.Type == null) && (Type == "bitmask")) { enumerant.Type = "u"; } // Recurse enumerant.Link(ctx); } Enums.RemoveAll(delegate(Enumerant item) { if (item.RequiredBy.Count == 0) { return(true); } if (item.Api != null && !ctx.IsSupportedApi(item.Api)) { return(true); } return(false); }); }
/// <summary> /// Get a list of <see cref="IFeature"/> removing this enumerant. /// </summary> /// <param name="registry"> /// A <see cref="Registry"/> holding the registry information. /// </param> /// <returns> /// It returns a <see cref="T:IEnumerable{IFeature}"/> listing all features removing this enumerant. /// </returns> private IEnumerable <IFeature> GetFeaturesRemovingCommand(RegistryContext ctx) { List <IFeature> features = new List <IFeature>(); // Features foreach (Feature feature in ctx.Registry.Features) { if (feature.Api != null && feature.Api != ctx.Class.ToLowerInvariant()) { continue; } int requirementIndex = feature.Removals.FindIndex(delegate(FeatureCommand item) { if (item.Api != null && !Regex.IsMatch(ctx.Class.ToLowerInvariant(), item.Api)) { return(false); } int enumIndex = item.Commands.FindIndex(delegate(FeatureCommand.Item subitem) { return(subitem.Name == Prototype.Name); }); return(enumIndex != -1); }); if (requirementIndex != -1) { features.Add(feature); } } return(features); }
public IEnumerable <Task> Get() { using (var context = new RegistryContext()) { return(context.Tasks.ToList()); } }
internal static bool IsCompatible(RegistryContext ctx, Command command, CommandParameter param) { switch (ctx.Class.ToLower()) { case "gl": break; default: return(false); } if (param.GetImplementationType(ctx, command) != "IntPtr") { return(false); } if (Regex.IsMatch(param.Name, "offset")) { return(false); } if (param.IsConstant || command.IsGetImplementation(ctx)) { return(true); } return(false); }
internal void GenerateDocumentation(SourceStreamWriter sw, RegistryContext ctx) { if (ctx.RefPages.Count > 0) { ctx.RefPages.GenerateDocumentation(sw, ctx, this); } }
/// <summary> /// Get a list of <see cref="IFeature"/> requiring this enumerant. /// </summary> /// <param name="registry"> /// A <see cref="Registry"/> holding the registry information. /// </param> /// <returns> /// It returns a <see cref="T:IEnumerable{IFeature}"/> listing all features requiring this enumerant. /// </returns> private IEnumerable <IFeature> GetFeaturesRequiringEnum(RegistryContext ctx) { List <IFeature> features = new List <IFeature>(); // Features foreach (Feature feature in ctx.Registry.Features) { if (feature.Api != null && !Regex.IsMatch(ctx.Class.ToLowerInvariant(), feature.Api)) { continue; } int requirementIndex = feature.Requirements.FindIndex(delegate(FeatureCommand item) { if (item.Api != null && !Regex.IsMatch(ctx.Class.ToLowerInvariant(), item.Api)) { return(false); } int enumIndex = item.Enums.FindIndex(delegate(FeatureCommand.Item subitem) { return(subitem.Name == Name); }); return(enumIndex != -1); }); if (requirementIndex != -1) { features.Add(feature); } } // Extensions foreach (Extension extension in ctx.Registry.Extensions) { if (extension.Supported != null && !Regex.IsMatch(ctx.Class.ToLowerInvariant(), extension.Supported)) { continue; } int requirementIndex = extension.Requirements.FindIndex(delegate(FeatureCommand item) { if (item.Api != null && !Regex.IsMatch(ctx.Class.ToLowerInvariant(), item.Api)) { return(false); } int enumIndex = item.Enums.FindIndex(delegate(FeatureCommand.Item subitem) { return(subitem.Name == Name); }); return(enumIndex != -1); }); if (requirementIndex != -1) { features.Add(extension); } } return(features); }
public void AddRegistry(RegistryContext reg) { if (!ContextRegistered(reg)) { _contextRegistry.Add(reg); } }
public override void WriteUnpinCommand(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { if (GetImplementationType(ctx, parentCommand) == "Object") { sw.WriteLine("{0}.Free();", PinnedLocalVarName); } }
public IEnumerable <Employee> Get() { using (var context = new RegistryContext()) { return(context.Employees.ToList()); } }
public void SetContext(RegistryContext reg) { if (ContextRegistered(reg)) { _currentContext = reg; } }
public override void WritePinnedVariable(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { if (GetImplementationType(ctx, parentCommand) == "Object") { sw.WriteLine("GCHandle {0} = GCHandle.Alloc({1}, GCHandleType.Pinned);", PinnedLocalVarName, ImplementationName); } }
public override void WriteDelegateParam(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { string paramModifier = GetImplementationTypeModifier(ctx, parentCommand); if (mIsPinned) { if (paramModifier != null) { sw.Write("{0} ", paramModifier); } // Object parameters are pinned sw.Write("{0}.AddrOfPinnedObject()", PinnedLocalVarName); } else if (IsFixed(ctx, parentCommand)) { if (paramModifier != null) { sw.Write("{0} ", paramModifier); } // Fixed parameters are fixed in overloaded method call sw.Write(DelegateCallVarName); } else { base.WriteDelegateParam(sw, ctx, parentCommand); } }
public Handler( GameContext gameContext, RegistryContext registryContext) { _registryContext = registryContext; _gameContext = gameContext; }
public Task Get(int id) { using (var context = new RegistryContext()) { return(context.Tasks.FirstOrDefault(x => x.id == id)); } }
/// <summary> /// Generate the C# source code for this enumerant. /// </summary> /// <param name="sw"> /// A <see cref="SourceStreamWriter"/> used for writing the source code. /// </param> internal void GenerateSource(SourceStreamWriter sw, RegistryContext ctx) { if (sw == null) { throw new ArgumentNullException(nameof(sw)); } GenerateDocumentation(sw, ctx); GenerateRequirements(sw, ctx); // This metadata is used for procedure logging function bool requiresLogAttribute = ParentEnumerantBlock.Type == "bitmask"; if (requiresLogAttribute == true) { if (ParentEnumerantBlock.Type == "bitmask") { sw.WriteLine("[Log(BitmaskName = \"{0}\")]", ParentEnumerantBlock.Namespace); } } //if (IsDeprecated) { // sw.Write("#if DEBUG && !OPENGL_NET_COMPATIBILITY_PROFILE" + Environment.NewLine); // sw.WriteLine("[Obsolete(\"Deprecated/removed by {0}.\")]", SpecificationStyle.GetKhronosVersionHumanReadable(RemovedBy[0].Name)); // sw.Write("#endif" + Environment.NewLine); //} sw.WriteLine(Declaration); }
/// <summary> /// Generate the command delegate source code. /// </summary> /// <param name="sw"> /// The <see cref="SourceStreamWriter"/> used to write the source code. /// </param> /// <param name="ctx"> /// The <see cref="RegistryContext"/> defining the OpenGL registry information. /// </param> internal void GenerateDelegate(SourceStreamWriter sw, RegistryContext ctx) { // No sure if it is really necessary sw.WriteLine("[SuppressUnmanagedCodeSecurity()]"); // Delegate type definition sw.WriteIdentation(); sw.Write("internal "); if (IsSafeImplementation == false) { sw.Write("unsafe "); } sw.Write("delegate "); sw.Write("{0} {1}(", DelegateReturnType, ImportName); int paramCount = Parameters.Count; foreach (CommandParameter param in Parameters) { string paramAttributes = param.GetDelegateTypeAttributes(ctx, this); string paramModifier = param.GetDelegateTypeModifier(ctx, this); if (paramAttributes != null) { sw.Write("{0} ", paramAttributes); } if (paramModifier != null) { sw.Write("{0} ", paramModifier); } sw.Write("{0} {1}", param.GetDelegateType(ctx, this), param.ImportName); paramCount--; if (paramCount > 0) { sw.Write(", "); } } sw.Write(");"); sw.WriteLine(); sw.WriteLine(); if (Aliases.Count > 0) { sw.WriteLine("[AliasOf(\"{0}\")]", ImportName); foreach (Command aliasOf in Aliases) { sw.WriteLine("[AliasOf(\"{0}\")]", aliasOf.ImportName); } } // Required on Windows platform: different threads can bind different OpenGL context, which can have different // entry points sw.WriteLine("[ThreadStatic]"); // Delegate field sw.WriteLine("internal static {0} {1};", ImportName, DelegateName); }
public override void WriteDelegateParam(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { if (mIsStrong) { // Strongly typed enum must be casted to delegate call type (int or uint) sw.Write("({0}){1}", OverridenParameter.ImportType, DelegateCallVarName); } else base.WriteDelegateParam(sw, ctx, parentCommand); }
/// <summary> /// Construct a CommandParameterArray from the original parameter. /// </summary> /// <param name="otherParam"></param> /// <param name="ctx"></param> /// <param name="parentCommand"></param> public CommandParameterArrayLength(CommandParameter otherParam, RegistryContext ctx, Command parentCommand) : base(otherParam, ctx, parentCommand) { if (otherParam == null) throw new ArgumentNullException("otherParam"); }
/// <summary> /// Construct a CommandParameterArray from the original parameter. /// </summary> /// <param name="otherParam"></param> /// <param name="ctx"></param> /// <param name="parentCommand"></param> public CommandParameterArrayLength(CommandParameter otherParam, RegistryContext ctx, Command parentCommand) : base(otherParam, ctx, parentCommand) { if (otherParam == null) { throw new ArgumentNullException("otherParam"); } }
public override bool IsImplicit(RegistryContext ctx, Command parentCommand) { if (IsArrayLengthParameter(this, ctx, parentCommand)) { return(true); } return(false); }
private List <CommandParameter> GetOutLastParameters(RegistryContext ctx) { List <CommandParameter> parameters = GetDefaultParameters(ctx); parameters.RemoveAt(parameters.Count - 1); parameters.Add(new CommandParameterOut(Parameters[Parameters.Count - 1], ctx, this, false)); return(parameters); }
public Employee Post(Employee employee) { using (var context = new RegistryContext()) { context.Employees.Add(employee); context.SaveChanges(); return(employee); } }
public Task Post(Task task) { using (var context = new RegistryContext()) { context.Tasks.Add(task); context.SaveChanges(); return(task); } }
/// <summary> /// Construct a CommandParameterUnsafe from the original parameter. /// </summary> /// <param name="otherParam"></param> /// <param name="ctx"></param> /// <param name="parentCommand"></param> public CommandParameterUnsafe(CommandParameter otherParam, RegistryContext ctx, Command parentCommand) : base(otherParam) { if (otherParam == null) throw new ArgumentNullException("otherParam"); if (IsCompatible(ctx, parentCommand, otherParam)) { _IsPointer = true; } }
internal static CommandParameter GetArrayLengthParameter(CommandParameter param, RegistryContext ctx, Command parentCommand) { List<CommandParameter> arrayLengthParams = parentCommand.Parameters.FindAll(delegate(CommandParameter item) { return (parentCommand.Parameters.FindIndex(delegate(CommandParameter subitem) { return (item.Length == param.Name); }) >= 0); }); if (arrayLengthParams.Count > 0) return (arrayLengthParams[0]); else return (null); }
/// <summary> /// Construct a CommandParameterStrong from the original parameter. /// </summary> /// <param name="otherParam"></param> /// <param name="ctx"></param> /// <param name="parentCommand"></param> public CommandParameterStrong(CommandParameter otherParam, RegistryContext ctx, Command parentCommand) : base(otherParam) { if (otherParam == null) throw new ArgumentNullException("otherParam"); if (IsCompatible(otherParam, ctx, parentCommand)) { Type = otherParam.Group; mIsStrong = true; } }
public void Link(RegistryContext ctx) { foreach (Command command in Commands) command.Link(ctx); // Remove enumerants not required by anyone Commands.RemoveAll(delegate(Command item) { if (item.RequiredBy.Count == 0) return (true); return (false); }); }
internal static new bool IsCompatible(RegistryContext ctx, Command parentCommand, CommandParameter param) { if (!param.IsManagedArray || param.Length == null) return (false); int sizeParamIndex = parentCommand.Parameters.FindIndex(delegate (CommandParameter item) { return (item.Name == param.Length); }); if (sizeParamIndex < 0) return (false); return (true); }
internal static bool IsCompatible(CommandParameter param, RegistryContext ctx, Command parentCommand) { // 'bool' parameters are in Boolean group: conditions below will pass if (param.GetImplementationType(ctx, parentCommand) == "bool") return (false); // Unsafe parameters are not allowed, Group is a requirement if (!param.IsSafe || param.Group == null) return (false); // Check actual existence of strongly typed enum return (ctx.Registry.Groups.FindIndex(delegate(EnumerantGroup item) { return (item.Name == param.Group); }) >= 0); }
/// <summary> /// Construct a CommandParameterOut from the original parameter. /// </summary> /// <param name="otherParam"></param> /// <param name="ctx"></param> /// <param name="parentCommand"></param> public CommandParameterOut(CommandParameter otherParam, RegistryContext ctx, Command parentCommand, bool strong) : base(otherParam) { if (otherParam == null) throw new ArgumentNullException("otherParam"); if (IsCompatible(ctx, parentCommand, otherParam)) Length = "1"; else if (strong && CommandParameterStrong.IsCompatible(ctx, parentCommand, otherParam)) { Type = otherParam.Group; mIsStrong = true; } }
/// <summary> /// Construct a CommandParameterPinned from the original parameter. /// </summary> /// <param name="otherParam"></param> /// <param name="ctx"></param> /// <param name="parentCommand"></param> public CommandParameterPinned(CommandParameter otherParam, RegistryContext ctx, Command parentCommand, bool strong) : base(otherParam) { if (otherParam == null) throw new ArgumentNullException("otherParam"); if (IsCompatible(ctx, parentCommand, otherParam)) { Type = "Object"; TypeDecorators.Clear(); mIsPinned = true; } else if (strong && CommandParameterStrong.IsCompatible(ctx, parentCommand, otherParam)) { Type = otherParam.Group; } }
internal static bool IsCompatible(RegistryContext ctx, Command command, CommandParameter param) { // Already "out" param? if (param.GetImplementationTypeModifier(ctx, command) == "out") return (false); string implementationType = param.ManagedImplementationType; // Type[] + IsGetImplementation -> out Type // Type[] + OutParam -> out Type // Type[] + OutParamLast -> out Type if ((param.IsConstant == false) && implementationType.EndsWith("[]") && (param.Length != "1") && ((command.Flags & (CommandFlags.OutParam | CommandFlags.OutParamLast)) != 0)) return (true); return (false); }
internal static bool IsCompatible(RegistryContext ctx, Command command, CommandParameter param) { switch (ctx.Class.ToLower()) { case "gl": break; default: return (false); } if (param.GetImplementationType(ctx, command) != "IntPtr") return (false); if (Regex.IsMatch(param.Name, "offset")) return (false); if (param.IsConstant || command.IsGetImplementation(ctx)) return (true); return (false); }
public override void WriteDelegateParam(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { string paramModifier = GetImplementationTypeModifier(ctx, parentCommand); if (mIsPinned) { if (paramModifier != null) sw.Write("{0} ", paramModifier); // Object parameters are pinned sw.Write("{0}.AddrOfPinnedObject()", PinnedLocalVarName); } else if (IsFixed(ctx, parentCommand)) { if (paramModifier != null) sw.Write("{0} ", paramModifier); // Fixed parameters are fixed in overloaded method call sw.Write(DelegateCallVarName); } else base.WriteDelegateParam(sw, ctx, parentCommand); }
internal static bool IsCompatible(RegistryContext ctx, Command command, List<CommandParameter> parameters) { return (parameters.FindIndex(delegate (CommandParameter item) { return (IsCompatible(ctx, command, item)); }) >= 0); }
internal static bool IsCompatible(RegistryContext ctx, Command command) { return (IsCompatible(ctx, command, command.Parameters)); }
public virtual void WritePinnedVariable(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { // No code for common parameter }
public string GetImplementationTypeAttributes(RegistryContext ctx, Command parentCommand) { string implementationType = ManagedImplementationType; string implementationMod = GetImplementationTypeModifier(ctx, parentCommand); string attribute = null; // String + Length!=null && !IsConst -> [Out] StringBuilder (in Get commands) if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0)))) attribute = "[Out]"; // Array && !IsConst -> [Out] T[] (in Get commands) if ((IsConstant == false) && (implementationType.EndsWith("[]")) && ((implementationMod != "out") && (implementationMod != "ref")) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0)))) attribute = "[Out]"; return (attribute); }
public string GetDelegateTypeAttributes(RegistryContext ctx, Command parentCommand) { string implementationType = ManagedImplementationType; string attribute = null; // String + Length!=null -> [Out] StringBuilder if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0)))) attribute = "[Out]"; return (attribute); }
public virtual void WriteFixedStatement(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { if (IsFixed(ctx, parentCommand) == false) return; string dereference = String.Empty; switch (GetImplementationTypeModifier(ctx, parentCommand)) { case "out": case "ref": dereference = "&"; break; } sw.WriteLine("fixed ({0} {1} = {2}{3})", ImportType, FixedLocalVarName, dereference, ImplementationName); }
public virtual void WriteDebugAssertion(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { if (Length == null) return; if (CommandParameterArray.IsCompatible(this, ctx, parentCommand)) sw.WriteLine("Debug.Assert({0}.Length >= {1});", ImplementationName, Length); #if false if (Regex.IsMatch(Length, @"[0-9]+")) sw.WriteLine("Debug.Assert({0}.Length >= {1});", ImplementationName, Length); #endif }
public virtual void WriteDelegateParam(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { if (IsFixed(ctx, parentCommand) == false) { sw.Write(DelegateCallVarName); } else sw.Write(FixedLocalVarName); }
public virtual void WriteCallLogFormatParam(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand, int paramIndex) { string implementationType = GetImplementationType(ctx, parentCommand); bool safeImplementationType = !implementationType.EndsWith("*") && implementationType != "IntPtr"; if (safeImplementationType == false) sw.Write("0x{{{0}}}", paramIndex); else sw.Write("{{{0}}}", paramIndex); }
public virtual void WriteCallLogArgParam(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { WriteCallLogArgParam(sw, ImplementationName, GetImplementationType(ctx, parentCommand)); }
public string GetDelegateTypeModifier(RegistryContext ctx, Command parentCommand) { return (null); }
public override void WritePinnedVariable(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { if (GetImplementationType(ctx, parentCommand) == "Object") sw.WriteLine("GCHandle {0} = GCHandle.Alloc({1}, GCHandleType.Pinned);", PinnedLocalVarName, ImplementationName); }
public string GetDelegateType(RegistryContext ctx, Command parentCommand) { string implementationType = ImportType; // String + Length!=null -> [Out] StringBuilder if ((IsConstant == false) && (implementationType == "String") && (Length != null) && ((parentCommand.IsGetImplementation(ctx) || ((parentCommand.Flags & CommandFlags.OutParam) != 0)))) implementationType = "StringBuilder"; return (implementationType.Trim()); }
public override void WriteUnpinCommand(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { if (GetImplementationType(ctx, parentCommand) == "Object") sw.WriteLine("{0}.Free();", PinnedLocalVarName); }
public virtual bool IsImplicit(RegistryContext ctx, Command parentCommand) { return (false); }
public virtual void WriteUnpinCommand(SourceStreamWriter sw, RegistryContext ctx, Command parentCommand) { // No code for common parameter }