-
Notifications
You must be signed in to change notification settings - Fork 314
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
Va list binding compatibility #970
Merged
emilio
merged 3 commits into
mozilla:master
from
gerard-ryan-immersaview:va_list_output_compatability
May 28, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef int32_t (*VaListFnPtr)(int32_t count, ...); | ||
|
||
typedef int32_t (*VaListFnPtr2)(int32_t count); | ||
|
||
typedef struct Interface_______i32_______i32_______va_list { | ||
int32_t (*fn1)(int32_t count, ...); | ||
} Interface_______i32_______i32_______va_list; | ||
|
||
typedef struct Interface_______i32_______i32 { | ||
int32_t (*fn1)(int32_t count); | ||
} Interface_______i32_______i32; | ||
|
||
int32_t va_list_test(int32_t count, ...); | ||
|
||
int32_t va_list_test2(int32_t count, ...); | ||
|
||
void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), | ||
int32_t (*fn2)(int32_t count), | ||
VaListFnPtr fn3, | ||
VaListFnPtr2 fn4, | ||
struct Interface_______i32_______i32_______va_list fn5, | ||
struct Interface_______i32_______i32 fn6); |
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,35 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef int32_t (*VaListFnPtr)(int32_t count, ...); | ||
|
||
typedef int32_t (*VaListFnPtr2)(int32_t count); | ||
|
||
typedef struct Interface_______i32_______i32_______va_list { | ||
int32_t (*fn1)(int32_t count, ...); | ||
} Interface_______i32_______i32_______va_list; | ||
|
||
typedef struct Interface_______i32_______i32 { | ||
int32_t (*fn1)(int32_t count); | ||
} Interface_______i32_______i32; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
int32_t va_list_test(int32_t count, ...); | ||
|
||
int32_t va_list_test2(int32_t count, ...); | ||
|
||
void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), | ||
int32_t (*fn2)(int32_t count), | ||
VaListFnPtr fn3, | ||
VaListFnPtr2 fn4, | ||
struct Interface_______i32_______i32_______va_list fn5, | ||
struct Interface_______i32_______i32 fn6); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif // __cplusplus |
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 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef int32_t (*VaListFnPtr)(int32_t count, ...); | ||
|
||
typedef int32_t (*VaListFnPtr2)(int32_t count); | ||
|
||
struct Interface_______i32_______i32_______va_list { | ||
int32_t (*fn1)(int32_t count, ...); | ||
}; | ||
|
||
struct Interface_______i32_______i32 { | ||
int32_t (*fn1)(int32_t count); | ||
}; | ||
|
||
int32_t va_list_test(int32_t count, ...); | ||
|
||
int32_t va_list_test2(int32_t count, ...); | ||
|
||
void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), | ||
int32_t (*fn2)(int32_t count), | ||
VaListFnPtr fn3, | ||
VaListFnPtr2 fn4, | ||
struct Interface_______i32_______i32_______va_list fn5, | ||
struct Interface_______i32_______i32 fn6); |
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,35 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
typedef int32_t (*VaListFnPtr)(int32_t count, ...); | ||
|
||
typedef int32_t (*VaListFnPtr2)(int32_t count); | ||
|
||
struct Interface_______i32_______i32_______va_list { | ||
int32_t (*fn1)(int32_t count, ...); | ||
}; | ||
|
||
struct Interface_______i32_______i32 { | ||
int32_t (*fn1)(int32_t count); | ||
}; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif // __cplusplus | ||
|
||
int32_t va_list_test(int32_t count, ...); | ||
|
||
int32_t va_list_test2(int32_t count, ...); | ||
|
||
void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), | ||
int32_t (*fn2)(int32_t count), | ||
VaListFnPtr fn3, | ||
VaListFnPtr2 fn4, | ||
struct Interface_______i32_______i32_______va_list fn5, | ||
struct Interface_______i32_______i32 fn6); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif // __cplusplus |
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,28 @@ | ||
from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
cdef extern from *: | ||
ctypedef bint bool | ||
ctypedef struct va_list | ||
|
||
cdef extern from *: | ||
|
||
ctypedef int32_t (*VaListFnPtr)(int32_t count, ...); | ||
|
||
ctypedef int32_t (*VaListFnPtr2)(int32_t count); | ||
|
||
cdef struct Interface_______i32_______i32_______va_list: | ||
int32_t (*fn1)(int32_t count, ...); | ||
|
||
cdef struct Interface_______i32_______i32: | ||
int32_t (*fn1)(int32_t count); | ||
|
||
int32_t va_list_test(int32_t count, ...); | ||
|
||
int32_t va_list_test2(int32_t count, ...); | ||
|
||
void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), | ||
int32_t (*fn2)(int32_t count), | ||
VaListFnPtr fn3, | ||
VaListFnPtr2 fn4, | ||
Interface_______i32_______i32_______va_list fn5, | ||
Interface_______i32_______i32 fn6); |
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 |
---|---|---|
@@ -1,11 +1,30 @@ | ||
use std::ffi::VaList; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn va_list_test(mut ap: VaList) -> int32_t { | ||
pub unsafe extern "C" fn va_list_test(count: int32_t, mut ap: VaList) -> int32_t { | ||
ap.arg() | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn va_list_test2(mut ap: ...) -> int32_t { | ||
pub unsafe extern "C" fn va_list_test2(count: int32_t, mut ap: ...) -> int32_t { | ||
ap.arg() | ||
} | ||
|
||
type VaListFnPtr = Option<unsafe extern "C" fn(count: int32_t, VaList) -> int32_t>; | ||
type VaListFnPtr2 = Option<unsafe extern "C" fn(count: int32_t, ...) -> int32_t>; | ||
|
||
#[repr(C)] | ||
struct Interface<T> { | ||
fn1: T, | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn va_list_fn_ptrs( | ||
fn1: Option<unsafe extern "C" fn(count: int32_t, VaList) -> int32_t>, | ||
fn2: Option<unsafe extern "C" fn(count: int32_t, ...) -> int32_t>, | ||
fn3: VaListFnPtr, | ||
fn4: VaListFnPtr2, | ||
fn5: Interface<Option<unsafe extern "C" fn(count: int32_t, VaList) -> int32_t>>, | ||
fn6: Interface<Option<unsafe extern "C" fn(count: int32_t, ...) -> int32_t>>, | ||
) { | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It looks like when used in function pointer the dotdotdot version does not emit the va args dots in the C version. Is this intended?
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.
Created #971
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 this test to highlight the existing limitation.
I had attempted to address it with #969 but there appears to have been some miscommunication.