// =================================================================== // CODE GENERATION FUNCTIONS // ------------------------------------------------------------------- /// Generate the code for a function definition. /// /// @param indentSize The indentation of the function. /// @return The generated code for the given function. /// public override string GenerateHeader(int indentSize) { var result = new StringBuilder(1024); result.Append(base.GenerateHeader(indentSize)); // Build components var indent = ToIndent(indentSize + 1); VSObject.ForEachChildPort( p => { if (p.PortIndex < (int)iCS_PortIndex.ParametersEnd) { if (p.IsInProposedDataPort && iCS_Types.IsA <Component>(p.RuntimeType)) { result.Append(indent); result.Append("var "); result.Append(GetLocalVariableName(p)); result.Append("= GetComponent<"); result.Append(ToTypeName(p.RuntimeType)); result.Append(">();\n"); } } } ); return(result.ToString()); }
/// <summary> /// Constructor "Open" /// </summary> /// <param name="node"></param> internal VXmlDummy(VXmlNode node, short type, string name) { BASE_NODE = node; BASE_OBJECT = node.OBJ; field_type = type; field_name = name; field_value = ""; field_prefix = DEFX.NODE_TYPE_INTERNAL_FIELD_PREFIX[type - 100]; }
/// <summary> /// Used by "ContentBytes property and CheckIn /// </summary> /// <param name="bytes"></param> internal void save_content_bytes(ref byte[] value) { long ln = value.Length; if (ln > 0) { VSObject a = content_space.Allocate(ln + 12, DEFX.NODE_TYPE_CONTENT, DEFX.CONTENT_BLOCKSIZE); CONT_ID = a.Id; a.Write(HDR_LENGTH_POS, ln); // Save length a.Write(CONTENT_HDR_SIZE, value, ln); } }
// ------------------------------------------------------------------- /// Scan the input ports to create special local variables. void CreateLocalVariables() { VSObject.ForEachChildPort( p => { if (p.PortIndex < (int)iCS_PortIndex.ParametersEnd) { if (p.IsInProposedDataPort && iCS_Types.IsA <Component>(p.RuntimeType)) { new LocalVariableDefinition(p, this); } } } ); }
// ------------------------------------------------------------------- /// Collect the used assemblies void CollectUsedNamespaces() { VSObject.ForEachChildRecursiveDepthFirst( c => { if (c.IsKindOfFunction) { var runtimeType = c.RuntimeType; if (runtimeType != null) { AddNamespace(runtimeType.Namespace); } } } ); }
/// <summary> /// Constructor /// </summary> /// <param name="node"></param> internal VXmlDummyCollection(VXmlNode node, string type, string prefix) { // Save base objects BASE_NODE = node; BASE_OBJECT = node.OBJ; field_type = type; // Get fields list object_fields = BASE_OBJECT.GetFields(type + prefix); for (int i = 0; i < object_fields.Length; i++) { object_fields[i] = object_fields[i].Remove(0, 1); } }
// ------------------------------------------------------------------- /// Build information for parameters. void BuildParameterInformation() { var parameters = GetParameters(VSObject); var pLen = parameters.Length; myParameters = new CodeBase[pLen]; foreach (var p in parameters) { int idx = p.PortIndex; if (idx >= parameters.Length) { VSObject.ForEachChildPort( dp => { Debug.Log("Index: " + dp.PortIndex + " => " + dp.FullName); } ); } if (p.IsInputPort) { var producerPort = GraphInfo.GetProducerPort(p); if (producerPort != null && producerPort != p) { myParameters[idx] = new FunctionCallParameterDefinition(p, this, p.RuntimeType); } else { // Generate class variable for UnityEngine.Objects var portType = p.RuntimeType; if (iCS_Types.IsA <UnityEngine.Object>(portType)) { myParameters[idx] = new FunctionCallParameterDefinition(p, this, p.RuntimeType); var typeDef = GetClassDefinition(); var v = new VariableDefinition(p, typeDef, AccessSpecifier.Public, ScopeSpecifier.NonStatic); typeDef.AddVariable(v); } else { myParameters[idx] = new ConstantDefinition(p, this); } } } else { myParameters[idx] = new FunctionCallOutParameterDefinition(p, this); } } }
private void DisplaySpaceInfo() { string nm = (string)listSpace.SelectedItem; if ((cbShow.SelectedIndex == 0) | (nm == "<All>")) { // Display Space Info OpenStorage(); this.DisplayInfo(); CloseStorage(); } else if (nm != "<All>") { if (cbShow.SelectedIndex == 1) { // Display Free Space Info txtInfo.Text = ""; OpenStorage(); string[] info = mgr.GetFreeSpaceInfo(nm); CloseStorage(); for (int i = 0; i < info.Length; i++) { AddInfo(info[i]); } } else if (cbShow.SelectedIndex == 2) { // Display Pool Allocation OpenStorage(); txtInfo.Text = ""; VSpace sp = mgr.GetSpace(nm); short[] pools = sp.GetPools(); string spf = "#,#;(#,#)"; int padf = 15; AddInfo("Pool# Allocated size"); for (int i = 0; i < pools.Length; i++) { long[] a = sp.GetPoolPointers(pools[i]); long a_use = 0; if (a[0] > 0) { VSObject o = sp.GetRootObject(pools[i]); while (o != null) { a_use += o.Size; o = o.Next; } if (pools[i] > 0) { AddInfo(pools[i].ToString().PadLeft(5) + " " + a_use.ToString(spf).PadLeft(padf)); } else { AddInfo(DEFS.POOL_MNEM(pools[i]).PadLeft(5) + " " + a_use.ToString(spf).PadLeft(padf)); } } } AddInfo("Done"); CloseStorage(); } } }