Skip to content

Commit a7db592

Browse files
committed
Add proof of concept Python binding
Supports this code: widget: @python type = { value: int; operator=: (out this, i: int) = { value = i; } add: (inout this, i: int) -> int = { value += i; return value; } shout: (this, s: std::string) -> std::string = s + "!"; } Being invoked from Python like this: import widgetlib w = widgetlib.widget(10) print(w.add(5)) # prints 15 print(w.add(i=7)) # prints 22 print(w.shout("hello")) # prints "hello!" I'm not checking in a test case though because this is proof-of-concept only, currently hardwired to generate pybind11 and bash .sh invoking g++-10
1 parent 53504bb commit a7db592

File tree

7 files changed

+1437
-1163
lines changed

7 files changed

+1437
-1163
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

2-
cppfront compiler v0.8.2 Build A815:1039
2+
cppfront compiler v0.8.2 Build A826:0706
33
SPDX-License-Identifier Apache-2.0 WITH LLVM-exception
44
Copyright (c) 2022-2025 Herb Sutter

source/build.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"A815:1039"
1+
"A826:0706"

source/parse.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6403,6 +6403,9 @@ class parser
64036403
{
64046404
std::vector<error_entry>& errors;
64056405
std::set<std::string>& includes;
6406+
std::vector<std::string>& extra_cpp1;
6407+
std::vector<std::string>& extra_build;
6408+
std::string filename;
64066409

64076410
std::unique_ptr<translation_unit_node> parse_tree = {};
64086411

@@ -6529,20 +6532,38 @@ class parser
65296532
//
65306533
parser(
65316534
std::vector<error_entry>& errors_,
6532-
std::set<std::string>& includes_
6535+
std::set<std::string>& includes_,
6536+
std::vector<std::string>& extra_cpp1_,
6537+
std::vector<std::string>& extra_build_,
6538+
std::string_view filename_
65336539
)
6534-
: errors{ errors_ }
6535-
, includes{ includes_ }
6536-
, parse_tree{std::make_unique<translation_unit_node>()}
6540+
: errors { errors_ }
6541+
, includes { includes_ }
6542+
, extra_cpp1 { extra_cpp1_ }
6543+
, extra_build{ extra_build_ }
6544+
, filename { filename_ }
6545+
, parse_tree {std::make_unique<translation_unit_node>()}
65376546
{ }
65386547

65396548
parser( parser const& that )
65406549
: errors{ that.errors }
65416550
, includes{ that.includes }
6551+
, extra_cpp1{ that.extra_cpp1 }
6552+
, extra_build{ that.extra_build }
65426553
, parse_tree{std::make_unique<translation_unit_node>()}
65436554
{ }
65446555

65456556

6557+
//-----------------------------------------------------------------------
6558+
// get_filename
6559+
//
6560+
auto get_filename() const
6561+
-> std::string
6562+
{
6563+
return filename;
6564+
}
6565+
6566+
65466567
//-----------------------------------------------------------------------
65476568
// parse
65486569
//

0 commit comments

Comments
 (0)