Skip to content

Commit ee3089e

Browse files
author
Giloo
committed
creates output keyword even if it does not exist beforehand.
1 parent 2e00ccc commit ee3089e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/export.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,8 +2029,8 @@ bool iszero = ((requested.flags & GDL_KW_ZERO) == GDL_KW_ZERO); //zero field if
20292029
// and GDL_KW_OUT | GDL_KW_ZERO for the flags. The value field will either
20302030
// contain NULL or the pointer to the variable. */
20312031
bool inputByReference = ((requested.flags & GDL_KW_VIN) == GDL_KW_VIN); // input, but passed by reference
2032-
bool isoutput = (!inputByReference && (requested.flags & GDL_KW_OUT) == GDL_KW_OUT);
2033-
bool isarray = (!inputByReference && (requested.flags & GDL_KW_ARRAY) == GDL_KW_ARRAY); //var must be an array, field is a GDL_KW_ARR_DESC_R*
2032+
bool isoutput = ((requested.flags & GDL_KW_OUT) == GDL_KW_OUT);
2033+
bool isarray = ((requested.flags & GDL_KW_ARRAY) == GDL_KW_ARRAY); //var must be an array, field is a GDL_KW_ARR_DESC_R*
20342034
bool byMask = ((requested.flags & GDL_KW_VALUE) == GDL_KW_VALUE);
20352035
// tag 'out' those that will get a return value
20362036
if (requested.specified != NULL) { // need write 0 or 1 in a special int in KW structure
@@ -2044,7 +2044,7 @@ if (requested.value != NULL) { // need to pass either an address of a EXPORT_VPT
20442044
if (isoutput && passed.readonly) GDL_WillThrowAfterCleaning("Keyword " + std::string(requested.keyword) + " must be a named variable.");
20452045
BaseGDL* var = passed.varptr;
20462046
//if requested var is NULL here, it is an undefined var, which MAY be returned as good value.
2047-
if (var == NULL) GDL_WillThrowAfterCleaning("GDLExportKeyword: variable " + std::string(requested.keyword) + " is not defined.");
2047+
if (var == NULL && !isoutput) GDL_WillThrowAfterCleaning("GDLExportKeyword: variable " + std::string(requested.keyword) + " is not defined.");
20482048
if (iszero) { //zero before write.
20492049
GDLZeroAtAddr(global_address);
20502050
}
@@ -2084,6 +2084,9 @@ if (requested.value != NULL) { // need to pass either an address of a EXPORT_VPT
20842084
}
20852085
}
20862086
}
2087+
} else if (isoutput) {
2088+
toBeReturned = IDL_Gettmp();
2089+
memcpy((void*) (global_address), (void*) (&toBeReturned), sizeof (EXPORT_VPTR)); //pass address of a EXPORT_VAR that will contain the result.
20872090
}
20882091
}
20892092
return toBeReturned;

0 commit comments

Comments
 (0)