+
Skip to content

Support array length parameters in public constructors #933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ private static string RenderParameters(IReadOnlyList<ParameterToNativeData> para
if (parameter.IsDestroyNotify)
continue;

if (parameter.IsArrayLengthParameter)
continue;

var typeData = ParameterRenderer.Render(parameter.Parameter);
result.Add($"{typeData.Direction}{typeData.NullableTypeName} {parameter.GetSignatureName()}");
}
Expand Down
6 changes: 0 additions & 6 deletions src/Libs/GLib-2.0/Public/Bytes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ partial void Initialize()
GC.AddMemoryPressure(_size);
}

public static Bytes New(Span<byte> data)
{
var obj = new Bytes(Internal.Bytes.New(ref MemoryMarshal.GetReference(data), (nuint) data.Length));
return obj;
}

public void Dispose()
{
Handle.Dispose();
Expand Down
15 changes: 15 additions & 0 deletions src/Native/GirTestLib/girtest-byte-array-tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ girtest_byte_array_tester_class_init(GirTestByteArrayTesterClass *class)
{
}

/**
* girtest_byte_array_tester_new_from_data:
* @buffer: (array length=len): data buffer
* @len: The size of the buffer
*
* This ignores the parameters as it is only there to test code generation data can be ignored.
*
* Returns: A new instance
*/
GirTestByteArrayTester*
girtest_byte_array_tester_new_from_data(guint8 *buffer, gsize len)
{
return g_object_new (GIRTEST_TYPE_BYTE_ARRAY_TESTER, NULL);
}

/**
* girtest_byte_array_tester_data_return:
*
Expand Down
1 change: 1 addition & 0 deletions src/Native/GirTestLib/girtest-byte-array-tester.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ typedef void (*GirTestByteArrayTesterCallback) (const guchar *buf, gsize count);
*/
typedef void (*GirTestByteArrayTesterCallbackNoLength) (const guchar *buf);

GirTestByteArrayTester* girtest_byte_array_tester_new_from_data(guint8 *buffer, gsize len);
const guchar* girtest_byte_array_tester_data_return();
gssize girtest_byte_array_tester_data_out_caller_allocates(void *buffer, gsize count);
gsize girtest_byte_array_tester_get_data_size();
Expand Down
7 changes: 7 additions & 0 deletions src/Tests/Libs/GirTest-0.1.Tests/ByteArrayTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public class ByteArrayTest : Test
private const byte Byte2 = 0x22;
private const nuint DataSize = 3;

[TestMethod]
public void SupportsByteArrayWithLengthInConstructor()
{
var data = new byte[] { 0x01 };
_ = ByteArrayTester.NewFromData(data);
}

[TestMethod]
public void ReturnByteArray()
{
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载