-
Notifications
You must be signed in to change notification settings - Fork 10
Conversation
It seems like Type.Name is more common in gir. For instance, implements refers to the interface by name and not c:type. This is also handy because we do not have to strip off any trailing const or leading pointers.
Sometimes arrays do not have a name. In this case use Type.Name instead
Object is now resolved as Class
@@ -12,11 +12,12 @@ void RegisterBuiltIn (bool nativeWin64) | |||
AddType (new StringMarshal ("gfilename", "string", "", "IntPtr"));//, "GLib.Marshaller.StringToFilenamePtr({0})", "GLib.Marshaller.FilenamePtrToStringGFree({0})")); | |||
AddType (new StringMarshal ("gchar", "string", "", "IntPtr"));//, "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})")); | |||
AddType (new StringMarshal ("char", "string", "", "IntPtr"));//, "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})")); | |||
AddType (new StringMarshal ("utf8", "string", "", "IntPtr"));//, "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just stubbed this out. I'm not sure what else we want here if anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probaby remove more primitives as per https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations/#Default_Basic_Types
src/Gir.Tests/SymbolTableTests.cs
Outdated
@@ -48,12 +48,13 @@ public void NoAliasTypeAfterProcessing () | |||
} | |||
|
|||
[Test] | |||
[Ignore("there is no void*")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test can probably be removed as there are no pointers inside Type.Name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets remove it. Ignore
d tests seem to cause problems with CI for right now.
src/Gir/GenerationOptions.cs
Outdated
SymbolTable = new SymbolTable(Statistics, options.Win64Longs); | ||
SymbolTable.AddTypes (repo.GetSymbols()); | ||
foreach (var repository in resolvedRepos) { | ||
SymbolTable.AddTypes (repository.GetSymbols(), repository); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This includes the main repository so the mainrepository is in the symbol table twice: Once without and once with namespace prefix. This is because arrays seem to behave weird. There are array types inside GLib which have GLib.ByteArray as type where it should have been just ByteArray. That's why I added the repository twice.
src/Gir/Marshal/Array.cs
Outdated
@@ -5,7 +5,12 @@ public partial class Array | |||
{ | |||
public ISymbol GetSymbol (GenerationOptions opts) | |||
{ | |||
return opts.SymbolTable [CType]; | |||
if (Name != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometimes there is for some reason no Name on arrays. Bug in gi maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
byte_array_new_take in GLib-2.0.gir
<array length="1" zero-terminated="0" c:type="guint8*">
<type name="guint8" c:type="guint8"/>
</array>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you haven't modified the gir locally? It does have it for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<function name="byte_array_new_take"
c:identifier="g_byte_array_new_take"
moved-to="ByteArray.new_take"
version="2.32">
<doc xml:space="preserve">Create byte array containing the data. The data will be owned by the array
and will be freed with g_free(), i.e. it could be allocated using g_strdup().</doc>
<return-value transfer-ownership="full">
<doc xml:space="preserve">a new #GByteArray</doc>
<array name="GLib.ByteArray" c:type="GByteArray*">
<type name="guint8" c:type="guint8"/>
</array>
</return-value>
<parameters>
<parameter name="data" transfer-ownership="full">
<doc xml:space="preserve">byte data for the array</doc>
<array length="1" zero-terminated="0" c:type="guint8*">
<type name="guint8" c:type="guint8"/>
</array>
</parameter>
<parameter name="len" transfer-ownership="none">
<doc xml:space="preserve">length of @data</doc>
<type name="gsize" c:type="gsize"/>
</parameter>
</parameters>
</function>
It's not there in the data parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, for that case, I looked at the code, and in that case, it's just a uint8 pointer:
https://github.com/GNOME/glib/blob/90d3337e1d9d8218f1f8509417b6ae65993aa029/glib/garray.c#L1661
I guess when name isn't there, we need to pass in an array of the element type, it's not a specific gtype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, when we have a array with no name, it's just an Array
ISymbol that has T[]
as the managed type
@@ -12,11 +12,12 @@ void RegisterBuiltIn (bool nativeWin64) | |||
AddType (new StringMarshal ("gfilename", "string", "", "IntPtr"));//, "GLib.Marshaller.StringToFilenamePtr({0})", "GLib.Marshaller.FilenamePtrToStringGFree({0})")); | |||
AddType (new StringMarshal ("gchar", "string", "", "IntPtr"));//, "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})")); | |||
AddType (new StringMarshal ("char", "string", "", "IntPtr"));//, "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})")); | |||
AddType (new StringMarshal ("utf8", "string", "", "IntPtr"));//, "GLib.Marshaller.StringToPtrGStrdup({0})", "GLib.Marshaller.PtrToStringGFree({0})")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we need the others. It seems like the string type name is utf8 for gchar and char in gir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added char
because I ran into it. The others I grabbed because of the old generator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, if we go down this route, utf8 is the only one we need.
@@ -54,6 +55,20 @@ void RegisterPrimitives (bool nativeWin64) | |||
|
|||
AddType (new Primitive ("va_list", "...", "")); | |||
|
|||
var alias = new Alias { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of a hack. It seems like GType is kind of a primitive since in GObject GType is used without a prefix even though the definition is in GLib.
@@ -72,20 +86,20 @@ static string TrimConstAndPointer (string type) | |||
return type.Substring (start, end - start); | |||
} | |||
|
|||
public ISymbol this [string type] { | |||
get { | |||
var actualType = TrimConstAndPointer (type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TrimConstAndPointer is not used anymore now but I kept the method for now. Do we want to remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a new project lets be proactive in removing stuff that isn't being used anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove it.
src/Gir/Marshal/SymbolTable.cs
Outdated
|
||
if (!typeMap.TryGetValue(toType, out target)) { | ||
// HACK?!: this might be in a included repository but these are prefixed in symbol table | ||
toType = $"{repository}.{alias.Type.Name}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to correctly dealias symbols in included repositories.
@@ -5,7 +5,7 @@ public partial class Varargs : ISymbol | |||
{ | |||
public string CSharpType => "..."; | |||
|
|||
public string CType => "va_list"; | |||
public string Name => "va_list"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole class will be rewritten to support overridden data, so it's fine for now.
@@ -23,7 +23,7 @@ public Object (UIntPtr object_type, string first_property_name, ... var_args) : | |||
{ | |||
} | |||
|
|||
static extern IntPtr g_object_newv (UIntPtr object_type, uint n_parameters, Parameter parameters); | |||
static extern Object g_object_newv (UIntPtr object_type, uint n_parameters, Parameter parameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look right. We don't want the pinvoke signature to use the C# type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but Classes use RetVal.CSharpType right now which points to Object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test changed because Object was not resolved correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaaah, yes! I thought we used CType, but we don't 👍
Not sure why jenkins is not building this PR |
@directhex ^^ |
@monojenkins build |
whitelist |
@monojenkins whitelist |
CLA was signed before, see #30 |
No description provided.