Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

generator: Overhaul GInterface type naming approach #113

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions atk/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ sources = \
Hyperlink.cs \
Misc.cs \
Object.cs \
SelectionAdapter.cs \
TextAdapter.cs \
Selection.cs \
Text.cs \
TextChangedDetail.cs \
Util.cs

Expand Down
4 changes: 2 additions & 2 deletions atk/SelectionAdapter.cs → atk/Selection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
Expand All @@ -22,7 +22,7 @@
// Boston, MA 02111-1307, USA.

namespace Atk {
public partial class SelectionAdapter {
public partial class Selection {

public void EmitSelectionChanged ()
{
Expand Down
4 changes: 2 additions & 2 deletions atk/TextAdapter.cs → atk/Text.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the Lesser GNU General
// modify it under the terms of version 2 of the Lesser GNU General
// Public License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
Expand All @@ -22,7 +22,7 @@
// Boston, MA 02111-1307, USA.

namespace Atk {
public partial class TextAdapter {
public partial class Text {

public void EmitTextChanged (TextChangedDetail detail, int position, int length)
{
Expand Down
8 changes: 4 additions & 4 deletions generator/InterfaceGen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public bool IsConsumeOnly {

public string AdapterName {
get {
return base.Name + "Adapter";
return base.Name;
}
}

Expand All @@ -75,13 +75,13 @@ public string QualifiedAdapterName {

public string ImplementorName {
get {
return Name + "Implementor";
return "I" + base.Name;
}
}

public override string Name {
get {
return "I" + base.Name;
return "I" + base.Name + "Base";
}
}

Expand Down Expand Up @@ -258,7 +258,7 @@ void GenerateGetObject (StreamWriter sw)

void GenerateImplementorProp (StreamWriter sw)
{
sw.WriteLine ("\t\tpublic " + ImplementorName + " Implementor {");
sw.WriteLine ("\t\tpublic " + ImplementorName + " VirtualImplementor {");
sw.WriteLine ("\t\t\tget {");
sw.WriteLine ("\t\t\t\treturn implementor as {0};", ImplementorName);
sw.WriteLine ("\t\t\t}");
Expand Down
9 changes: 4 additions & 5 deletions gio/AppInfoAdapter.cs → gio/AppInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
namespace GLib {
using System;
using System.Runtime.InteropServices;
public partial class AppInfoAdapter {

public partial class AppInfo {
[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_app_info_get_all();

public static GLib.IAppInfo[] GetAll () {
public static GLib.IAppInfoBase[] GetAll () {
IntPtr raw_ret = g_app_info_get_all();
GLib.IAppInfo[] ret = (GLib.IAppInfo[]) GLib.Marshaller.ListPtrToArray (raw_ret, typeof (GLib.List), true, false, typeof (GLib.IAppInfo));
return ret;
return (GLib.IAppInfoBase[]) GLib.Marshaller.ListPtrToArray (raw_ret, typeof (GLib.List), true, false, typeof (GLib.IAppInfoBase));
}
}
}
12 changes: 6 additions & 6 deletions gio/FileAdapter.cs → gio/File.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@
namespace GLib {
using System;
using System.Runtime.InteropServices;
public partial class FileAdapter {

public partial class File {
public override string ToString ()
{
return Uri.ToString ();
}

public bool Exists {
get { return QueryExists (null); }
}

public bool Delete ()
{
return Delete (null);
}

[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_file_get_uri(IntPtr raw);

public System.Uri Uri {
get {
IntPtr raw_ret = g_file_get_uri(Handle);
Expand Down
16 changes: 8 additions & 8 deletions gio/FileFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,30 @@ public class FileFactory
[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr g_file_new_for_uri (string uri);

public static IFile NewForUri (string uri)
public static IFileBase NewForUri (string uri)
{
return GLib.FileAdapter.GetObject (g_file_new_for_uri (uri), false) as IFile;
return GLib.File.GetObject (g_file_new_for_uri (uri), false) as IFileBase;
}

public static IFile NewForUri (Uri uri)
public static IFileBase NewForUri (Uri uri)
{
return GLib.FileAdapter.GetObject (g_file_new_for_uri (uri.ToString ()), false) as IFile;
return GLib.File.GetObject (g_file_new_for_uri (uri.ToString ()), false) as IFileBase;
}

[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr g_file_new_for_path (string path);

public static IFile NewForPath (string path)
public static IFileBase NewForPath (string path)
{
return GLib.FileAdapter.GetObject (g_file_new_for_path (path), false) as IFile;
return GLib.File.GetObject (g_file_new_for_path (path), false) as IFileBase;
}

[DllImport ("libgio-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern IntPtr g_file_new_for_commandline_arg (string arg);

public static IFile NewFromCommandlineArg (string arg)
public static IFileBase NewFromCommandlineArg (string arg)
{
return GLib.FileAdapter.GetObject (g_file_new_for_commandline_arg (arg), false) as IFile;
return GLib.File.GetObject (g_file_new_for_commandline_arg (arg), false) as IFileBase;
}
}
}
12 changes: 6 additions & 6 deletions gio/GioStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ public GioStream (InputStream stream)
{
this.stream = stream;
can_read = true;
can_seek = stream is ISeekable && (stream as ISeekable).CanSeek;
can_seek = stream is ISeekableBase && (stream as ISeekableBase).CanSeek;
}

public GioStream (OutputStream stream)
{
this.stream = stream;
can_write = true;
can_seek = stream is ISeekable && (stream as ISeekable).CanSeek;
can_seek = stream is ISeekableBase && (stream as ISeekableBase).CanSeek;
}

public GioStream (IOStream stream)
{
this.stream = stream;
can_read = true;
can_write = true;
can_seek = stream is ISeekable && (stream as ISeekable).CanSeek;
can_seek = stream is ISeekableBase && (stream as ISeekableBase).CanSeek;
}

public override bool CanSeek {
Expand Down Expand Up @@ -112,7 +112,7 @@ public override long Position {
throw new NotSupportedException ("This stream doesn't support seeking");
if (is_disposed)
throw new ObjectDisposedException ("The stream is closed");
return (stream as ISeekable).Position;
return (stream as ISeekableBase).Position;
}
set {
Seek (value, System.IO.SeekOrigin.Begin);
Expand Down Expand Up @@ -195,7 +195,7 @@ public override long Seek (long offset, System.IO.SeekOrigin origin)
throw new NotSupportedException ("This stream doesn't support seeking");
if (is_disposed)
throw new ObjectDisposedException ("The stream is closed");
var seekable = stream as ISeekable;
var seekable = stream as ISeekableBase;

SeekType seek_type;
switch (origin) {
Expand All @@ -219,7 +219,7 @@ public override void SetLength (long value)
if (!CanSeek || !CanWrite)
throw new NotSupportedException ("This stream doesn't support seeking");

var seekable = stream as ISeekable;
var seekable = stream as ISeekableBase;

if (!seekable.CanTruncate ())
throw new NotSupportedException ("This stream doesn't support truncating");
Expand Down
6 changes: 3 additions & 3 deletions gio/IFile.cs → gio/IFileBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
// Boston, MA 02111-1307, USA.

namespace GLib {
public partial interface IFile : GLib.IWrapper {
public partial interface IFileBase : GLib.IWrapper {
bool Exists
{
get;
}

System.Uri Uri
{
get;
}

bool Delete();
}
}
6 changes: 3 additions & 3 deletions gio/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ glue_includes = gio/gio.h
POLICY_VERSIONS=

sources = \
AppInfoAdapter.cs \
FileAdapter.cs \
AppInfo.cs \
File.cs \
FileEnumerator.cs \
FileFactory.cs \
GioStream.cs \
IFile.cs
IFileBase.cs

add_dist = gio-sharp-3.0.pc.in

Expand Down
2 changes: 1 addition & 1 deletion gtk/CellLayoutAdapter.cs → gtk/CellLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Gtk {

using System;

public partial class CellLayoutAdapter {
public partial class CellLayout {

public void SetAttributes (CellRenderer cell, params object[] attrs)
{
Expand Down
2 changes: 1 addition & 1 deletion gtk/ITreeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Gtk {

using System;

public partial interface ITreeModel {
public partial interface ITreeModelBase {

/// <summary>IterChildren Method</summary>
/// <remarks>To be completed</remarks>
Expand Down
4 changes: 2 additions & 2 deletions gtk/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sources = \
Button.cs \
Calendar.cs \
CellAreaBox.cs \
CellLayoutAdapter.cs \
CellLayout.cs \
CellRenderer.cs \
CellView.cs \
CheckMenuItem.cs \
Expand Down Expand Up @@ -99,7 +99,7 @@ sources = \
TreeEnumerator.cs \
TreeIter.cs \
TreeMenu.cs \
TreeModelAdapter.cs \
TreeModel.cs \
TreeModelFilter.cs \
TreeModelSort.cs \
TreeNode.cs \
Expand Down
14 changes: 7 additions & 7 deletions gtk/NodeStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public NodeStore (Type node_type)
implementor = new NodeStoreImplementor (node_type);
}

internal TreeModelAdapter Adapter {
get { return new TreeModelAdapter (implementor); }
internal TreeModel Adapter {
get { return new TreeModel (implementor); }
}

internal TreeIter GetIter (ITreeNode node)
Expand Down Expand Up @@ -81,8 +81,8 @@ public IEnumerator GetEnumerator ()
return implementor.GetEnumerator ();
}

internal class NodeStoreImplementor : GLib.Object, ITreeModelImplementor, IEnumerable {
TreeModelAdapter model_adapter;
internal class NodeStoreImplementor : GLib.Object, ITreeModel, IEnumerable {
TreeModel model_adapter;
GLib.GType[] ctypes;
MemberInfo [] getters;
int n_cols;
Expand All @@ -99,7 +99,7 @@ public NodeStoreImplementor (Type node_type)

ScanType (node_type);

model_adapter = new Gtk.TreeModelAdapter (this);
model_adapter = new Gtk.TreeModel (this);
}

void ScanType (Type type)
Expand Down Expand Up @@ -239,8 +239,8 @@ public ITreeNode GetNode (TreeIter iter)
return gch.Target as ITreeNode;
}

void ITreeModelImplementor.RefNode (Gtk.TreeIter iter) { }
void ITreeModelImplementor.UnrefNode (Gtk.TreeIter iter) { }
void ITreeModel.RefNode (Gtk.TreeIter iter) { }
void ITreeModel.UnrefNode (Gtk.TreeIter iter) { }
#endregion

public bool GetIter (out TreeIter iter, TreePath path)
Expand Down
4 changes: 2 additions & 2 deletions gtk/TreeEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ namespace Gtk
internal class TreeEnumerator : IEnumerator
{
private Gtk.TreeIter iter;
private Gtk.ITreeModel model;
private Gtk.ITreeModelBase model;
private bool reset = true;
private bool changed = false;

public TreeEnumerator (ITreeModel model)
public TreeEnumerator (ITreeModelBase model)
{
this.model = model;

Expand Down
4 changes: 2 additions & 2 deletions gtk/TreeModelAdapter.cs → gtk/TreeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Gtk {
using System;
using System.Runtime.InteropServices;

public partial class TreeModelAdapter {
public partial class TreeModel {

[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
static extern bool gtk_tree_model_iter_children (IntPtr raw, out Gtk.TreeIter iter, IntPtr parent);
Expand Down Expand Up @@ -70,7 +70,7 @@ public void SetValue (Gtk.TreeIter iter, int column, float value) {
public void SetValue (Gtk.TreeIter iter, int column, uint value) {
throw new NotImplementedException ();
}

public void SetValue (Gtk.TreeIter iter, int column, object value) {
throw new NotImplementedException ();
}
Expand Down
2 changes: 1 addition & 1 deletion sample/CustomScrollableWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public DerivedScrollableWidget (string label) : base (label)
{ }
}

class CustomScrollableWidget<T> : CustomBase, IScrollableImplementor {
class CustomScrollableWidget<T> : CustomBase, IScrollable {
private int num_rows = 20;
private string label;
private Pango.Layout layout;
Expand Down
2 changes: 1 addition & 1 deletion sample/GtkDemo/DemoEditableCells.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void AddItem (object o, EventArgs args)
private void RemoveItem (object o, EventArgs args)
{
TreeIter iter;
ITreeModel model;
ITreeModelBase model;

if (treeView.Selection.GetSelected (out model, out iter)) {
int position = store.GetPath (iter).Indices[0];
Expand Down
2 changes: 1 addition & 1 deletion sample/GtkDemo/DemoEntryCompletion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public DemoEntryCompletion () : base ("Demo Entry Completion", null, DialogFlags
Destroy ();
}

ITreeModel CreateCompletionModel ()
ITreeModelBase CreateCompletionModel ()
{
ListStore store = new ListStore (typeof (string));

Expand Down
Loading