Commit cc81ac5
committed
[[ LCB ]] Add varargs support to foreign handlers
This patch adds varargs support to foreign C handlers, allowing
binding to a wider range of C functions.
The syntax for vararg handlers is similar to that of C:
```
foreign handler myvarargs(in pFirst as Pointer, ...) returns CInt binds to ...
```
Using the token `...` to indicate the start of the variable
parameter list.
To implement vararg functions, a new parameter mode 'variadic'
has been added which causes a handler to be treated as variadic if
such a parameter with a mode is present.
As C requires any int type with rank less than int to be promoted
to int, and float to be promoted to double (when passed to a non-fixed
parameter in a variadic function), a 'promotedtype' and 'promote'
function have been added to foreign type descriptors to describe
the appropriate relation.1 parent fa8cdcf commit cc81ac5
File tree
23 files changed
+735
-126
lines changed- docs
- guides
- lcb/notes
- libfoundation
- include
- src
- libscript
- include/libscript
- src
- tests
- lcb
- compiler/frontend
- vm
- toolchain
- lc-compile/src
- libcompile/src
23 files changed
+735
-126
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
439 | 447 | | |
440 | 448 | | |
441 | 449 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1776 | 1776 | | |
1777 | 1777 | | |
1778 | 1778 | | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
1779 | 1787 | | |
1780 | 1788 | | |
1781 | 1789 | | |
| |||
1866 | 1874 | | |
1867 | 1875 | | |
1868 | 1876 | | |
| 1877 | + | |
1869 | 1878 | | |
1870 | 1879 | | |
1871 | 1880 | | |
| |||
1890 | 1899 | | |
1891 | 1900 | | |
1892 | 1901 | | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
1893 | 1905 | | |
1894 | 1906 | | |
1895 | 1907 | | |
1896 | 1908 | | |
1897 | 1909 | | |
1898 | | - | |
| 1910 | + | |
| 1911 | + | |
1899 | 1912 | | |
1900 | 1913 | | |
1901 | 1914 | | |
| |||
0 commit comments