public virtual string TranslateType(Pastel.Nodes.PType type) { if (this.parentPlatformSet) { return(this.parentPlatform.TranslateType(type)); } throw new InvalidOperationException("This platform does not support types."); }
private void InitTypeInfo() { this.returnTypeInfoForNativeMethods = new Dictionary <string, Pastel.Nodes.PType>(); this.argumentTypeInfoForNativeMethods = new Dictionary <string, Pastel.Nodes.PType[]>(); string typeInfoFile = FileUtil.JoinPath(this.Metadata.Directory, "native_method_type_info.txt"); if (FileUtil.FileExists(typeInfoFile)) { string typeInfo = FileUtil.ReadFileText(typeInfoFile); Pastel.TokenStream tokens = new Pastel.TokenStream(Pastel.Tokenizer.Tokenize("LIB:" + this.Metadata.ID + "/native_method_type_info.txt", typeInfo)); while (tokens.HasMore) { Pastel.Nodes.PType returnType = Pastel.Nodes.PType.Parse(tokens); string functionName = GetValidNativeLibraryFunctionNameFromPastelToken(tokens.Pop()); tokens.PopExpected("("); List <Pastel.Nodes.PType> argTypes = new List <Pastel.Nodes.PType>(); while (!tokens.PopIfPresent(")")) { if (argTypes.Count > 0) { tokens.PopExpected(","); } argTypes.Add(Pastel.Nodes.PType.Parse(tokens)); // This is unused but could be later used as part of an auto-generated documentation for third-party platform implements of existing libraries. string argumentName = GetValidNativeLibraryFunctionNameFromPastelToken(tokens.Pop()); } tokens.PopExpected(";"); this.returnTypeInfoForNativeMethods[functionName] = returnType; this.argumentTypeInfoForNativeMethods[functionName] = argTypes.ToArray(); } } }