Skip to content

Commit b3da344

Browse files
committed
Add some comments about shared_ptr upcast code
1 parent 564a918 commit b3da344

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

Source/Modules/csharp.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,7 @@ class CSHARP:public Language {
17621762
String *smartnamestr = SwigType_namestr(smart);
17631763
String *bsmartnamestr = SwigType_namestr(smart);
17641764

1765+
// TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates
17651766
SwigType *rclassname = SwigType_typedef_resolve_all(classname);
17661767
SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname);
17671768
Replaceall(bsmartnamestr, rclassname, rbaseclassname);

Source/Modules/d.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3381,6 +3381,7 @@ class D : public Language {
33813381
String *smartnamestr = SwigType_namestr(smart);
33823382
String *bsmartnamestr = SwigType_namestr(smart);
33833383

3384+
// TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates
33843385
SwigType *rclassname = SwigType_typedef_resolve_all(classname);
33853386
SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname);
33863387
Replaceall(bsmartnamestr, rclassname, rbaseclassname);

Source/Modules/java.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,6 +1904,7 @@ class JAVA:public Language {
19041904
String *smartnamestr = SwigType_namestr(smart);
19051905
String *bsmartnamestr = SwigType_namestr(smart);
19061906

1907+
// TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates
19071908
SwigType *rclassname = SwigType_typedef_resolve_all(classname);
19081909
SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname);
19091910
Replaceall(bsmartnamestr, rclassname, rbaseclassname);

Source/Modules/typepass.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ class TypePass:private Dispatcher {
267267
and smart pointer to base class, so that smart pointer upcasts
268268
are automatically generated. */
269269
SwigType *bsmart = Copy(smart);
270+
271+
// TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates
270272
SwigType *rclsname = SwigType_typedef_resolve_all(clsname);
271273
SwigType *rbname = SwigType_typedef_resolve_all(bname);
272274
int replace_count = Replaceall(bsmart, rclsname, rbname);
@@ -276,6 +278,12 @@ class TypePass:private Dispatcher {
276278
String *firstname = Getattr(first, "name");
277279
Replaceall(bsmart, firstname, rbname);
278280
}
281+
// The code above currently creates a smartptr of the base class by substitution, replacing Derived
282+
// with Base resulting in something like: 'smartptr< Derived >' from 'smartptr< Base >'. Instead
283+
// the feature:smartptr should be used as it also contains 'smartptr< Base >' as specified by the user.
284+
// A similar fix should also be done in upcastsCode in java.cxx, csharp.cxx and writeClassUpcast in d.cxx.
285+
// Printf(stdout, "smartcomparison %s <=> %s\n", SwigType_namestr(bsmart), Getattr(bclass, "feature:smartptr"));
286+
279287
Delete(rclsname);
280288
Delete(rbname);
281289
String *smartnamestr = SwigType_namestr(smart);

0 commit comments

Comments
 (0)