Skip to content
This repository has been archived by the owner on May 25, 2020. It is now read-only.

Binding fixes #24

Open
wants to merge 6 commits into
base: master
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
3 changes: 2 additions & 1 deletion src/bin/eolian_mono/eolian/mono/klass.hh
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ struct klass
<< scope_tab << scope_tab << name_helpers::klass_get_name(cls) << "();\n"
<< scope_tab << "/// <summary>Initializes a new instance of the <see cref=\"" << interface_name << "\"/> class.\n"
<< scope_tab << "/// Internal usage: This is used when interacting with C code and should not be used directly.</summary>\n"
<< scope_tab << "/// <param name=\"wh\">The native pointer to be wrapped.</param>\n"
<< scope_tab << "private " << concrete_name << "(Efl.Eo.Globals.WrappingHandle wh) : base(wh)\n"
<< scope_tab << "{\n"
<< scope_tab << "}\n\n"
Expand Down Expand Up @@ -510,7 +511,7 @@ struct klass
<< scope_tab << "}\n\n"
<< scope_tab << "/// <summary>Initializes a new instance of the <see cref=\"" << inherit_name << "\"/> class.\n"
<< scope_tab << "/// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.</summary>\n"
<< scope_tab << "/// <param name=\"raw\">The native pointer to be wrapped.</param>\n"
<< scope_tab << "/// <param name=\"wh\">The native pointer to be wrapped.</param>\n"
<< scope_tab << "protected " << inherit_name << "(Efl.Eo.Globals.WrappingHandle wh) : base(wh)\n"
<< scope_tab << "{\n"
<< scope_tab << "}\n\n"
Expand Down
10 changes: 10 additions & 0 deletions src/bin/eolian_mono/eolian/mono/type_impl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,16 @@ struct visitor_generate
return c;
}
}
, {"slice", nullptr, nullptr, [&]
{
return regular_type_def{" Eina.Slice", complex.outer.base_qualifier, {}};
}
}
, {"rw_slice", nullptr, nullptr, [&]
{
return regular_type_def{" Eina.RwSlice", complex.outer.base_qualifier, {}};
}
}
};

auto default_match = [&] (attributes::complex_type_def const& complex)
Expand Down
68 changes: 34 additions & 34 deletions src/bindings/mono/eina_mono/eina_stringshare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,29 @@ public static partial class NativeMethods
/// </remarks>
public class Stringshare : IEquatable<Stringshare>, IEquatable<string>
{
/// <sumary>
/// <summary>
/// Main constructor. Wrap the given string.
/// Have private acess to avoid wrapping a null reference,
/// use convertion or the factory method to create a new instance.
/// <see cref="Stringshare.Create(string s)"/>
/// <see cref="Stringshare.operator Stringshare(string s)"/>
/// </sumary>
/// <see cref="Create(string)"/>
/// <see cref="implicit operator Stringshare(string)"/>
/// </summary>
private Stringshare(string s)
{
Str = s;
}

/// <sumary>
/// <summary>
/// Auto-implemented property that holds the wrapped string value.
/// </sumary>
/// </summary>
public string Str { get; private set; }

/// <sumary>
/// <summary>
/// Factory method to instantiate a new object.
/// Get a wrappper for the given string or a null reference if the given
/// string reference is also null.
/// <seealso cref="Stringshare.operator Stringshare(string s)"/>
/// </sumary>
/// <seealso cref="implicit operator Stringshare(string)"/>
/// </summary>
/// <returns>
/// A new instance wrapping the given string, or a null reference if
/// the given string reference is also null.
Expand All @@ -84,9 +84,9 @@ public static Stringshare Create(string s)
return new Stringshare(s);
}

/// <sumary>
/// <summary>
/// Implicit convertion to string.
/// </sumary>
/// </summary>
public static implicit operator string(Stringshare ss)
{
if (ReferenceEquals(null, ss))
Expand All @@ -97,13 +97,13 @@ public static implicit operator string(Stringshare ss)
return ss.Str;
}

/// <sumary>
/// <summary>
/// Implicit convertion from string to Stringshare.
/// </sumary>
/// </summary>
/// <remarks>
/// Note that this method can be used to create an instance of this class,
/// either via an explicit cast or an implicit convertion.
/// <seealso cref="Stringshare.Create(string s)"/>
/// <seealso cref="Create(string)"/>
/// </remarks>
public static implicit operator Stringshare(string s)
{
Expand All @@ -115,9 +115,9 @@ public static implicit operator Stringshare(string s)
return new Stringshare(s);
}

/// <sumary>
/// <summary>
/// Check two Stringshare objects for equality.
/// </sumary>
/// </summary>
/// <returns>
/// True if both wrapped strings have the same content or if both
/// references are null, false otherwise.
Expand All @@ -128,9 +128,9 @@ public static implicit operator Stringshare(string s)
}


/// <sumary>
/// <summary>
/// Check two Stringshare objects for inequality.
/// </sumary>
/// </summary>
/// <returns>
/// True if the wrapped strings have different content or if one reference is null
/// and the other is not, false otherwise.
Expand All @@ -140,20 +140,20 @@ public static implicit operator Stringshare(string s)
return !(ss1 == ss2);
}

/// <sumary>
/// <summary>
/// Returns the wrapped string.
/// <seealso cref="Stringshare.Str"/>
/// <seealso cref="Stringshare.Get()"/>
/// </sumary>
/// <seealso cref="Str"/>
/// <seealso cref="Get()"/>
/// </summary>
/// <returns>The wrapped string. Same as the property Str.</returns>
public override string ToString()
{
return Str;
}

/// <sumary>
/// <summary>
/// Override of GetHashCode for consistency with user-defined equality methods.
/// </sumary>
/// </summary>
/// <returns>
/// The wrapped string hash code.
/// </returns>
Expand All @@ -162,9 +162,9 @@ public override int GetHashCode()
return Str.GetHashCode();
}

/// <sumary>
/// <summary>
/// Check the given object for equality.
/// </sumary>
/// </summary>
/// <returns>
/// True if the given object is the same object or if it is another Stringshare object
/// and both wrapped strings are equal or if it is a string object and its content
Expand All @@ -191,9 +191,9 @@ public override bool Equals(object other)
return other.GetType() == typeof(Stringshare) && this == ((Stringshare)other);
}

/// <sumary>
/// <summary>
/// Check the given Stringshare for equality.
/// </sumary>
/// </summary>
/// <returns>
/// True if the given Stringshare object is not null and its wrapped string
/// have the same content of this.Str, false otherwise.
Expand All @@ -203,9 +203,9 @@ public bool Equals(Stringshare other)
return this == other;
}

/// <sumary>
/// <summary>
/// Check the given Stringshare for equality.
/// </sumary>
/// </summary>
/// <returns>
/// True if the given string is not null and the wrapped string have the same
/// content of the given string, false otherwise.
Expand All @@ -215,11 +215,11 @@ public bool Equals(string other)
return this.Str == other;
}

/// <sumary>
/// <summary>
/// Get the wrapped string.
/// <seealso cref="Stringshare.Str"/>
/// <seealso cref="Stringshare.ToString()"/>
/// </sumary>
/// <seealso cref="Str"/>
/// <seealso cref="ToString()"/>
/// </summary>
/// <returns>The wrapped string. Same as the property Str.</returns>
public string Get()
{
Expand Down
30 changes: 28 additions & 2 deletions src/bindings/mono/eo_mono/EoWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ namespace Efl
namespace Eo
{

/// <summary>
/// Abstract class that delivers base level binding to Efl Objects.
///
/// Most of it is protected functionalities to serve the generated
/// binding classes that inherit from it.
/// </summary>
public abstract class EoWrapper : IWrapper, IDisposable
{
/// <summary>Object used to synchronize access to EFL events.</summary>
protected readonly object eflBindingEventLock = new object();
private bool generated = true;
private System.IntPtr handle = IntPtr.Zero;
Expand Down Expand Up @@ -49,7 +56,7 @@ protected EoWrapper(ConstructingHandle ch)
/// <summary>Initializes a new instance of the <see cref="Object"/> class.
/// Internal usage: Constructs an instance from a native pointer. This is used when interacting with C code and should not be used directly.
/// Do not implement this constructor.</summary>
/// <param name="raw">The native pointer to be wrapped.</param>
/// <param name="wh">The native pointer to be wrapped.</param>
protected EoWrapper(Efl.Eo.Globals.WrappingHandle wh)
{
handle = wh.NativeHandle;
Expand Down Expand Up @@ -124,6 +131,15 @@ public abstract System.IntPtr NativeClass
get;
}

/// <summary>
/// Whether this object type is one of the generated binding classes or a custom
/// class defined by the user and that inherit from one of the generated ones.
/// </summary>
/// <returns>
/// True if this object type is one of the generated binding classes,
/// false if it is class that is manually defined and that inherits from
/// one of the generated ones, including user defined classes.
/// </returns>
protected bool IsGeneratedBindingClass
{
get { return generated; }
Expand Down Expand Up @@ -269,7 +285,7 @@ private static void OwnershipSharedCallback(IntPtr data, ref Efl.Event.NativeStr
ws.MakeShared();
}

/// <sumary>Create and set to the internal native state a C# supervisor for this Eo wrapper. For internal use only.</sumary>
/// <summary>Create and set to the internal native state a C# supervisor for this Eo wrapper. For internal use only.</summary>
private void AddWrapperSupervisor()
{
var ws = new Efl.Eo.WrapperSupervisor(this);
Expand All @@ -291,23 +307,33 @@ private void AddOwnershipEventHandlers()
Eina.Error.RaiseIfUnhandledException();
}

/// <summary>
/// Struct to be used when constructing objects from native code.
/// Wraps the pointer handle to the native object instance.
/// </summary>
protected struct ConstructingHandle
{
/// <summary>Constructor for wrapping the native handle.</summary>
public ConstructingHandle(IntPtr h)
{
NativeHandle = h;
}

/// <summary>Pointer to the native instance.</summary>
public IntPtr NativeHandle { get; private set; }
}

/// <summary>Wrapper for native methods and virtual method delegates.
/// For internal use by generated code only.</summary>
public abstract class NativeMethods : Efl.Eo.NativeClass
{
private static EflConstructorDelegate csharpEflConstructorStaticDelegate = new EflConstructorDelegate(Constructor);
private static Efl.Eo.NativeModule EoModule = new Efl.Eo.NativeModule("eo");

private delegate IntPtr EflConstructorDelegate(IntPtr obj, IntPtr pd);

/// <summary>Gets the list of Eo operations to override.</summary>
/// <returns>The list of Eo operations to be overload.</returns>
public override System.Collections.Generic.List<Efl_Op_Description> GetEoOps(Type type)
{
var descs = new System.Collections.Generic.List<Efl_Op_Description>();
Expand Down
4 changes: 2 additions & 2 deletions src/bindings/mono/eo_mono/iwrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -716,11 +716,11 @@ public static void ThreadSafeFreeCbExec(EinaFreeCb cbFreeCb, IntPtr cbData)
Monitor.Exit(Efl.All.InitLock);
}

/// <sumary>
/// <summary>
/// Internal struct used by the binding to pass the native handle pointer
/// to the managed object wrapping constructor.
/// Internal usage only: do not use this class in inherited classes.
/// </sumary>
/// </summary>
public struct WrappingHandle
{
public WrappingHandle(IntPtr h)
Expand Down
2 changes: 2 additions & 0 deletions src/examples/elementary/bg_cxx_example_01.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define EFL_CXXPERIMENTAL // for background part
#ifndef EFL_BETA_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif
#include <Efl_Ui.hh>

using efl::eo::instantiate;
Expand Down
2 changes: 2 additions & 0 deletions src/examples/elementary/button_cxx_example_00.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` button_cxx_example_00.cc -o button_cxx_example_00

#define EFL_CXXPERIMENTAL
#ifndef EFL_BETA_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif
#include <Efl_Ui.hh>
#include <iostream>

Expand Down
2 changes: 2 additions & 0 deletions src/examples/elementary/button_cxx_example_01.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` button_cxx_example_01.cc -o button_cxx_example_01

#define EFL_CXXPERIMENTAL
#ifndef EFL_BETA_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif
#include <Efl_Ui.hh>

using efl::eo::instantiate;
Expand Down
1 change: 1 addition & 0 deletions src/examples/elementary/calendar_cxx_example_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct appData
}, _1, _2);
// FIXME XAR: I broke this and I do not know how to fix it
// cal.format_func_set(cb_a);
(void)cb_a;
}

void destroy() {
Expand Down
2 changes: 2 additions & 0 deletions src/examples/elementary/radio_cxx_example_01.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` radio_cxx_example_01.cc -o radio_cxx_example_01

#define EFL_CXXPERIMENTAL
#ifndef EFL_BETA_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif
#include <Efl_Ui.hh>
#include <iostream>

Expand Down
2 changes: 2 additions & 0 deletions src/examples/elementary/slider_cxx_example.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// g++ -g `pkg-config --cflags --libs elementary-cxx efl-cxx eina-cxx eo-cxx ecore-cxx evas-cxx edje-cxx` slider_cxx_example.cc -o slider_cxx_example

#define EFL_CXXPERIMENTAL
#ifndef EFL_BETA_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif
#include <Efl_Ui.hh>

using namespace std::placeholders;
Expand Down
2 changes: 2 additions & 0 deletions src/examples/elementary/toolbar_cxx_example_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

#warning This example requires yet unfinished EO APIs

#ifndef EFL_BETA_API_SUPPORT
#define EFL_BETA_API_SUPPORT
#endif
#include <Efl_Ui.hh>

EAPI int
Expand Down
10 changes: 10 additions & 0 deletions src/lib/eolian_cxx/grammar/type_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@ struct visitor_generate
(complex, regular_type_def{" ::efl::eina::accessor", complex.outer.base_qualifier, {}});
}
}
, {"slice", nullptr, nullptr, [&]
{
return regular_type_def{" Eina_Slice", complex.outer.base_qualifier, {}};
}
}
, {"rw_slice", nullptr, nullptr, [&]
{
return regular_type_def{" Eina_Rw_Slice", complex.outer.base_qualifier, {}};
}
}
};

auto default_match = [&] (attributes::complex_type_def const& complex)
Expand Down
Loading