// this might be getting called too many times since im not sure im caching the result private void ParseContentTemplate(TemplateRootNode templateRootNode, TemplateShell shell, ProcessedType processedType) { XElement root = shell.GetElementTemplateContent(processedType.templateAttr.templateId); if (root == null) { throw new TemplateNotFoundException(processedType.templateAttr.filePath, processedType.templateAttr.templateId); } IXmlLineInfo xmlLineInfo = root; StructList <AttributeDefinition> attributes = StructList <AttributeDefinition> .Get(); StructList <AttributeDefinition> injectedAttributes = StructList <AttributeDefinition> .Get(); ParseAttributes(shell, "Contents", root.Attributes(), attributes, injectedAttributes, out string genericTypeResolver, out string requireType); if (attributes.size == 0) { StructList <AttributeDefinition> .Release(ref attributes); } if (injectedAttributes.size == 0) { StructList <AttributeDefinition> .Release(ref injectedAttributes); } templateRootNode.attributes = ValidateRootAttributes(shell.filePath, attributes); templateRootNode.lineInfo = new TemplateLineInfo(xmlLineInfo.LineNumber, xmlLineInfo.LinePosition); templateRootNode.genericTypeResolver = genericTypeResolver; templateRootNode.requireType = requireType; // always null I think ParseChildren(templateRootNode, templateRootNode, root.Nodes()); }
public void Release() { StackPool <int> .Release(stack); StructList <ExpressionToken> .Release(ref tokens); stack = null; }
public override void Release() { body.Release(); StructList <LambdaArgument> .Release(ref signature); body = null; s_LambdaExpressionPool.Release(this); }
public void Release() { typeName = null; namespaceName = null; if (generics != null) { for (int i = 0; i < generics.Count; i++) { generics[i].Release(); } StructList <TypeLookup> .Release(ref generics); } }
public static bool TryParseTypeName(string typeName, out TypeLookup typeLookup) { StructList <ExpressionToken> list = StructList <ExpressionToken> .Get(); ExpressionTokenizer.Tokenize(typeName, list); ExpressionParser parser = new ExpressionParser(new TokenStream(list)); typeLookup = default; bool valid = parser.ParseTypePath(ref typeLookup); parser.Release(); list.Release(); return(valid); }
public void OnUpdate() { if (onStylePropertyChanged == null) { return; } m_ChangeSets.ForEach(this, (id, changeSet, self) => { if (!changeSet.element.isEnabled) { StructList <StyleProperty> .Release(ref changeSet.changes); changeSet.element = null; return; } // if (changeSet.element is IStylePropertiesWillChangeHandler willChangeHandler) { // willChangeHandler.OnStylePropertiesWillChange(); // } self.onStylePropertyChanged.Invoke(changeSet.element, changeSet.changes); if (changeSet.element is IStyleChangeHandler changeHandler) { StyleProperty[] properties = changeSet.changes.Array; int count = changeSet.changes.Count; for (int i = 0; i < count; i++) { changeHandler.OnStylePropertyChanged(properties[i]); } } // if (changeSet.element is IStylePropertiesDidChangeHandler didChangeHandler) { // didChangeHandler.OnStylePropertiesDidChange(); // } StructList <StyleProperty> .Release(ref changeSet.changes); changeSet.element = null; }); m_ChangeSets.Clear(); }
internal static MethodInfo SelectEligibleMethod(IList <MethodInfo> methodInfos, Expression[] arguments, StructList <ParameterConversion> winningConversions) { if (methodInfos.Count == 0) { return(null); } if (methodInfos.Count == 1) { if (CheckCandidate(new Candidate(methodInfos[0].GetParameters()), arguments, out int unused, winningConversions)) { return(methodInfos[0]); } return(null); } StructList <Candidate> candidates = StructList <Candidate> .GetMinSize(methodInfos.Count); StructList <ParameterConversion> conversions = StructList <ParameterConversion> .Get(); int argCount = arguments.Length; for (int i = 0; i < methodInfos.Count; i++) { MethodInfo methodInfo = methodInfos[i]; ParameterInfo[] parameterInfos = methodInfo.GetParametersCached(); if (parameterInfos.Length == argCount) { candidates.Add(new Candidate(methodInfo, parameterInfos)); } else if (parameterInfos.Length > argCount) { bool valid = true; for (int j = 0; j < parameterInfos.Length; j++) { if (!parameterInfos[j].HasDefaultValue) { valid = false; break; } } if (valid) { candidates.Add(new Candidate(methodInfo, parameterInfos)); } } } int winner = -1; int winnerPoints = -1; for (int i = 0; i < candidates.Count; i++) { int candidatePoints; conversions.QuickClear(); if (!CheckCandidate(candidates[i], arguments, out candidatePoints, conversions)) { continue; } // todo -- handle the ambiguous case if (BestScoreSoFar(candidatePoints, winnerPoints)) { winner = i; winnerPoints = candidatePoints; winningConversions.QuickClear(); winningConversions.AddRange(conversions); } } StructList <ParameterConversion> .Release(ref conversions); if (winner != -1) { MethodInfo retn = candidates[winner].methodInfo; StructList <Candidate> .Release(ref candidates); return(retn); } return(null); }
internal static ConstructorInfo SelectEligibleConstructor(Type type, Expression[] arguments, StructList <ParameterConversion> winningConversions) { ConstructorInfo[] constructors = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public); if (constructors.Length == 0) { return(null); } if (constructors.Length == 1) { if (CheckCandidate(new Candidate(constructors[0].GetParametersCached()), arguments, out int unused, winningConversions)) { return(constructors[0]); } return(null); } StructList <Candidate> candidates = StructList <Candidate> .GetMinSize(constructors.Length); StructList <ParameterConversion> conversions = StructList <ParameterConversion> .Get(); for (int i = 0; i < constructors.Length; i++) { candidates[i] = new Candidate(constructors[i].GetParametersCached()); } int winner = -1; int winnerPoints = 0; for (int i = 0; i < constructors.Length; i++) { int candidatePoints; conversions.QuickClear(); if (!CheckCandidate(candidates[i], arguments, out candidatePoints, conversions)) { continue; } // todo -- handle the ambiguous case if (BestScoreSoFar(candidatePoints, winnerPoints)) { winner = i; winnerPoints = candidatePoints; winningConversions.QuickClear(); winningConversions.AddRange(conversions); } } StructList <Candidate> .Release(ref candidates); StructList <ParameterConversion> .Release(ref conversions); if (winner != -1) { return(constructors[winner]); } return(null); }
// depth buffer means our regions are locked per channel // 2 options: 1. each channel is its own set of draw calls, this is easy but maybe not as fast. do this as a first pass // 2. try to re-use regions for different channels, almost certainly leads to less throughput but faster since we don't need extra draw calls // probably means we have sub-sorting regions, ie large packers would have sub-packers // would definitely want to sort by size in that case and first try to pack larger regions into themselves // would likely update rect packer to be channel aware, when trying to place next item instead of moving over try colliding a different channel instead public void Clip(Camera camera, CommandBuffer commandBuffer) { // breaks on refresh if we don't do this :( this.clearMaterial.SetColor(s_Color, Color.white); this.clearCountMaterial.SetColor(s_Color, new Color(0, 0, 0, 0)); requireRegionCounting = false; for (int i = 0; i < batchesToRender.size; i++) { batchesToRender[i].pooledMesh.Release(); StructList <Matrix4x4> .Release(ref batchesToRender.array[i].transforms); StructList <Vector4> .Release(ref batchesToRender.array[i].objectData); StructList <Vector4> .Release(ref batchesToRender.array[i].colorData); } batchesToRender.Clear(); Gather(); Vector3 cameraOrigin = camera.transform.position; cameraOrigin.x -= 0.5f * Screen.width; cameraOrigin.y += (0.5f * Screen.height); cameraOrigin.z += 2; Matrix4x4 origin = Matrix4x4.TRS(cameraOrigin, Quaternion.identity, Vector3.one); LightList <ClipData> texturedClippers = LightList <ClipData> .Get(); regionMesh?.Release(); regionMesh = GetRegionMesh(out requireRegionCounting); clipTexture = RenderTexture.GetTemporary(Screen.width, Screen.height, 24, RenderTextureFormat.Default); // todo -- use lower resolution #if DEBUG commandBuffer.BeginSample("UIFora Clip Draw"); #endif commandBuffer.SetRenderTarget(clipTexture); // probably don't need this actually, can bake it into clear. keep for debugging commandBuffer.ClearRenderTarget(true, true, Color.black); commandBuffer.DrawMesh(regionMesh.mesh, origin, clearMaterial, 0, 0); // todo -- handle multiple shapes from one path ClipBatch batch = new ClipBatch(); batch.transforms = StructList <Matrix4x4> .Get(); batch.colorData = StructList <Vector4> .Get(); batch.objectData = StructList <Vector4> .Get(); for (int i = 0; i < clippers.size; i++) { ClipData clipData = clippers[i]; Path2D clipPath = clipData.clipPath; if (clipPath == null) { // todo if transform is not identity we need to generate a rotated or skewed rect for the clip shape continue; } clipPath.UpdateGeometry(); // should early out if no update required if (AnyShapeUsesTextures(clipPath)) { // todo -- handle textures // todo -- handle text continue; } batch = DrawShapesInPath(batch, clipPath, clipData, clipData); for (int j = 0; j < clipData.dependents.size; j++) { batch = DrawShapesInPath(batch, clipPath, clipData, clipData.dependents[j]); } } FinalizeBatch(batch, false); for (int i = 0; i < batchesToRender.size; i++) { ref ClipBatch clipBatch = ref batchesToRender.array[i]; ClipPropertyBlock propertyBlock = clipMaterialPool.GetPropertyBlock(clipBatch.transforms.size); propertyBlock.SetData(clipBatch); commandBuffer.DrawMesh(clipBatch.pooledMesh.mesh, origin, clipDrawMaterial, 0, 0, propertyBlock.matBlock); }
private bool ParseDeclaration(ref ASTNode node) { AttributeNode attrNode = null; LightList <AttributeNode> attributes = LightList <AttributeNode> .Get(); while (ParseAttribute(ref attrNode)) { attributes.Add(attrNode); if (tokenStream.Current != ExpressionTokenType.ArrayAccessOpen) { break; } } if (attributes.size == 0) { LightList <AttributeNode> .Release(ref attributes); } if (tokenStream.Current != ExpressionTokenType.Identifier) { return(false); } // modifiers? -> returnType -> name -> signature -> openBrace * closeBrace tokenStream.Save(); bool isStatic = false; if (tokenStream.Current == "static") { isStatic = true; tokenStream.Advance(); } ExpressionParser parser = new ExpressionParser(tokenStream); StructList <LambdaArgument> signature = null; TypeLookup typeLookup = default; if (!parser.ParseTypePath(ref typeLookup)) { goto fail; } tokenStream.Set(parser.GetTokenPosition()); parser.Release(false); if (tokenStream.Current != ExpressionTokenType.Identifier) { goto fail; } string name = tokenStream.Current.value; tokenStream.Advance(); // if semi colon then we have a field! if (tokenStream.Current == ExpressionTokenType.SemiColon) { tokenStream.Advance(); node = new FieldNode() { name = name, isStatic = isStatic, attributes = attributes, typeLookup = typeLookup }; return(true); } if (tokenStream.Current != ExpressionTokenType.ParenOpen) { goto fail; } signature = StructList <LambdaArgument> .Get(); if (tokenStream.NextTokenIs(ExpressionTokenType.ParenClose)) { tokenStream.Advance(2); } else { int matchingIndex = tokenStream.FindMatchingIndex(ExpressionTokenType.ParenOpen, ExpressionTokenType.ParenClose); if (matchingIndex == -1) { goto fail; } TokenStream subStream = tokenStream.AdvanceAndReturnSubStream(matchingIndex); subStream.Advance(); tokenStream.Advance(); if (!ExpressionParser.ParseSignature(subStream, signature)) { goto fail; } for (int i = 0; i < signature.size; i++) { if (signature.array[i].type == null) { throw new ParseException($"When defining a method you must specify a type for all arguments. Found identifier {signature.array[i].identifier} but no type was given."); } } } if (tokenStream.Current != ExpressionTokenType.ExpressionOpen) { goto fail; } BlockNode block = ParseBlock(); node = new MethodNode() { body = block, returnTypeLookup = typeLookup, attributes = attributes, name = name, isStatic = isStatic, signatureList = signature != null?signature.ToArray() : s_EmptySignature }; StructList <LambdaArgument> .Release(ref signature); parser.Release(false); return(true); fail: { tokenStream.Restore(); parser.Release(false); typeLookup.Release(); signature?.Release(); return(false); } }
public void Release() { StructList <StyleKeyFrameValue> .Release(ref properties); }
public void Release() { slotInputs?.Release(); application = null; innerSlotContext = null; }