-- Create declarations for synthesis. -- Copyright (C) 2017 Tristan Gingold -- -- This file is part of GHDL. -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . with Types; use Types; with Files_Map; with Name_Table; with Grt.Types; use Grt.Types; with Grt.Files_Operations; use Grt.Files_Operations; with Grt.Stdio; with Synth.Memtype; use Synth.Memtype; with Synth.Objtypes; use Synth.Objtypes; with Synth.Vhdl_Expr; use Synth.Vhdl_Expr; with Synth.Errors; use Synth.Errors; package body Synth.Vhdl_Files is -- Variables to store the search path. Current_Unit : Node := Null_Node; Current_Pfx_Len : Integer := -1; Current_Pfx_Id : Name_Id := No_Name_Id; -- Representation of file name compatible with C (so NUL terminated). subtype C_File_Name is String (1 .. 1025); procedure File_Error (Loc : Node; Status : Op_Status); pragma No_Return (File_Error); procedure File_Error (Loc : Node; Status : Op_Status) is begin pragma Assert (Status /= Op_Ok); Error_Msg_Synth (+Loc, "file operation failed"); raise File_Execution_Error; end File_Error; -- VAL represents a string, so an array of characters. procedure Convert_String (Val : Valtyp; Res : out String) is Vtyp : constant Type_Acc := Val.Typ; Vlen : constant Uns32 := Vtyp.Abounds.D (1).Len; begin pragma Assert (Vtyp.Kind = Type_Array); pragma Assert (Vtyp.Arr_El.Kind = Type_Discrete); pragma Assert (Vtyp.Arr_El.W in 7 .. 8); -- Could be 7 in vhdl87 pragma Assert (Vtyp.Abounds.Ndim = 1); pragma Assert (Vtyp.Abounds.D (1).Len = Res'Length); for I in 1 .. Vlen loop Res (Res'First + Natural (I - 1)) := Character'Val (Read_U8 (Val.Val.Mem + Size_Type (I - 1))); end loop; end Convert_String; -- Convert filename VAL to RES + LEN. procedure Convert_File_Name (Val : Valtyp; Res : out C_File_Name; Len : out Natural; Status : out Op_Status) is Name : constant Valtyp := Strip_Alias_Const (Val); pragma Unreferenced (Val); begin Len := Natural (Name.Typ.Abounds.D (1).Len); if Len >= Res'Length - 1 then Status := Op_Filename_Error; return; end if; Convert_String (Name, Res (1 .. Len)); Res (Len + 1) := Grt.Types.NUL; Status := Op_Ok; end Convert_File_Name; procedure Set_Design_Unit (Unit : Node) is begin Current_Unit := Unit; Current_Pfx_Id := No_Name_Id; end Set_Design_Unit; function Synth_Open (Name : Ghdl_C_String; Mode : Ghdl_C_String) return Grt.Stdio.FILEs is use Grt.Stdio; Res : FILEs; begin -- Try to open the file using the name given. Res := fopen (To_Address (Name), To_Address (Mode)); if Res /= NULL_Stream then -- File found. return Res; end if; -- Return now if the search path is not used: -- mode is not read, or -- no search path given. if Mode (1) /= 'r' then return Res; end if; if Current_Unit = Null_Node then return NULL_Stream; end if; -- The search path is given by the cu
// dear imgui: Platform Binding for OSX / Cocoa
// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..)
// [BETA] Beta bindings, not well tested. If you want a portable application, prefer using the Glfw or SDL platform bindings on Mac.

// Issues:
// [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters]..
// [ ] Platform: Mouse cursor shapes and visibility are not supported (see end of https://github.com/glfw/glfw/issues/427)

@class NSEvent;
@class NSView;

IMGUI_API bool        ImGui_ImplOSX_Init();
IMGUI_API void        ImGui_ImplOSX_Shutdown();
IMGUI_API void        ImGui_ImplOSX_NewFrame(NSView *_Nonnull view);
IMGUI_API bool        ImGui_ImplOSX_HandleEvent(NSEvent *_Nonnull event, NSView *_Nullable view);
Value (Syn_Inst, Param2); Param3 : constant Node := Get_Chain (Param2); Param_Len : constant Valtyp := Get_Value (Syn_Inst, Param3); Buf : String (1 .. Natural (Str.Typ.Abounds.D (1).Len)); Len : Std_Integer; Status : Op_Status; begin Len := Std_Integer (Buf'Last); Ghdl_Untruncated_Text_Read (File, To_Ghdl_C_String (Buf'Address), Len, Status); if Status /= Op_Ok then File_Error (Loc, Status); end if; for I in 1 .. Natural (Len) loop Write_U8 (Str.Val.Mem + Size_Type (I - 1), Character'Pos (Buf (I))); end loop; Write_Discrete (Param_Len, Int64 (Len)); end Synth_Untruncated_Text_Read; procedure File_Read_Value (File : File_Index; Val : Memtyp; Loc : Node) is Status : Op_Status; begin case Val.Typ.Kind is when Type_Discrete | Type_Bit | Type_Logic | Type_Float => Ghdl_Read_Scalar (File, Ghdl_Ptr (Val.Mem.all'Address), Ghdl_Index_Type (Val.Typ.Sz), Status); if Status /= Op_Ok then File_Error (Loc, Status); end if; when Type_Vector | Type_Array => declare El_Typ : constant Type_Acc := Get_Array_Element (Val.Typ); Off : Size_Type; begin Off := 0; for I in 1 .. Get_Array_Flat_Length (Val.Typ) loop File_Read_Value (File, (El_Typ, Val.Mem + Off), Loc); Off := Off + El_Typ.Sz; end loop; end; when Type_Record => for I in Val.Typ.Rec.E'Range loop File_Read_Value (File, (Val.Typ.Rec.E (I).Typ, Val.Mem + Val.Typ.Rec.E (I).Moff), Loc); end loop; when Type_Unbounded_Record | Type_Unbounded_Array | Type_Unbounded_Vector | Type_Protected | Type_Slice | Type_File | Type_Access => raise Internal_Error; end case; end File_Read_Value; procedure Synth_File_Read (Syn_Inst : Synth_Instance_Acc; Imp : Node; Loc : Node) is Inters : constant Node := Get_Interface_Declaration_Chain (Imp); File : constant File_Index := Get_Value (Syn_Inst, Inters).Val.File; Param2 : constant Node := Get_Chain (Inters); Value : constant Valtyp := Get_Value (Syn_Inst, Param2); begin File_Read_Value (File, (Value.Typ, Value.Val.Mem), Loc); end Synth_File_Read; end Synth.Vhdl_Files;