Skip to content

Commit

Permalink
stop generating quoted code and just generate the code (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith authored Feb 1, 2025
1 parent 0145a34 commit 2bd0d6f
Show file tree
Hide file tree
Showing 48 changed files with 71,477 additions and 71,639 deletions.
8 changes: 4 additions & 4 deletions Adwaita/src/Adwaita.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ using Gtk4.GLib

using libadwaita_jll

eval(include("gen/adw_consts"))
eval(include("gen/adw_structs"))
include("gen/adw_consts")
include("gen/adw_structs")

module G_

Expand All @@ -24,8 +24,8 @@ using Gtk4.Graphene
using Gtk4.GdkPixbufLib
using Gtk4

eval(include("gen/adw_methods"))
eval(include("gen/adw_functions"))
include("gen/adw_methods")
include("gen/adw_functions")

end

Expand Down
35 changes: 16 additions & 19 deletions GI/src/giexport.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ end

function export_consts!(ns,path,prefix,skiplist = Symbol[]; doc_prefix = prefix, doc_xml = nothing, export_constants = true)
toplevel, exprs, exports = GI.output_exprs()

const_mod = Expr(:block)

c = all_const_exprs!(const_mod, exports, ns; skiplist= skiplist, export_constants)
Expand Down Expand Up @@ -183,7 +183,7 @@ function all_struct_exprs!(exprs,exports,ns;print_summary=true,excludelist=[],co
end
push!(exprs,unblock(gboxed_types_init))
end

if print_summary
printstyled("Generated ",imported," structs out of ",length(ss),"\n";color=:green)
end
Expand All @@ -196,13 +196,13 @@ function all_callbacks!(exprs, exports, ns; callback_skiplist = [])
for c in callbacks
get_name(c) in callback_skiplist && continue
try
push!(exprs, decl(c))
catch e
if isa(e, NotImplementedError)
continue
else
rethrow(e)
end
push!(exprs, decl(c))
catch e
if isa(e, NotImplementedError)
continue
else
rethrow(e)
end
end
push!(exports.args, get_full_name(c))
end
Expand Down Expand Up @@ -444,7 +444,7 @@ function export_methods!(ns,path,prefix;struct_method_skiplist = Symbol[], objec
all_struct_methods!(exprs,ns, struct_skiplist = struct_skiplist, skiplist = struct_method_skiplist, exclude_deprecated = exclude_deprecated)
all_object_methods!(exprs,ns; skiplist = object_method_skiplist, object_skiplist = object_skiplist, exclude_deprecated = exclude_deprecated, interface_helpers)
all_interface_methods!(exprs,ns; skiplist = interface_method_skiplist, interface_skiplist = interface_skiplist, exclude_deprecated = exclude_deprecated)

write_to_file(path,"$(prefix)_methods",toplevel)
end

Expand Down Expand Up @@ -529,24 +529,21 @@ function export_functions!(ns,path,prefix;skiplist = Symbol[], exclude_deprecate
write_to_file(path,"$(prefix)_functions",toplevel)
end

function write_to_file(filename,toplevel)
function write_to_file(filename,block)
open(filename,"w") do f
Base.println(f,"quote")
Base.remove_linenums!(toplevel)
Base.show_unquoted(f, toplevel)
Base.remove_linenums!(block)
Base.show_unquoted(f, block)
println(f)
Base.println(f,"end")
end
end

write_to_file(path,filename,toplevel)=write_to_file(joinpath(path,filename),toplevel)

function output_exprs()
body = Expr(:block)
toplevel = Expr(:toplevel, body)
exprs = body.args
block = Expr(:block)
exprs = block.args
exports = Expr(:export)
toplevel, exprs, exports
block, exprs, exports
end

# Read from XML
Expand Down
20 changes: 10 additions & 10 deletions src/GLib/GLib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ end
include("glist.jl")
include("gtype.jl")

eval(include("../gen/glib_consts"))
include("../gen/glib_consts")

const lib_version = VersionNumber(
MAJOR_VERSION,
Expand All @@ -160,7 +160,7 @@ const lib_version = VersionNumber(

include("gvalues.jl")

eval(include("../gen/glib_structs"))
include("../gen/glib_structs")

include("gvariant.jl")
include("gerror.jl")
Expand All @@ -169,8 +169,8 @@ include("hashtable.jl")

include("signals.jl")

eval(include("../gen/gobject_structs"))
eval(include("../gen/gio_structs"))
include("../gen/gobject_structs")
include("../gen/gio_structs")

module G_

Expand All @@ -181,12 +181,12 @@ using ..GLib: BookmarkFileError, ChecksumType, ConvertError, DateDMY, DateMonth,

import Base: convert, copy, run

eval(include("../gen/glib_methods"))
eval(include("../gen/glib_functions"))
eval(include("../gen/gobject_methods"))
eval(include("../gen/gobject_functions"))
eval(include("../gen/gio_methods"))
eval(include("../gen/gio_functions"))
include("../gen/glib_methods")
include("../gen/glib_functions")
include("../gen/gobject_methods")
include("../gen/gobject_functions")
include("../gen/gio_methods")
include("../gen/gio_functions")

end

Expand Down
10 changes: 5 additions & 5 deletions src/GdkPixbufLib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export width, height, slice

const Index{I<:Integer} = Union{I, AbstractVector{I}}

eval(include("gen/gdkpixbuf_consts"))
eval(include("gen/gdkpixbuf_structs"))
include("gen/gdkpixbuf_consts")
include("gen/gdkpixbuf_structs")

module G_

Expand All @@ -32,8 +32,8 @@ using ..GdkPixbufLib: Colorspace, InterpType, PixbufError, PixbufRotation

import Base: convert, copy

eval(include("gen/gdkpixbuf_methods"))
eval(include("gen/gdkpixbuf_functions"))
include("gen/gdkpixbuf_methods")
include("gen/gdkpixbuf_functions")

end

Expand Down Expand Up @@ -83,7 +83,7 @@ end
convert(::Type{RGBA}, x::Unsigned) = RGBA(UInt8(x), UInt8(x >> 8), UInt8(x >> 16), UInt8(x >> 24))
convert(::Type{U}, x::RGBA) where {U <: Unsigned} = convert(U, (x.r) | (x.g >> 8) | (x.b >> 16) | (x.a >> 24))
function convert(::Type{RGBA}, x::Colorant)
c = ColorTypes.RGBA{N0f8}(x)
c = ColorTypes.RGBA{N0f8}(x)
RGBA(reinterpret(UInt8,red(c)),reinterpret(UInt8,green(c)),reinterpret(UInt8,blue(c)),reinterpret(UInt8,alpha(c)))
end

Expand Down
8 changes: 4 additions & 4 deletions src/Graphene.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Base: convert, length, getindex, iterate, unsafe_convert

import CEnum: @cenum, CEnum

eval(include("gen/graphene_consts"))
eval(include("gen/graphene_structs"))
include("gen/graphene_consts")
include("gen/graphene_structs")

export _GrapheneRect, _GraphenePoint, _GrapheneMatrix, _GrapheneVec4, _GrapheneVec3, _GrapheneSize, _GraphenePoint3D

Expand All @@ -19,8 +19,8 @@ using Graphene_jll
using ..GLib
using ..Graphene

eval(include("gen/graphene_methods"))
#eval(include("gen/graphene_functions"))
include("gen/graphene_methods")
#include("gen/graphene_functions")

end

Expand Down
30 changes: 15 additions & 15 deletions src/Gtk4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ using Reexport
import .Graphics: width, height, getgc, scale, center, clip
import Cairo: destroy, text, status

eval(include("gen/gdk4_consts"))
eval(include("gen/gdk4_structs"))
eval(include("gen/gsk4_consts"))
eval(include("gen/gsk4_structs"))
eval(include("gen/gtk4_consts"))
eval(include("gen/gtk4_structs"))
include("gen/gdk4_consts")
include("gen/gdk4_structs")
include("gen/gsk4_consts")
include("gen/gsk4_structs")
include("gen/gtk4_consts")
include("gen/gtk4_structs")

const ModifierType_NONE = ModifierType_NO_MODIFIER_MASK

Expand All @@ -54,12 +54,12 @@ using ..Gtk4

using ..Gtk4: BlendMode, Corner, FillRule, GLUniformType, LineCap, LineJoin, MaskMode, PathDirection, PathOperation, RenderNodeType, ScalingFilter, SerializationError, TransformCategory, PathForeachFlags, AxisUse, CrossingMode, DevicePadFeature, DeviceToolType, DmabufError, DragCancelReason, EventType, FullscreenMode, GLError, Gravity, InputSource, KeyMatch, MemoryFormat, NotifyType, ScrollDirection, ScrollUnit, SubpixelLayout, SurfaceEdge, TextureError, TitlebarGesture, TouchpadGesturePhase, VulkanError, AnchorHints, AxisFlags, DragAction, FrameClockPhase, GLAPI, ModifierType, PaintableFlags, SeatCapabilities, ToplevelState, AccessibleAnnouncementPriority, AccessibleAutocomplete, AccessibleInvalidState, AccessiblePlatformState, AccessibleProperty, AccessibleRelation, AccessibleRole, AccessibleSort, AccessibleState, AccessibleTextContentChange, AccessibleTextGranularity, AccessibleTristate, Align, ArrowType, AssistantPageType, BaselinePosition, BorderStyle, BuilderError, ButtonsType, CellRendererAccelMode, CellRendererMode, Collation, ConstraintAttribute, ConstraintRelation, ConstraintStrength, ConstraintVflParserError, ContentFit, CornerType, CssParserError, CssParserWarning, DeleteType, DialogError, DirectionType, EditableProperties, EntryIconPosition, EventSequenceState, FileChooserAction, FileChooserError, FilterChange, FilterMatch, FontLevel, GraphicsOffloadEnabled, IconSize, IconThemeError, IconViewDropPosition, ImageType, InputPurpose, InscriptionOverflow, Justification, LevelBarMode, License, ListTabBehavior, MessageType, MovementStep, NaturalWrapMode, NotebookTab, NumberUpLayout, Ordering, Orientation, Overflow, PackType, PadActionType, PageOrientation, PageSet, PanDirection, PolicyType, PositionType, PrintDuplex, PrintError, PrintOperationAction, PrintOperationResult, PrintPages, PrintQuality, PrintStatus, PropagationLimit, PropagationPhase, RecentManagerError, ResponseType, RevealerTransitionType, ScrollStep, ScrollType, ScrollablePolicy, SelectionMode, SensitivityType, ShortcutScope, ShortcutType, SizeGroupMode, SizeRequestMode, SortType, SorterChange, SorterOrder, SpinButtonUpdatePolicy, SpinType, StackTransitionType, StringFilterMatchMode, SymbolicColor, SystemSetting, TextDirection, TextExtendSelection, TextViewLayer, TextWindowType, TreeViewColumnSizing, TreeViewDropPosition, TreeViewGridLines, Unit, WrapMode, ApplicationInhibitFlags, BuilderClosureFlags, CellRendererState, DebugFlags, DialogFlags, EventControllerScrollFlags, FontChooserLevel, IconLookupFlags, InputHints, ListScrollFlags, PickFlags, PopoverMenuFlags, PrintCapabilities, ShortcutActionFlags, StateFlags, StyleContextPrintFlags, TextSearchFlags

eval(include("gen/gdk4_methods"))
eval(include("gen/gdk4_functions"))
eval(include("gen/gsk4_methods"))
eval(include("gen/gsk4_functions"))
eval(include("gen/gtk4_methods"))
eval(include("gen/gtk4_functions"))
include("gen/gdk4_methods")
include("gen/gdk4_functions")
include("gen/gsk4_methods")
include("gen/gsk4_functions")
include("gen/gtk4_methods")
include("gen/gtk4_functions")

function get_current_event_state(instance::GtkEventController)
ret = ccall(("gtk_event_controller_get_current_event_state", libgtk4), UInt32, (Ptr{GObject},), instance)
Expand Down Expand Up @@ -138,9 +138,9 @@ end

function __init__()
in("Gtk",[x.name for x in keys(Base.loaded_modules)]) && error("Gtk4 is incompatible with Gtk.")

if VERSION >= v"1.11" && isinteractive()
if (Threads.nthreads(:default) > 1 && Threads.nthreads(:interactive) == 0) ||
if (Threads.nthreads(:default) > 1 && Threads.nthreads(:interactive) == 0) ||
Threads.nthreads(:interactive) > 1
@warn("Gtk4 may freeze the REPL if there is more than one thread in its thread pool. Please set JULIA_NUM_THREADS to N,1 (for N default threads) and restart Julia.")
end
Expand All @@ -164,7 +164,7 @@ function __init__()
# Help GTK find modules for printing, media, and input backends
# May have consequences for GTK3 programs spawned by Julia
ENV["GTK_PATH"] = joinpath(dirname(GTK4_jll.libgtk4_path::String),"gtk-4.0")

# Following also works for finding the printing backends (and also may affect GTK3 programs)
#ENV["GTK_EXE_PREFIX"] = GTK4_jll.artifact_dir
end
Expand Down
6 changes: 3 additions & 3 deletions src/Pango/Cairo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Base: convert, unsafe_convert
import CEnum: @cenum, CEnum
import BitFlags: @bitflag

eval(include("../gen/cairo_consts"))
eval(include("../gen/cairo_structs"))
eval(include("../gen/cairo_functions"))
include("../gen/cairo_consts")
include("../gen/cairo_structs")
include("../gen/cairo_functions")

end
14 changes: 7 additions & 7 deletions src/Pango/Pango.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import Base: convert, length, getindex, iterate, unsafe_convert
import CEnum: @cenum, CEnum
import BitFlags: @bitflag

eval(include("../gen/pango_consts"))
eval(include("../gen/pango_structs"))
include("../gen/pango_consts")
include("../gen/pango_structs")

include("Cairo.jl")

eval(include("../gen/pangocairo_structs"))
include("../gen/pangocairo_structs")

using .Cairo

Expand All @@ -28,11 +28,11 @@ using ..Pango
using ..Pango: Alignment, AttrType, BaselineShift, CoverageLevel, Direction, EllipsizeMode, FontScale, Gravity, GravityHint, LayoutDeserializeError, Overline, RenderPart, Script, Stretch, Style, TabAlign, TextTransform, Underline, Variant, Weight, WrapMode, FontMask, LayoutDeserializeFlags, LayoutSerializeFlags, ShapeFlags, ShowFlags
using ..Pango.Cairo

eval(include("../gen/pango_methods"))
eval(include("../gen/pango_functions"))
include("../gen/pango_methods")
include("../gen/pango_functions")

eval(include("../gen/pangocairo_methods"))
eval(include("../gen/pangocairo_functions"))
include("../gen/pangocairo_methods")
include("../gen/pangocairo_functions")

end

Expand Down
Loading

0 comments on commit 2bd0d6f

Please sign in to comment.