77// defining characteristics:
88// - 2 segments
99// - starts with cxxbridge
10+ // TODO: should these also include {CXXVERSION}?
1011//
1112// (b) Behavior on a builtin binding without generic parameter.
1213// pattern: {CXXBRIDGE} $ {TYPE} $ {NAME}
1516// defining characteristics:
1617// - 3 segments
1718// - starts with cxxbridge
19+ // TODO: should these also include {CXXVERSION}?
1820//
1921// (c) Behavior on a builtin binding with generic parameter.
2022// pattern: {CXXBRIDGE} $ {TYPE} $ {PARAM...} $ {NAME}
2426// defining characteristics:
2527// - 4+ segments
2628// - starts with cxxbridge
29+ // TODO: should these also include {CXXVERSION}? (always? or only for
30+ // ones implicitly or explicitly `impl`-ed by the user?)
2731//
2832// (d) User-defined extern function.
29- // pattern: {NAMESPACE...} $ {CXXBRIDGE} $ {NAME}
33+ // pattern: {NAMESPACE...} $ {CXXBRIDGE} $ {CXXVERSION} $ { NAME}
3034// examples:
31- // - cxxbridge1$new_client
32- // - org$rust$cxxbridge1$new_client
35+ // - cxxbridge1$v187$ new_client
36+ // - org$rust$cxxbridge1$v187$ new_client
3337// defining characteristics:
34- // - cxxbridge is second from end
38+ // - cxxbridge is third from end
3539// FIXME: conflict with (a) if they collide with one of our one-off symbol names in the global namespace
3640//
3741// (e) User-defined extern member function.
38- // pattern: {NAMESPACE...} $ {CXXBRIDGE} $ {TYPE} $ {NAME}
42+ // pattern: {NAMESPACE...} $ {CXXBRIDGE} $ {CXXVERSION} $ { TYPE} $ {NAME}
3943// examples:
40- // - org$cxxbridge1$Struct$get
44+ // - org$cxxbridge1$v187$ Struct$get
4145// defining characteristics:
42- // - cxxbridge is third from end
46+ // - cxxbridge is fourth from end
4347// FIXME: conflict with (b) if e.g. user binds a type in global namespace that collides with our builtin type names
4448//
4549// (f) Operator overload.
46- // pattern: {NAMESPACE...} $ {CXXBRIDGE} $ {TYPE} $ operator $ {NAME}
50+ // pattern: {NAMESPACE...} $ {CXXBRIDGE} $ {CXXVERSION} $ { TYPE} $ operator $ {NAME}
4751// examples:
48- // - org$rust$cxxbridge1$Struct$operator$eq
52+ // - org$rust$cxxbridge1$v187$ Struct$operator$eq
4953// defining characteristics:
5054// - second segment from end is `operator` (not possible in type or namespace names)
5155//
5256// (g) Closure trampoline.
53- // pattern: {NAMESPACE...} $ {CXXBRIDGE} $ {TYPE?} $ {NAME} $ {ARGUMENT} $ {DIRECTION}
57+ // pattern: {NAMESPACE...} $ {CXXBRIDGE} $ {CXXVERSION} $ { TYPE?} $ {NAME} $ {ARGUMENT} $ {DIRECTION}
5458// examples:
5559// - org$rust$cxxbridge1$Struct$invoke$f$0
5660// defining characteristics:
7680use crate :: syntax:: symbol:: { self , Symbol } ;
7781use crate :: syntax:: { ExternFn , Pair , Types } ;
7882
83+ const CXXBRIDGE : & str = "cxxbridge1" ;
84+
7985// Ignoring `CARGO_PKG_VERSION_MAJOR` and `...MINOR`, because they don't agree across
8086// all the crates. For example `gen/lib/Cargo.toml` says `version = "0.7.xxx"`, but
8187// `macro/Cargo.toml` says `version = "1.0.xxx"`.
82- const CXXBRIDGE : & ' static str = concat ! ( "cxxbridge1_ " , env!( "CARGO_PKG_VERSION_PATCH" ) ) ;
88+ const CXXVERSION : & str = concat ! ( "v " , env!( "CARGO_PKG_VERSION_PATCH" ) ) ;
8389
8490macro_rules! join {
8591 ( $( $segment: expr) ,+ $( , ) ?) => {
@@ -94,18 +100,20 @@ pub(crate) fn extern_fn(efn: &ExternFn, types: &Types) -> Symbol {
94100 join ! (
95101 efn. name. namespace,
96102 CXXBRIDGE ,
103+ CXXVERSION ,
97104 self_type_ident. name. cxx,
98105 efn. name. rust,
99106 )
100107 }
101- None => join ! ( efn. name. namespace, CXXBRIDGE , efn. name. rust) ,
108+ None => join ! ( efn. name. namespace, CXXBRIDGE , CXXVERSION , efn. name. rust) ,
102109 }
103110}
104111
105112pub ( crate ) fn operator ( receiver : & Pair , operator : & ' static str ) -> Symbol {
106113 join ! (
107114 receiver. namespace,
108115 CXXBRIDGE ,
116+ CXXVERSION ,
109117 receiver. cxx,
110118 "operator" ,
111119 operator,
0 commit comments