Skip to content

Commit de5d5d5

Browse files
committed
Fix callback getter functions
1 parent 61f8527 commit de5d5d5

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Source/Modules/fortran.cxx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ class FORTRAN : public Language {
553553
virtual int staticmemberfunctionHandler(Node *n);
554554
virtual int staticmembervariableHandler(Node *n);
555555
virtual int enumDeclaration(Node *n);
556+
virtual int callbackfunctionHandler(Node *n);
556557
virtual int constantWrapper(Node *n);
557558

558559
virtual String *makeParameterName(Node *n, Parm *p, int arg_num, bool is_setter = false) const;
@@ -565,7 +566,7 @@ class FORTRAN : public Language {
565566
Wrapper *imfuncWrapper(Node *n, bool bindc);
566567
Wrapper *proxyfuncWrapper(Node *n);
567568

568-
int callbackHandler(Node *n);
569+
int fortrancallbackHandler(Node *n);
569570
int bindcfunctionHandler(Node *n);
570571
int bindcvarWrapper(Node *n);
571572

@@ -2463,7 +2464,7 @@ int FORTRAN::globalfunctionHandler(Node *n) {
24632464
// Flag is set to a non-"0" value
24642465
Node *cbnode = Getattr(n, "fortran:callback");
24652466
if (!cbnode) {
2466-
this->callbackHandler(n);
2467+
this->fortrancallbackHandler(n);
24672468
cbnode = Getattr(n, "fortran:callback");
24682469
}
24692470
if (cbnode && Cmp(Getattr(cbnode, "sym:name"), Getattr(n, "sym:name")) == 0) {
@@ -2498,7 +2499,7 @@ int FORTRAN::globalfunctionHandler(Node *n) {
24982499
* might want to have two separate meaningful callback names and we don't want
24992500
* to mysteriously prevent one from being wrapped.
25002501
*/
2501-
int FORTRAN::callbackHandler(Node *n) {
2502+
int FORTRAN::fortrancallbackHandler(Node *n) {
25022503
// Create a shallow copy of the node with params
25032504
Node *cbnode = copyNode(n);
25042505
Setattr(cbnode, "parms", Getattr(n, "parms"));
@@ -2817,6 +2818,21 @@ int FORTRAN::enumDeclaration(Node *n) {
28172818
return result;
28182819
}
28192820

2821+
2822+
/* -------------------------------------------------------------------------
2823+
* \brief Process callbacks, which generate 'getter' wrapper functions
2824+
*
2825+
* To avoid breaking the later 'functionWrapper', we create a copy of the node.
2826+
*/
2827+
int FORTRAN::callbackfunctionHandler(Node *n) {
2828+
// Create a shallow copy of the node with params
2829+
Node *cbnode = copyNode(n);
2830+
Setattr(cbnode, "parms", Getattr(n, "parms"));
2831+
Language::callbackfunctionHandler(cbnode);
2832+
Setattr(n, "feature:callback:node", cbnode);
2833+
return SWIG_OK;
2834+
}
2835+
28202836
/* -------------------------------------------------------------------------
28212837
* \brief Process *compile-time* constants
28222838
*
@@ -3043,7 +3059,7 @@ String *FORTRAN::get_proxyname(Node *parent, SwigType *basetype) {
30433059
if (is_enum) {
30443060
set_nodeType(n, "enumforward");
30453061
} else if (is_funptr) {
3046-
// Create a 'callback node' like callbackHandler
3062+
// Create a 'callback node' like fortrancallbackHandler
30473063
set_nodeType(n, "cdecl");
30483064
Setattr(n, "kind", "function");
30493065
Setattr(n, "storage", "externc");

0 commit comments

Comments
 (0)