Make this work with Swift 5.3
This commit is contained in:
parent
b4fbd3a7ee
commit
50992ad03d
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/awk
|
||||
#
|
||||
# Patch the generated wrapper Swift code to handle special cases
|
||||
#
|
||||
BEGIN { property_state = 0; }
|
||||
/var state: PropertyState / { property_state = 1; }
|
||||
/let rv = _ptr.pointee.state/ {
|
||||
if (property_state) {
|
||||
gsub("_ptr.pointee.state", "PropertyState(_ptr.pointee.state)")
|
||||
}
|
||||
}
|
||||
/_ptr.pointee.state = newValue/ {
|
||||
if (property_state) {
|
||||
property_state = 0;
|
||||
gsub("newValue", "newValue.rawValue")
|
||||
}
|
||||
}
|
||||
// {
|
||||
print
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
propertyGet
|
31
Gdk-3.0.sed
31
Gdk-3.0.sed
|
@ -1,10 +1,36 @@
|
|||
s/EVENT_STOP: Bool = 5/EVENT_STOP: gboolean = 1/
|
||||
s/gdk_cursor_ref/g_object_ref/g
|
||||
s/gdk_cursor_unref/g_object_unref/g
|
||||
s/cr: ContextProtocol/cr: cairo.ContextProtocol/
|
||||
s/ContextProtocol>(cr:/Cairo.ContextProtocol>(cr:/
|
||||
s/\(airo.*T: \)\(ContextProtocol\)/\1Cairo.\2/
|
||||
s/\(airo.* -> \)\(ContextRef\)/\1Cairo.\2/
|
||||
s/\(airo.*: \)\(ContextRef\)/\1Cairo.\2/
|
||||
s/\(rv = \)\(ContextRef.*cairo\)/\1Cairo.\2/
|
||||
s/\(rv = \)\(ContextRef.*pango\)/\1Pango.\2/
|
||||
s/\(ango.* -> \)\(ContextRef\)/\1Pango.\2/
|
||||
s/-> ListRef/-> GLib.ListRef/
|
||||
s/: ListRef/: GLib.ListRef/
|
||||
s/createSimilarImageSurface(format: CInt/createSimilarImageSurface(format: cairo_format_t/
|
||||
s/-> GdkAtom {/-> GdkAtom! {/g
|
||||
s/gdk_gl_context_set_use_es(cast(gl_context_ptr), newValue)/gdk_gl_context_set_use_es(cast(gl_context_ptr), newValue ? 1 : 0)/
|
||||
s/: GdkAtom/: GdkAtom!/g
|
||||
s/UnsafeMutablePointer<GdkAtom>/GdkAtom/
|
||||
s/targets: UnsafePointer<GdkAtom>/targets: UnsafePointer<GdkAtom?>/
|
||||
s/GdkAtom!.self/_GdkAtom.self/
|
||||
s/actual_property_type: AtomT/actual_property_type: UnsafeMutablePointer<GdkAtom?>/
|
||||
s/property: GdkAtom!, type: GdkAtom!/property: AtomT!, type: AtomT!/
|
||||
s/property, type/property._ptr, type._ptr/
|
||||
s/propertyGet<WindowT: WindowProtocol>/propertyGet<WindowT: WindowProtocol, AtomT: AtomProtocol>/
|
||||
s/propertyChange<WindowT: WindowProtocol>/propertyChange<WindowT: WindowProtocol, AtomT: AtomProtocol>/
|
||||
s/func propertyChange(property: AtomT/func propertyChange<AtomT: AtomProtocol>(property: AtomT/
|
||||
s/\(propertyGet.*\)window: WindowT, property: AtomT!, type: AtomT!/\1window: WindowT, property: UnsafeMutablePointer<GdkAtom?>, type: AtomT!/
|
||||
s/(gdk_property_get(window.window_ptr, property._ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), _ptr, actual_format, actual_length, data)/(gdk_property_get(window.window_ptr, _ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), property, actual_format, actual_length, data)/
|
||||
s/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propFormat/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, property _ptr: UnsafeMutablePointer<GdkAtom?>, propFormat/
|
||||
s/selectionPropertyGet<AtomT: AtomProtocol>(data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propType prop_type: AtomT, propFormat prop_format: UnsafeMutablePointer<gint>!) -> Int/selectionPropertyGet(data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>, propFormat prop_format: UnsafeMutablePointer<gint>!) -> Int/
|
||||
s/property._ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), actual_property_type._ptr/_ptr, type._ptr, gulong(offset), gulong(length), gint(pdelete), actual_property_type/
|
||||
s/selectionPropertyGet<AtomT: AtomProtocol, WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>.>!, propType prop_type: AtomT/selectionPropertyGet<WindowT: WindowProtocol>(requestor: WindowT, data: UnsafeMutablePointer<UnsafeMutablePointer<guchar>?>!, propertyType: UnsafeMutablePointer<GdkAtom?>!/
|
||||
s/rv = Int(gdk_selection_property_get(requestor.window_ptr, data, prop_type._ptr, prop_format))/rv = Int(gdk_selection_property_get(requestor.window_ptr, data, propertyType, prop_format))/
|
||||
s/Int(gdk_selection_property_get(window_ptr, data, prop_type._ptr, prop_format))/Int(gdk_selection_property_get(window_ptr, data, propertyType, prop_format))/
|
||||
s/gdk_gl_context_set_use_es(gl_context_ptr, gint(newValue))/gdk_gl_context_set_use_es(gl_context_ptr, newValue ? 1 : 0)/
|
||||
s/: \([A-Za-z.]*Notify[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Func[,)]\)/: @escaping \1/g
|
||||
s/: \([A-Za-z.]*Marshal[,)]\)/: @escaping \1/g
|
||||
|
@ -25,3 +51,4 @@ s/public func beep/@available(*, deprecated) public func beep/
|
|||
s/public func errorTrap/@available(*, deprecated) public func errorTrap/
|
||||
s/public func flush/@available(*, deprecated) public func flush/
|
||||
s/public func setDoubleClickTime/@available(*, deprecated) public func setDoubleClickTime/
|
||||
s/_ptr.pointee.state = newValue.value/_ptr.pointee.state = newValue.rawValue/
|
||||
|
|
|
@ -21,9 +21,9 @@ if [ ! -e "${GIR}" ] ; then
|
|||
echo "and can be found in /usr /usr/local or by pkg-config!"
|
||||
exit 1
|
||||
fi
|
||||
gir2swift -p ${GIR_DIR}/GLib-2.0.gir -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/Pango-1.0.gir -p ${GIR_DIR}/cairo-1.0.gir -p ${GIR_DIR}/PangoCairo-1.0.gir -p ${GIR_DIR}/GdkPixbuf-2.0.gir "${GIR}" | sed -f ${Module}.sed > Sources/${Mod}/${Module}.swift
|
||||
gir2swift -p ${GIR_DIR}/GLib-2.0.gir -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/Pango-1.0.gir -p ${GIR_DIR}/cairo-1.0.gir -p ${GIR_DIR}/PangoCairo-1.0.gir -p ${GIR_DIR}/GdkPixbuf-2.0.gir "${GIR}" | sed -f ${Module}.sed | awk -f ${Module}.awk > Sources/${Mod}/${Module}.swift
|
||||
gir2swift -o Sources/${Mod} -m ${Module}.module -p ${GIR_DIR}/GLib-2.0.gir -p ${GIR_DIR}/GObject-2.0.gir -p ${GIR_DIR}/Pango-1.0.gir -p ${GIR_DIR}/cairo-1.0.gir -p ${GIR_DIR}/PangoCairo-1.0.gir -p ${GIR_DIR}/GdkPixbuf-2.0.gir "${GIR}"
|
||||
for src in Sources/${Mod}/*-*.swift ; do
|
||||
sed -f ${Module}.sed < ${src} > ${src}.out
|
||||
sed -f ${Module}.sed < ${src} | awk -f ${Module}.awk > ${src}.out
|
||||
mv ${src}.out ${src}
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue