Exemplo n.º 1
0
		private void SerializeClassDefinition(List<string> output, ClassDefinition classDef, string indention)
		{
			output.Add(indention);
			output.Add("class ");
			output.Add(classDef.NameToken.Value);

			if (classDef.BaseClassToken != null)
			{
				output.Add(" : ");
				output.Add(classDef.BaseClassToken.Value);
				output.Add(" {\n");
			}
			else
			{
				output.Add(" {\n");
			}

			for (int i = 0; i < classDef.Members.Length; ++i)
			{
				if (i > 0)
				{
					output.Add("\n");
				}

				FunctionDefinition funDef = classDef.Members[i];

				SerializeFunctionDefinition(output, funDef, indention + "\t", funDef.Name == "__init__");
			}

			output.Add(indention);
			output.Add("}\n\n");
		}
Exemplo n.º 2
0
		private void SerializeClassDefinition(List<string> output, ClassDefinition classDef, string indention)
		{
			output.Add(indention);
			output.Add("class ");
			output.Add(classDef.NameToken.Value);
			if (classDef.BaseClassToken != null)
			{
				output.Add("(");
				output.Add(classDef.BaseClassToken.Value);
				output.Add("):\n");
			}
			else
			{
				output.Add(":\n");
			}

			foreach (FunctionDefinition fd in classDef.Members)
			{
				this.Serialize(output, fd, indention + "\t");
				output.Add("\n");
			}

			if (classDef.Members.Length == 0)
			{
				output.Add(indention);
				output.Add("\tpass\n");
			}
		}