-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Function pointers * Fix tests * Fix tests
- Loading branch information
1 parent
cd68a72
commit 1aed7a7
Showing
36 changed files
with
462 additions
and
56 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/c/tests/function_pointers/function_pointer_void/config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"inputFilePath": "./main.c", | ||
"userIncludeDirectories": [ | ||
"../../../production/ffi_helper/include" | ||
], | ||
"ignoredIncludeFiles": [ | ||
"../../../production/ffi_helper/include/ffi_helper.h" | ||
], | ||
"targetPlatforms": { | ||
"windows": { | ||
"x86_64-pc-windows-msvc": {}, | ||
"aarch64-pc-windows-msvc": {} | ||
}, | ||
"macos": { | ||
"aarch64-apple-darwin": {}, | ||
"x86_64-apple-darwin": {}, | ||
"aarch64-apple-ios": {} | ||
}, | ||
"linux": { | ||
"x86_64-unknown-linux-gnu": {}, | ||
"aarch64-unknown-linux-gnu": {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <stdio.h> | ||
#include "ffi_helper.h" | ||
|
||
typedef void (*function_pointer_void)(); | ||
|
||
FFI_API_DECL void function(function_pointer_void fnptr) | ||
{ | ||
(*fnptr)(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"inputFilePath": "./main.c", | ||
"userIncludeDirectories": [ | ||
"../../../production/ffi_helper/include" | ||
], | ||
"ignoredIncludeFiles": [ | ||
"../../../production/ffi_helper/include/ffi_helper.h" | ||
], | ||
"targetPlatforms": { | ||
"windows": { | ||
"i686-pc-windows-msvc": {}, | ||
"x86_64-pc-windows-msvc": {}, | ||
"aarch64-pc-windows-msvc": {} | ||
}, | ||
"macos": { | ||
"i686-apple-darwin": {}, | ||
"aarch64-apple-darwin": {}, | ||
"x86_64-apple-darwin": {}, | ||
"aarch64-apple-ios": {} | ||
}, | ||
"linux": { | ||
"i686-unknown-linux-gnu": {}, | ||
"x86_64-unknown-linux-gnu": {}, | ||
"aarch64-unknown-linux-gnu": {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <stdio.h> | ||
#include "ffi_helper.h" | ||
|
||
struct struct_int | ||
{ | ||
int a; | ||
} | ||
|
||
FFI_API_DECL struct struct_int struct_int; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"inputFilePath": "./main.c", | ||
"userIncludeDirectories": [ | ||
"../../../production/ffi_helper/include" | ||
], | ||
"ignoredIncludeFiles": [ | ||
"../../../production/ffi_helper/include/ffi_helper.h" | ||
], | ||
"targetPlatforms": { | ||
"windows": { | ||
"i686-pc-windows-msvc": {}, | ||
"x86_64-pc-windows-msvc": {}, | ||
"aarch64-pc-windows-msvc": {} | ||
}, | ||
"macos": { | ||
"i686-apple-darwin": {}, | ||
"aarch64-apple-darwin": {}, | ||
"x86_64-apple-darwin": {}, | ||
"aarch64-apple-ios": {} | ||
}, | ||
"linux": { | ||
"i686-unknown-linux-gnu": {}, | ||
"x86_64-unknown-linux-gnu": {}, | ||
"aarch64-unknown-linux-gnu": {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <stdio.h> | ||
#include "ffi_helper.h" | ||
|
||
union union_int_int | ||
{ | ||
int a; | ||
int b; | ||
} | ||
|
||
FFI_API_DECL union union_int_int union_int_int; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/cs/tests/c2ffi.Tests.EndToEnd.Extract/FunctionPointers/function_pointer_void/Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Bottlenose Labs Inc. (https://github.com/bottlenoselabs). All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the Git repository root directory for full license information. | ||
|
||
using c2ffi.Tests.Library.Models; | ||
using FluentAssertions; | ||
|
||
#pragma warning disable CA1707 | ||
|
||
namespace c2ffi.Tests.EndToEnd.Extract.FunctionPointers.function_pointer_void; | ||
|
||
public class Test : ExtractFfiTest | ||
{ | ||
private const string FunctionPointerName = "function_pointer_void"; | ||
|
||
[Fact] | ||
public void FunctionPointer() | ||
{ | ||
var ffis = GetTargetPlatformFfis( | ||
$"src/c/tests/function_pointers/{FunctionPointerName}/config.json"); | ||
Assert.True(ffis.Length > 0); | ||
|
||
foreach (var ffi in ffis) | ||
{ | ||
FfiFunctionPointer(ffi); | ||
} | ||
} | ||
|
||
private void FfiFunctionPointer(CTestFfiTargetPlatform ffi) | ||
{ | ||
var alias = ffi.GetTypeAlias(FunctionPointerName); | ||
alias.Name.Should().Be(FunctionPointerName); | ||
alias.UnderlyingType.NodeKind.Should().Be("functionpointer"); | ||
alias.UnderlyingType.Name.Should().Be("void ()"); | ||
alias.UnderlyingType.SizeOf.Should().Be(8); | ||
alias.UnderlyingType.AlignOf.Should().Be(8); | ||
alias.UnderlyingType.InnerType.Should().BeNull(); | ||
|
||
var functionPointer = ffi.GetFunctionPointer("void ()"); | ||
functionPointer.Name.Should().Be("void ()"); | ||
functionPointer.CallingConvention.Should().Be("cdecl"); | ||
functionPointer.Parameters.Should().BeEmpty(); | ||
functionPointer.ReturnType.Name.Should().Be("void"); | ||
functionPointer.ReturnType.SizeOf.Should().BeNull(); | ||
functionPointer.ReturnType.AlignOf.Should().BeNull(); | ||
functionPointer.ReturnType.InnerType.Should().BeNull(); | ||
functionPointer.ReturnType.NodeKind.Should().Be("primitive"); | ||
} | ||
} |
Oops, something went wrong.