diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ff658f77a..de1f1e2dd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ - [#477](http://github.com/Nelson-numerical-software/nelson/issues/477): update files watcher algo. +- [#489](http://github.com/Nelson-numerical-software/nelson/issues/489): display builtin and associated overload. + +- [#490](http://github.com/Nelson-numerical-software/nelson/issues/490): update default prompt. + ## Bug Fixes: - [#480](http://github.com/Nelson-numerical-software/nelson/issues/480): publisher name updated for windows installer. diff --git a/modules/audio/builtin/cpp/Gateway.cpp b/modules/audio/builtin/cpp/Gateway.cpp index a9035b6458..7c455925b7 100644 --- a/modules/audio/builtin/cpp/Gateway.cpp +++ b/modules/audio/builtin/cpp/Gateway.cpp @@ -59,7 +59,7 @@ const std::wstring gatewayName = L"audio"; static const nlsGateway gateway[] = { { "audiodevinfo", (void*)Nelson::AudioGateway::audiodevinfoBuiltin, 1, -1 }, { "audioplayer", (void*)Nelson::AudioGateway::audioplayerBuiltin, 1, -1 }, - { "audioplayer_disp", (void*)Nelson::AudioGateway::audioplayer_dispBuiltin, 0, 1, + { "audioplayer_display", (void*)Nelson::AudioGateway::audioplayer_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, { "audioplayer_delete", (void*)Nelson::AudioGateway::audioplayer_deleteBuiltin, 0, 1 }, { "audioplayer_isvalid", (void*)Nelson::AudioGateway::audioplayer_isvalidBuiltin, 1, 1, diff --git a/modules/audio/builtin/cpp/audioplayer_dispBuiltin.cpp b/modules/audio/builtin/cpp/audioplayer_dispBuiltin.cpp index ec6b62d51f..d819fe8b03 100644 --- a/modules/audio/builtin/cpp/audioplayer_dispBuiltin.cpp +++ b/modules/audio/builtin/cpp/audioplayer_dispBuiltin.cpp @@ -36,7 +36,7 @@ Nelson::AudioGateway::audioplayer_dispBuiltin(Evaluator* eval, int nLhs, const A { ArrayOfVector retval; nargoutcheck(nLhs, 0, 0); - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); ArrayOf param1 = argIn[0]; if (param1.isHandle()) { Interface* io = eval->getInterface(); diff --git a/modules/com_engine/builtin/cpp/COM_dispBuiltin.cpp b/modules/com_engine/builtin/cpp/COM_dispBuiltin.cpp index 5ab516ad78..3262cf0f4a 100644 --- a/modules/com_engine/builtin/cpp/COM_dispBuiltin.cpp +++ b/modules/com_engine/builtin/cpp/COM_dispBuiltin.cpp @@ -35,7 +35,7 @@ Nelson::ComEngineGateway::COM_dispBuiltin(Evaluator* eval, int nLhs, const Array ArrayOfVector retval; #ifdef _MSC_VER nargoutcheck(nLhs, 0, 0); - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); ArrayOf param1 = argIn[0]; DispComHandleObject(eval, param1); #else diff --git a/modules/com_engine/builtin/cpp/Gateway.cpp b/modules/com_engine/builtin/cpp/Gateway.cpp index ca19d91099..c7418772ed 100644 --- a/modules/com_engine/builtin/cpp/Gateway.cpp +++ b/modules/com_engine/builtin/cpp/Gateway.cpp @@ -54,7 +54,7 @@ static const nlsGateway gateway[] = { { "actxGetRunningServer", (void*)Nelson::ComEngineGateway::actxGetRunningServerBuiltin, 1, 1 }, { "actxcontrollist", (void*)Nelson::ComEngineGateway::actxcontrollistBuiltin, 1, 0 }, { "actxserverlist", (void*)Nelson::ComEngineGateway::actxserverlistBuiltin, 1, 0 }, - { "COM_disp", (void*)Nelson::ComEngineGateway::COM_dispBuiltin, 0, 1, + { "COM_display", (void*)Nelson::ComEngineGateway::COM_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, { "COM_fieldnames", (void*)Nelson::ComEngineGateway::COM_fieldnamesBuiltin, 1, 1 }, { "COM_methods", (void*)Nelson::ComEngineGateway::COM_methodsBuiltin, 1, 1 }, diff --git a/modules/core/tests/test_evalc.m b/modules/core/tests/test_evalc.m index 5af5d99be7..db819abac3 100644 --- a/modules/core/tests/test_evalc.m +++ b/modules/core/tests/test_evalc.m @@ -31,6 +31,7 @@ ans = 1 + '; assert_isequal(R, REF); %============================================================================= @@ -43,9 +44,11 @@ assert_isequal(R, REF); %============================================================================= R = evalc('A = 32'); -REF = 'A = +REF = ' +A = 32 + '; assert_isequal(R, REF); %============================================================================= diff --git a/modules/double/tests/test_double_disp.m b/modules/double/tests/test_double_display.m similarity index 100% rename from modules/double/tests/test_double_disp.m rename to modules/double/tests/test_double_display.m diff --git a/modules/double/tests/test_double_disp.ref b/modules/double/tests/test_double_display.ref similarity index 98% rename from modules/double/tests/test_double_disp.ref rename to modules/double/tests/test_double_display.ref index 0f7f2aec65..d647325896 100644 --- a/modules/double/tests/test_double_disp.ref +++ b/modules/double/tests/test_double_display.ref @@ -3,41 +3,50 @@ ans = 2.2204e-16 + ans = 3.1416 + ans = NaN + ans = Inf + ans = 0.0000 0.0000 + ans = 0.0000 + 3.1416i 3.0000 + 0.0000i 3.1416 + 0.0000i 6.2832 + 0.0000i + ans = 1 2 3 + ans = 1 100000000 100000000 1 + ans = 1 1.0000e+09 1.0000e+09 1 + ans = 1 0 0 0 0 @@ -46,6 +55,7 @@ ans = 0 0 0 1 0 0 0 0 0 1 + ans = 0.1000 0.0000 0.0000 0.0000 0.0000 @@ -54,15 +64,19 @@ ans = 0.0000 0.0000 0.0000 0.1000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1000 + ans = 1 1 -100000000 1 + ans = 1 1.0000e+09 -1.0000e+09 1 + + A = 0.5488 0.6459 0.7917 @@ -70,6 +84,8 @@ A = 0.6028 0.8918 0.5680 0.5449 0.9637 0.9256 0.4237 0.3834 0.0710 + + B = 0.0871 0.9786 0.6399 @@ -78,6 +94,7 @@ B = 0.7782 0.7805 0.5218 0.8700 0.1183 0.4147 + ans = 0.5488 + 0.0871i 0.6459 + 0.9786i 0.7917 + 0.6399i @@ -86,6 +103,7 @@ ans = 0.5449 + 0.7782i 0.9637 + 0.7805i 0.9256 + 0.5218i 0.4237 + 0.8700i 0.3834 + 0.1183i 0.0710 + 0.4147i + ans = 1.0000 + 1.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i @@ -94,46 +112,58 @@ ans = 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i + ans = 2.220446049250313e-16 + ans = 3.141592653589793 + ans = 300000000 + ans = 3.000000000000000e+09 + ans = -300000000 + ans = -3.000000000000000e+09 + ans = 0.000001234500000 + ans = 0.000333333333333 + ans = 1.333333333333333 0.000001234500000 + ans = 0.000001234500000 + ans = 0.000001234500000 0.000001234500000 + diff --git a/modules/double/tests/test_empty_display.ref b/modules/double/tests/test_empty_display.ref index 8e1ce956e4..1da09af53d 100644 --- a/modules/double/tests/test_empty_display.ref +++ b/modules/double/tests/test_empty_display.ref @@ -3,34 +3,43 @@ ans = 0 0 + ans = 0 0 + ans = 0 0 + ans = - size: 1x2x0 [] + ans = - size: 5x0x2x4 [] + ans = - size: 3x5x8x13x0 [] + ans = - size: 1x2x0 [] + + M = - size: 4x3x0 [] + diff --git a/modules/dynamic_link/builtin/cpp/Gateway.cpp b/modules/dynamic_link/builtin/cpp/Gateway.cpp index 3bce4578f1..7f0c7f9bf8 100644 --- a/modules/dynamic_link/builtin/cpp/Gateway.cpp +++ b/modules/dynamic_link/builtin/cpp/Gateway.cpp @@ -73,17 +73,17 @@ static const nlsGateway gateway[] = { { "addgateway", 1, CPP_BUILTIN_WITH_EVALUATOR }, { "removegateway", (void*)Nelson::DynamicLinkGateway::removegatewayBuiltin, 0, 1, CPP_BUILTIN_WITH_EVALUATOR }, - { "dlsym_disp", (void*)Nelson::DynamicLinkGateway::dlsym_dispBuiltin, 0, 1, + { "dlsym_display", (void*)Nelson::DynamicLinkGateway::dlsym_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, { "dlsym_isvalid", (void*)Nelson::DynamicLinkGateway::dlsym_isvalidBuiltin, 1, 1, CPP_BUILTIN_WITH_EVALUATOR }, - { "dllib_disp", (void*)Nelson::DynamicLinkGateway::dllib_dispBuiltin, 0, 1, + { "dllib_display", (void*)Nelson::DynamicLinkGateway::dllib_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, { "dllib_isvalid", (void*)Nelson::DynamicLinkGateway::dllib_isvalidBuiltin, 1, 1, CPP_BUILTIN_WITH_EVALUATOR }, { "dlcall", (void*)Nelson::DynamicLinkGateway::dlcallBuiltin, -1, -1, CPP_BUILTIN_WITH_EVALUATOR }, - { "libpointer_disp", (void*)Nelson::DynamicLinkGateway::libpointer_dispBuiltin, 0, 1, + { "libpointer_display", (void*)Nelson::DynamicLinkGateway::libpointer_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, { "isNull", (void*)Nelson::DynamicLinkGateway::isNullBuiltin, 1, 1, CPP_BUILTIN_WITH_EVALUATOR }, diff --git a/modules/dynamic_link/builtin/cpp/dllib_dispBuiltin.cpp b/modules/dynamic_link/builtin/cpp/dllib_dispBuiltin.cpp index 92c8b93071..14890ca7c8 100644 --- a/modules/dynamic_link/builtin/cpp/dllib_dispBuiltin.cpp +++ b/modules/dynamic_link/builtin/cpp/dllib_dispBuiltin.cpp @@ -35,7 +35,7 @@ ArrayOfVector Nelson::DynamicLinkGateway::dllib_dispBuiltin(Evaluator* eval, int nLhs, const ArrayOfVector& argIn) { ArrayOfVector retval; - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); nargoutcheck(nLhs, 0, 0); ArrayOf param1 = argIn[0]; if (param1.isHandle()) { diff --git a/modules/dynamic_link/builtin/cpp/dlsym_dispBuiltin.cpp b/modules/dynamic_link/builtin/cpp/dlsym_dispBuiltin.cpp index c29e7f2ac8..2a74f6e42a 100644 --- a/modules/dynamic_link/builtin/cpp/dlsym_dispBuiltin.cpp +++ b/modules/dynamic_link/builtin/cpp/dlsym_dispBuiltin.cpp @@ -35,7 +35,7 @@ ArrayOfVector Nelson::DynamicLinkGateway::dlsym_dispBuiltin(Evaluator* eval, int nLhs, const ArrayOfVector& argIn) { ArrayOfVector retval; - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); nargoutcheck(nLhs, 0, 0); ArrayOf param1 = argIn[0]; if (param1.isHandle()) { diff --git a/modules/dynamic_link/builtin/cpp/libpointer_dispBuiltin.cpp b/modules/dynamic_link/builtin/cpp/libpointer_dispBuiltin.cpp index cf854b19e0..ecf98dc010 100644 --- a/modules/dynamic_link/builtin/cpp/libpointer_dispBuiltin.cpp +++ b/modules/dynamic_link/builtin/cpp/libpointer_dispBuiltin.cpp @@ -36,7 +36,7 @@ Nelson::DynamicLinkGateway::libpointer_dispBuiltin( Evaluator* eval, int nLhs, const ArrayOfVector& argIn) { ArrayOfVector retval; - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); nargoutcheck(nLhs, 0, 0); ArrayOf param1 = argIn[0]; if (param1.isHandle()) { diff --git a/modules/elementary_functions/builtin/cpp/dispBuiltin.cpp b/modules/elementary_functions/builtin/cpp/dispBuiltin.cpp index b61b84ed9a..c940a6dce9 100644 --- a/modules/elementary_functions/builtin/cpp/dispBuiltin.cpp +++ b/modules/elementary_functions/builtin/cpp/dispBuiltin.cpp @@ -37,8 +37,7 @@ Nelson::ElementaryFunctionsGateway::dispBuiltin( nargincheck(argIn, 1, 1); nargoutcheck(nLhs, 0, 0); ArrayOf variable = argIn[0]; - variable.name(""); - OverloadDisplay(eval, variable, true); + OverloadDisplay(eval, variable, "", true); return retval; } //============================================================================= diff --git a/modules/elementary_functions/builtin/cpp/displayBuiltin.cpp b/modules/elementary_functions/builtin/cpp/displayBuiltin.cpp index f0de76eded..2fb4378f02 100644 --- a/modules/elementary_functions/builtin/cpp/displayBuiltin.cpp +++ b/modules/elementary_functions/builtin/cpp/displayBuiltin.cpp @@ -41,32 +41,8 @@ Nelson::ElementaryFunctionsGateway::displayBuiltin( std::string variableName = variable.name(); if (argIn.size() == 2) { variableName = argIn[1].getContentAsCString(); - variable.name(variableName); } - OverloadDisplay(eval, variable, true); - - /* - std::wstring variableName; - ArrayOf variableValue; - Interface* io = eval->getInterface(); - switch (argIn.size()) { - case 1: { - variableName = argIn[0].name(); - io->outputMessage(variableName + " = \n\n"); - OverloadDisplay(eval, argIn[0], true); - } break; - case 2: { - std::wstring variableName = argIn[1].getContentAsWideString(); - io->outputMessage(variableName + L" =\n\n"); - OverloadDisplay(eval, argIn[0], true); - } - - } break; - } - if (!variableName.empty()) { - io->outputMessage(variableName + L" =\n\n"); - } - */ + OverloadDisplay(eval, variable, variableName, true); return retval; } //============================================================================= diff --git a/modules/error_manager/functions/MException_disp.m b/modules/error_manager/functions/MException_display.m similarity index 97% rename from modules/error_manager/functions/MException_disp.m rename to modules/error_manager/functions/MException_display.m index c1b73e40e2..325f45a4b0 100644 --- a/modules/error_manager/functions/MException_disp.m +++ b/modules/error_manager/functions/MException_display.m @@ -23,7 +23,7 @@ % License along with this program. If not, see . % LICENCE_BLOCK_END %============================================================================= -function MException_disp(e) +function MException_display(e, name) r = struct(e); d = evalc('disp(r);'); disp(replace(d, '', '')) diff --git a/modules/files_folders_functions/builtin/cpp/dirBuiltin.cpp b/modules/files_folders_functions/builtin/cpp/dirBuiltin.cpp index eabdf34ddf..29b0204c99 100644 --- a/modules/files_folders_functions/builtin/cpp/dirBuiltin.cpp +++ b/modules/files_folders_functions/builtin/cpp/dirBuiltin.cpp @@ -77,6 +77,7 @@ Nelson::FilesFoldersGateway::dirBuiltin(int nLhs, const ArrayOfVector& argIn) + _W("Not a file or a directory."); NelsonPrint(msg); } else { + NelsonPrint("\n"); for (boost::container::vector::iterator it = res.begin(); it != res.end(); ++it) { if (NelsonConfiguration::getInstance()->getInterruptPending()) { @@ -92,6 +93,7 @@ Nelson::FilesFoldersGateway::dirBuiltin(int nLhs, const ArrayOfVector& argIn) NelsonPrint(it->getName() + L"\n"); } } + NelsonPrint("\n"); } } else { stringVector fieldnames; diff --git a/modules/function_handle/builtin/cpp/Gateway.cpp b/modules/function_handle/builtin/cpp/Gateway.cpp index 462cf36ddc..c7707b1439 100644 --- a/modules/function_handle/builtin/cpp/Gateway.cpp +++ b/modules/function_handle/builtin/cpp/Gateway.cpp @@ -42,8 +42,8 @@ static const nlsGateway gateway[] = { { "function_handle_extraction", (void*)Nelson::FunctionHandleGateway::function_handle_extractionBuiltin, -1, -1, CPP_BUILTIN_WITH_EVALUATOR }, - { "function_handle_disp", (void*)Nelson::FunctionHandleGateway::function_handle_dispBuiltin, 0, - 1, CPP_BUILTIN_WITH_EVALUATOR }, + { "function_handle_display", (void*)Nelson::FunctionHandleGateway::function_handle_dispBuiltin, 0, + 2, CPP_BUILTIN_WITH_EVALUATOR }, { "isfunction_handle", (void*)Nelson::FunctionHandleGateway::isfunction_handleBuiltin, 1, 1 }, { "function_handle_fieldnames", (void*)Nelson::FunctionHandleGateway::function_handle_fieldnamesBuiltin, 1, 1 }, diff --git a/modules/function_handle/builtin/cpp/function_handle_dispBuiltin.cpp b/modules/function_handle/builtin/cpp/function_handle_dispBuiltin.cpp index 32bed211db..a547fabba1 100644 --- a/modules/function_handle/builtin/cpp/function_handle_dispBuiltin.cpp +++ b/modules/function_handle/builtin/cpp/function_handle_dispBuiltin.cpp @@ -36,7 +36,7 @@ Nelson::FunctionHandleGateway::function_handle_dispBuiltin( { ArrayOfVector retval; nargoutcheck(nLhs, 0, 0); - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); ArrayOf Arg = argIn[0]; if (!Arg.isFunctionHandle()) { Error(ERROR_WRONG_ARGUMENT_1_TYPE_FUNCTION_HANDLE_EXPECTED); diff --git a/modules/graphics/builtin/cpp/Gateway.cpp b/modules/graphics/builtin/cpp/Gateway.cpp index 94313c9d2f..739d837821 100644 --- a/modules/graphics/builtin/cpp/Gateway.cpp +++ b/modules/graphics/builtin/cpp/Gateway.cpp @@ -43,7 +43,7 @@ using namespace Nelson; const std::wstring gatewayName = L"graphics"; //============================================================================= static const nlsGateway gateway[] = { - { "graphic_object_disp", (void*)Nelson::GraphicsGateway::graphic_object_dispBuiltin, 0, 1, + { "graphic_object_display", (void*)Nelson::GraphicsGateway::graphic_object_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, { "figure", (void*)Nelson::GraphicsGateway::figureBuiltin, 1, 2 }, { "groot", (void*)Nelson::GraphicsGateway::grootBuiltin, 1, 0 }, diff --git a/modules/graphics/builtin/cpp/graphic_object_dispBuiltin.cpp b/modules/graphics/builtin/cpp/graphic_object_dispBuiltin.cpp index a21853a290..2610a5a5c5 100644 --- a/modules/graphics/builtin/cpp/graphic_object_dispBuiltin.cpp +++ b/modules/graphics/builtin/cpp/graphic_object_dispBuiltin.cpp @@ -35,7 +35,7 @@ Nelson::GraphicsGateway::graphic_object_dispBuiltin( Evaluator* eval, int nLhs, const ArrayOfVector& argIn) { ArrayOfVector retval; - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); nargoutcheck(nLhs, 0, 0); ArrayOf paramGo = argIn[0]; if (paramGo.getDataClass() != NLS_GO_HANDLE) { diff --git a/modules/handle/builtin/cpp/Gateway.cpp b/modules/handle/builtin/cpp/Gateway.cpp index 6eb0ab0c3f..943e55f1b4 100644 --- a/modules/handle/builtin/cpp/Gateway.cpp +++ b/modules/handle/builtin/cpp/Gateway.cpp @@ -83,7 +83,7 @@ static const nlsGateway gateway[] = { CPP_BUILTIN_WITH_EVALUATOR }, { "handle_invoke", (void*)Nelson::HandleGateway::handle_invokeBuiltin, 1, 1, CPP_BUILTIN_WITH_EVALUATOR }, - { "handle_disp", (void*)Nelson::HandleGateway::handle_dispBuiltin, 0, 1, + { "handle_display", (void*)Nelson::HandleGateway::handle_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, { "handle_delete", (void*)Nelson::HandleGateway::handle_deleteBuiltin, 0, 1, CPP_BUILTIN_WITH_EVALUATOR }, diff --git a/modules/handle/builtin/cpp/handle_dispBuiltin.cpp b/modules/handle/builtin/cpp/handle_dispBuiltin.cpp index a79123c04c..e199a843f5 100644 --- a/modules/handle/builtin/cpp/handle_dispBuiltin.cpp +++ b/modules/handle/builtin/cpp/handle_dispBuiltin.cpp @@ -32,7 +32,7 @@ ArrayOfVector Nelson::HandleGateway::handle_dispBuiltin(Evaluator* eval, int nLhs, const ArrayOfVector& argIn) { ArrayOfVector retval; - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); nargoutcheck(nLhs, 0, 0); ArrayOf param1 = argIn[0]; if (!param1.isHandle()) { diff --git a/modules/integer/tests/bug_github_issue_#68.ref b/modules/integer/tests/bug_github_issue_#68.ref index 25643bc468..706eb37e1b 100644 --- a/modules/integer/tests/bug_github_issue_#68.ref +++ b/modules/integer/tests/bug_github_issue_#68.ref @@ -19,6 +19,7 @@ Columns 1 to 9 1 0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 1 0 + ans = - size: 4x9x2 @@ -39,6 +40,7 @@ Columns 1 to 9 1 0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 1 0 + ans = - size: 4x9x2 @@ -71,6 +73,7 @@ Columns 6 to 9 1 1 0 1 0 0 1 0 + ans = - size: 4x9x2 @@ -103,6 +106,7 @@ Columns 6 to 9 1 1 0 1 0 0 1 0 + ans = - size: 4x9x2 @@ -123,6 +127,7 @@ Columns 1 to 9 1 0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 1 0 + ans = - size: 4x9x2 @@ -143,6 +148,7 @@ Columns 1 to 9 1 0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 1 0 + ans = - size: 4x9x2 @@ -175,6 +181,7 @@ Columns 6 to 9 1 1 0 1 0 0 1 0 + ans = - size: 4x9x2 @@ -207,6 +214,7 @@ Columns 6 to 9 1 1 0 1 0 0 1 0 + ans = - size: 3x3 @@ -216,6 +224,7 @@ Columns 1 to 3 0 1 0 0 0 1 + ans = - size: 3x3 @@ -225,6 +234,7 @@ Columns 1 to 3 0 1 0 0 0 1 + ans = - size: 3x3 @@ -234,6 +244,7 @@ Columns 1 to 3 0 1 0 0 0 1 + ans = - size: 3x3 @@ -243,6 +254,7 @@ Columns 1 to 3 0 1 0 0 0 1 + ans = - size: 3x3 @@ -252,6 +264,7 @@ Columns 1 to 3 0 1 0 0 0 1 + ans = - size: 3x3 @@ -261,6 +274,7 @@ Columns 1 to 3 0 1 0 0 0 1 + ans = - size: 3x3 @@ -270,6 +284,7 @@ Columns 1 to 3 0 1 0 0 0 1 + ans = - size: 3x3 @@ -278,3 +293,4 @@ Columns 1 to 3 1 0 0 0 1 0 0 0 1 + diff --git a/modules/interpreter/src/cpp/Evaluator.cpp b/modules/interpreter/src/cpp/Evaluator.cpp index 07be360dda..077df31eed 100644 --- a/modules/interpreter/src/cpp/Evaluator.cpp +++ b/modules/interpreter/src/cpp/Evaluator.cpp @@ -1774,7 +1774,6 @@ Evaluator::assignStatement(AbstractSyntaxTreePtr t, bool printIt) bool isHandle = false; ArrayOf b = expression(t->right); std::string variableName = t->text; - b.name(variableName); if (t->down != nullptr) { b = assignExpression(t, b); isHandle = b.isHandle(); @@ -1798,7 +1797,7 @@ Evaluator::assignStatement(AbstractSyntaxTreePtr t, bool printIt) } } if (printIt) { - OverloadDisplay(this, b); + OverloadDisplay(this, b, variableName); } if (ticProfiling != 0) { internalProfileFunction stack @@ -1836,9 +1835,8 @@ Evaluator::statementType(AbstractSyntaxTreePtr t, bool printIt) } else if (t->opNum == (OP_SCALL)) { ArrayOfVector m = specialFunctionCall(t->down, printIt); if (m.size() > 0) { - m[0].name("ans"); context->insertVariable("ans", m[0]); - OverloadDisplay(this, m[0]); + OverloadDisplay(this, m[0], "ans"); } } else if (t->type == reserved_node) { switch (t->tokenNumber) { @@ -1912,8 +1910,7 @@ Evaluator::statementType(AbstractSyntaxTreePtr t, bool printIt) bUpdateAns = false; } if (printIt && (m.size() > 0) && (state < NLS_STATE_QUIT)) { - b.name("ans"); - OverloadDisplay(this, b); + OverloadDisplay(this, b, "ans"); } } else if (t->opNum == OP_RHS) { m = rhsExpression(t->down); @@ -1922,7 +1919,6 @@ Evaluator::statementType(AbstractSyntaxTreePtr t, bool printIt) } else { b = m[0]; if (printIt && (state < NLS_STATE_QUIT)) { - io->outputMessage("\n"); for (size_t j = 0; j < m.size(); j++) { if (m.size() > 1) { char buffer[1000]; @@ -1930,15 +1926,14 @@ Evaluator::statementType(AbstractSyntaxTreePtr t, bool printIt) buffer, _("\n%d of %d:\n").c_str(), (int)j + (int)1, (int)m.size()); io->outputMessage(buffer); } - OverloadDisplay(this, m[j]); + OverloadDisplay(this, m[j], m[j].name().empty() ? "ans" : m[j].name()); } } } } else { b = expression(t); if (printIt && (state < NLS_STATE_QUIT)) { - b.name("ans"); - OverloadDisplay(this, b); + OverloadDisplay(this, b, "ans"); } } if (state == NLS_STATE_QUIT || state == NLS_STATE_ABORT) { @@ -2483,7 +2478,6 @@ Evaluator::multiFunctionCall(AbstractSyntaxTreePtr t, bool printIt) s = saveLHS; while ((s != nullptr) && (m.size() > 0)) { ArrayOf c(assignExpression(s->down, m)); - c.name(s->down->text); if (!context->insertVariable(s->down->text, c)) { if (IsValidVariableName(s->down->text, true)) { Error(_W("Redefining permanent variable.")); @@ -2491,7 +2485,7 @@ Evaluator::multiFunctionCall(AbstractSyntaxTreePtr t, bool printIt) Error(_W("Valid variable name expected.")); } if (printIt) { - OverloadDisplay(this, c, false); + OverloadDisplay(this, c, s->down->text, false); } s = s->right; } @@ -4154,15 +4148,15 @@ Evaluator::buildPrompt() std::wstring prompt; if (depth > 0) { if (bpActive) { - prompt = L"-" + std::to_wstring(depth) + L"D-> "; + prompt = std::to_wstring(depth) + L"D>> "; } else { - prompt = L"-" + std::to_wstring(depth) + L"-> "; + prompt = std::to_wstring(depth) + L">> "; } } else { if (bpActive) { - prompt = L"D-> "; + prompt = L"D>> "; } else { - prompt = L"--> "; + prompt = L">> "; } } return prompt; diff --git a/modules/interpreter/src/cpp/OverloadDisplay.cpp b/modules/interpreter/src/cpp/OverloadDisplay.cpp index 34d9b3131d..9be0453c73 100644 --- a/modules/interpreter/src/cpp/OverloadDisplay.cpp +++ b/modules/interpreter/src/cpp/OverloadDisplay.cpp @@ -36,18 +36,19 @@ namespace Nelson { //============================================================================= void -OverloadDisplay(Evaluator* eval, ArrayOf a, bool fromBuiltin) +OverloadDisplay(Evaluator* eval, const ArrayOf& a, const std::string& name, bool fromBuiltin) { bool bSuccess = false; if (eval->mustOverloadBasicTypes()) { Context* context = eval->getContext(); if (context != nullptr) { FunctionDef* funcDef = nullptr; - std::string OverloadName = ClassName(a) + "_disp"; + std::string OverloadName = ClassName(a) + "_display"; if (context->lookupFunction(OverloadName, funcDef)) { bSuccess = true; ArrayOfVector argsIn; argsIn.push_back(a); + argsIn.push_back(ArrayOf::characterArrayConstructor(name)); int nargout = 0; funcDef->evaluateFunction(eval, argsIn, nargout); } @@ -56,20 +57,21 @@ OverloadDisplay(Evaluator* eval, ArrayOf a, bool fromBuiltin) if (!bSuccess) { bool needToOverload; uint64 ticProfile = Profiler::getInstance()->tic(); - DisplayVariable(eval->getInterface(), a, fromBuiltin, needToOverload); + DisplayVariable(eval->getInterface(), a, name, fromBuiltin, needToOverload); if (ticProfile != 0U) { - internalProfileFunction stack = computeProfileStack(eval, "disp", L"evaluator"); + internalProfileFunction stack = computeProfileStack(eval, "display", L"evaluator"); Profiler::getInstance()->toc(ticProfile, stack); } if (needToOverload) { Context* context = eval->getContext(); if (context != nullptr) { FunctionDef* funcDef = nullptr; - std::string OverloadName = ClassName(a) + "_disp"; + std::string OverloadName = ClassName(a) + "_display"; if (context->lookupFunction(OverloadName, funcDef)) { bSuccess = true; ArrayOfVector argsIn; argsIn.push_back(a); + argsIn.push_back(ArrayOf::characterArrayConstructor(name)); int nargout = 0; funcDef->evaluateFunction(eval, argsIn, nargout); } else { diff --git a/modules/interpreter/src/include/Evaluator.hpp b/modules/interpreter/src/include/Evaluator.hpp index 86158f9096..df2e73ca37 100644 --- a/modules/interpreter/src/include/Evaluator.hpp +++ b/modules/interpreter/src/include/Evaluator.hpp @@ -332,7 +332,7 @@ class NLSINTERPRETER_IMPEXP Evaluator /** * The RHS expression is used to represent an rvalue in an * assignment statement (or an implicit assignment such as - * -->2+3). The form of the AST depends on the head. If the + * >>2+3). The form of the AST depends on the head. If the * head identifier is a function name, then the form of the * AST is: * ident diff --git a/modules/interpreter/src/include/OverloadDisplay.hpp b/modules/interpreter/src/include/OverloadDisplay.hpp index 460770a0f9..207e4fc222 100644 --- a/modules/interpreter/src/include/OverloadDisplay.hpp +++ b/modules/interpreter/src/include/OverloadDisplay.hpp @@ -25,12 +25,13 @@ //============================================================================= #pragma once //============================================================================= +#include #include "ArrayOf.hpp" #include "Evaluator.hpp" #include "nlsInterpreter_exports.h" //============================================================================= namespace Nelson { NLSINTERPRETER_IMPEXP void -OverloadDisplay(Evaluator* eval, ArrayOf a, bool fromBuiltin = false); +OverloadDisplay(Evaluator* eval, const ArrayOf &a, const std::string &name, bool fromBuiltin = false); } //============================================================================= diff --git a/modules/mex/examples/mex_engine_demo_2.c b/modules/mex/examples/mex_engine_demo_2.c index 4347e3a98e..45c239ec6c 100644 --- a/modules/mex/examples/mex_engine_demo_2.c +++ b/modules/mex/examples/mex_engine_demo_2.c @@ -43,7 +43,7 @@ int main(int argc, char *argv[]) printf("\nEnter a Nelson command to evaluate.\n"); printf("For example: X = 1:5\n"); printf("To finish: exit\n"); - printf("--> "); + printf(">> "); fgets(cmd, 255, stdin); engEvalString(ep, cmd); diff --git a/modules/mpi/builtin/cpp/Gateway.cpp b/modules/mpi/builtin/cpp/Gateway.cpp index 2b2af1085f..33488ac2f6 100644 --- a/modules/mpi/builtin/cpp/Gateway.cpp +++ b/modules/mpi/builtin/cpp/Gateway.cpp @@ -54,7 +54,7 @@ const std::wstring gatewayName = L"mpi"; //============================================================================= static const nlsGateway gateway[] = { { "MPI_Init", (void*)Nelson::MpiGateway::MPI_InitBuiltin, 0, 0, CPP_BUILTIN_WITH_EVALUATOR }, - { "MPI_Comm_disp", (void*)Nelson::MpiGateway::MPI_Comm_dispBuiltin, 0, 1, + { "MPI_Comm_display", (void*)Nelson::MpiGateway::MPI_Comm_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, { "MPI_Comm_isvalid", (void*)Nelson::MpiGateway::MPI_Comm_isvalidBuiltin, 0, 1, CPP_BUILTIN_WITH_EVALUATOR }, diff --git a/modules/mpi/builtin/cpp/MPI_Comm_dispBuiltin.cpp b/modules/mpi/builtin/cpp/MPI_Comm_dispBuiltin.cpp index 9eec39b699..117ce09aed 100644 --- a/modules/mpi/builtin/cpp/MPI_Comm_dispBuiltin.cpp +++ b/modules/mpi/builtin/cpp/MPI_Comm_dispBuiltin.cpp @@ -38,7 +38,7 @@ Nelson::MpiGateway::MPI_Comm_dispBuiltin(Evaluator* eval, int nLhs, const ArrayO { ArrayOfVector retval; nargoutcheck(nLhs, 0, 0); - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); int flagInit = 0; MPI_Initialized(&flagInit); if (!flagInit) { diff --git a/modules/nig/tests/test_nig.ref b/modules/nig/tests/test_nig.ref index 0694d04fb2..594607254c 100644 --- a/modules/nig/tests/test_nig.ref +++ b/modules/nig/tests/test_nig.ref @@ -42,6 +42,7 @@ NLSGATEWAYREMOVE(gateway) NLSGATEWAYNAME() //=============================================================================' + ans = '//============================================================================= @@ -75,6 +76,7 @@ namespace Nelson { } //=============================================================================' + ans = '//============================================================================= @@ -175,3 +177,4 @@ ArrayOfVector Nelson::ExampleGateway::example_nig_sumBuiltin(Evaluator* eval, in return retval; } //=============================================================================' + diff --git a/modules/overload/examples/complex/complexObj_disp.m b/modules/overload/examples/complex/complexObj_display.m similarity index 97% rename from modules/overload/examples/complex/complexObj_disp.m rename to modules/overload/examples/complex/complexObj_display.m index 84c875bf46..54831a0e7f 100644 --- a/modules/overload/examples/complex/complexObj_disp.m +++ b/modules/overload/examples/complex/complexObj_display.m @@ -23,7 +23,7 @@ % License along with this program. If not, see . % LICENCE_BLOCK_END %============================================================================= -function complexObj_disp(obj) +function complexObj_display(obj, name) disp('complexObj_disp:') disp('real part'); disp(obj.r); diff --git a/modules/qml_engine/builtin/cpp/Gateway.cpp b/modules/qml_engine/builtin/cpp/Gateway.cpp index eb8decbfc4..665124088d 100644 --- a/modules/qml_engine/builtin/cpp/Gateway.cpp +++ b/modules/qml_engine/builtin/cpp/Gateway.cpp @@ -89,7 +89,7 @@ static const nlsGateway gateway[] = { { "qml_createqquickview", (void*)Nelson::QmlEngineGateway::qml_createqquickviewBuiltin, 1, 1 }, { "QObject_undefine", (void*)Nelson::QmlEngineGateway::QObject_undefineBuiltin, 0, 2 }, { "QObject_delete", (void*)Nelson::QmlEngineGateway::QObject_deleteBuiltin, 0, 1 }, - { "QObject_disp", (void*)Nelson::QmlEngineGateway::QObject_dispBuiltin, 0, 1, + { "QObject_display", (void*)Nelson::QmlEngineGateway::QObject_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, { "QObject_get", (void*)Nelson::QmlEngineGateway::QObject_getBuiltin, 1, 2 }, { "QObject_set", (void*)Nelson::QmlEngineGateway::QObject_setBuiltin, 1, 3 }, diff --git a/modules/qml_engine/builtin/cpp/QObject_dispBuiltin.cpp b/modules/qml_engine/builtin/cpp/QObject_dispBuiltin.cpp index 41f21c66fd..3921d1f7d9 100644 --- a/modules/qml_engine/builtin/cpp/QObject_dispBuiltin.cpp +++ b/modules/qml_engine/builtin/cpp/QObject_dispBuiltin.cpp @@ -32,7 +32,7 @@ using namespace Nelson; ArrayOfVector Nelson::QmlEngineGateway::QObject_dispBuiltin(Evaluator* eval, int nLhs, const ArrayOfVector& argIn) { - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); nargoutcheck(nLhs, 0, 0); ArrayOf param1 = argIn[0]; DispQmlHandleObject(eval, param1); diff --git a/modules/sparse/builtin/cpp/Gateway.cpp b/modules/sparse/builtin/cpp/Gateway.cpp index 55e6b20be5..2fca0e8b10 100644 --- a/modules/sparse/builtin/cpp/Gateway.cpp +++ b/modules/sparse/builtin/cpp/Gateway.cpp @@ -52,9 +52,9 @@ const std::wstring gatewayName = L"sparse"; //============================================================================= static const nlsGateway gateway[] = { { "sparse", (void*)Nelson::SparseGateway::sparseBuiltin, 1, 6, CPP_BUILTIN_WITH_EVALUATOR }, - { "sparsedouble_disp", (void*)Nelson::SparseGateway::sparsedouble_dispBuiltin, 0, 1, + { "sparsedouble_display", (void*)Nelson::SparseGateway::sparsedouble_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, - { "sparselogical_disp", (void*)Nelson::SparseGateway::sparselogical_dispBuiltin, 0, 1, + { "sparselogical_display", (void*)Nelson::SparseGateway::sparselogical_dispBuiltin, 0, 2, CPP_BUILTIN_WITH_EVALUATOR }, { "full", (void*)Nelson::SparseGateway::fullBuiltin, 1, 1, CPP_BUILTIN_WITH_EVALUATOR }, { "sparsedouble_uminus", (void*)Nelson::SparseGateway::sparsedouble_uminusBuiltin, 1, 1, diff --git a/modules/sparse/builtin/cpp/sparsedouble_dispBuiltin.cpp b/modules/sparse/builtin/cpp/sparsedouble_dispBuiltin.cpp index 5cd67f5602..f5b26e465d 100644 --- a/modules/sparse/builtin/cpp/sparsedouble_dispBuiltin.cpp +++ b/modules/sparse/builtin/cpp/sparsedouble_dispBuiltin.cpp @@ -35,7 +35,7 @@ Nelson::SparseGateway::sparsedouble_dispBuiltin( { ArrayOfVector retval; nargoutcheck(nLhs, 0, 0); - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); if (!argIn[0].isSparse()) { Error(ERROR_WRONG_ARGUMENT_1_TYPE_SPARSE_DOUBLE_EXPECTED); } else { diff --git a/modules/sparse/builtin/cpp/sparselogical_dispBuiltin.cpp b/modules/sparse/builtin/cpp/sparselogical_dispBuiltin.cpp index 84984c67b7..971161507f 100644 --- a/modules/sparse/builtin/cpp/sparselogical_dispBuiltin.cpp +++ b/modules/sparse/builtin/cpp/sparselogical_dispBuiltin.cpp @@ -35,7 +35,7 @@ Nelson::SparseGateway::sparselogical_dispBuiltin( { ArrayOfVector retval(nLhs); nargoutcheck(nLhs, 0, 0); - nargincheck(argIn, 1, 1); + nargincheck(argIn, 1, 2); if (!argIn[0].isSparse()) { Error(ERROR_WRONG_ARGUMENT_1_TYPE_SPARSE_DOUBLE_EXPECTED); } else { diff --git a/modules/sparse/tests/bug_github_issue_#116.ref b/modules/sparse/tests/bug_github_issue_#116.ref index e059e80ffa..c02aead572 100644 --- a/modules/sparse/tests/bug_github_issue_#116.ref +++ b/modules/sparse/tests/bug_github_issue_#116.ref @@ -1,8 +1,4 @@ -a = - All zero sparse: 20000000000000-by-2 -b = - All zero sparse: 20000000000000-by-2 diff --git a/modules/stream_manager/src/cpp/DisplayVariable.cpp b/modules/stream_manager/src/cpp/DisplayVariable.cpp index 3e0d4f7d46..75f9e8a240 100644 --- a/modules/stream_manager/src/cpp/DisplayVariable.cpp +++ b/modules/stream_manager/src/cpp/DisplayVariable.cpp @@ -36,7 +36,8 @@ namespace Nelson { //============================================================================= void -DisplayVariable(Interface* io, const ArrayOf& A, bool fromDispBuiltin, bool& needToOverload) +DisplayVariable(Interface* io, const ArrayOf& A, const std::string& name, bool fromDispBuiltin, + bool& needToOverload) { needToOverload = false; if (io == nullptr) { @@ -46,11 +47,9 @@ DisplayVariable(Interface* io, const ArrayOf& A, bool fromDispBuiltin, bool& nee needToOverload = true; return; } - std::string variableName = A.name(); - if (!variableName.empty()) { - if (variableName == "ans") - io->outputMessage("\n"); - io->outputMessage(variableName + " =\n\n"); + if (!name.empty()) { + io->outputMessage("\n"); + io->outputMessage(name + " =\n\n"); } switch (A.getDataClass()) { case NLS_CELL_ARRAY: { @@ -90,6 +89,9 @@ DisplayVariable(Interface* io, const ArrayOf& A, bool fromDispBuiltin, bool& nee needToOverload = true; } break; } + if (!needToOverload && !name.empty()) { + io->outputMessage("\n"); + } } //============================================================================= } // namespace Nelson diff --git a/modules/stream_manager/src/include/DisplayVariable.hpp b/modules/stream_manager/src/include/DisplayVariable.hpp index cd1699c60f..e9c3ba071f 100644 --- a/modules/stream_manager/src/include/DisplayVariable.hpp +++ b/modules/stream_manager/src/include/DisplayVariable.hpp @@ -32,7 +32,8 @@ namespace Nelson { //============================================================================= NLSSTREAM_MANAGER_IMPEXP void -DisplayVariable(Interface* io, const ArrayOf& A, bool fromDispBuiltin, bool& needToOverload); +DisplayVariable(Interface* io, const ArrayOf& A, const std::string& name, bool fromDispBuiltin, + bool& needToOverload); //============================================================================= } // namespace Nelson //============================================================================= diff --git a/modules/stream_manager/tests/test_NaN_display.m b/modules/stream_manager/tests/test_NaN_display.m index de489c0250..a314bb402d 100644 --- a/modules/stream_manager/tests/test_NaN_display.m +++ b/modules/stream_manager/tests/test_NaN_display.m @@ -24,30 +24,38 @@ % LICENCE_BLOCK_END %============================================================================= R = evalc('A = [NaN 1 3 NaN 2]'); -REF = 'A = +REF = ' +A = NaN 1 3 NaN 2 + '; assert_isequal(R, REF); %============================================================================= R = evalc('A = single([NaN 1 3 NaN 2])'); -REF = 'A = +REF = ' +A = NaN 1 3 NaN 2 + '; assert_isequal(R, REF); %============================================================================= R = evalc('A = single([NaN 1 3.4 NaN 2])'); -REF = 'A = +REF = ' +A = NaN 1.0000 3.4000 NaN 2.0000 + '; assert_isequal(R, REF); %============================================================================= R = evalc('A = [NaN 1 3.4 NaN 2]'); -REF = 'A = +REF = ' +A = NaN 1.0000 3.4000 NaN 2.0000 + '; assert_isequal(R, REF); %============================================================================= diff --git a/modules/string/tests/test_ndarraychar_disp.m b/modules/string/tests/test_ndarraychar_display.m similarity index 100% rename from modules/string/tests/test_ndarraychar_disp.m rename to modules/string/tests/test_ndarraychar_display.m diff --git a/modules/string/tests/test_ndarraychar_disp.ref b/modules/string/tests/test_ndarraychar_display.ref similarity index 99% rename from modules/string/tests/test_ndarraychar_disp.ref rename to modules/string/tests/test_ndarraychar_display.ref index c4e628b0bf..ebd24bba2f 100644 --- a/modules/string/tests/test_ndarraychar_disp.ref +++ b/modules/string/tests/test_ndarraychar_display.ref @@ -17,3 +17,4 @@ Columns 1 to 3 Columns 1 to 3 'TWZ' + diff --git a/modules/text_editor/tests/test_smartindent.ref b/modules/text_editor/tests/test_smartindent.ref index f495092153..44fd7552d9 100644 --- a/modules/text_editor/tests/test_smartindent.ref +++ b/modules/text_editor/tests/test_smartindent.ref @@ -15,3 +15,4 @@ ans = disp('not ok') end endfunction' + diff --git a/modules/webtools/functions/weboptions_disp.m b/modules/webtools/functions/weboptions_display.m similarity index 97% rename from modules/webtools/functions/weboptions_disp.m rename to modules/webtools/functions/weboptions_display.m index 588a8ff087..7b368609b1 100644 --- a/modules/webtools/functions/weboptions_disp.m +++ b/modules/webtools/functions/weboptions_display.m @@ -23,7 +23,7 @@ % License along with this program. If not, see . % LICENCE_BLOCK_END %============================================================================= -function weboptions_disp(options) +function weboptions_display(options, name) r = struct(options); d = evalc('disp(r);'); disp(replace(d, '', ''))