summaryrefslogtreecommitdiff
path: root/graphics/asymptote/main.cc
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-12-28 03:01:00 +0000
committerNorbert Preining <norbert@preining.info>2021-12-28 03:01:00 +0000
commitecdf859b6ce481abfd530425dcf6f0f764bd0001 (patch)
tree13bc161dc046876ac6c92fce5f9f5034ba9aa573 /graphics/asymptote/main.cc
parent790995b7e79697514364450bf9c04f1b8d500838 (diff)
CTAN sync 202112280300
Diffstat (limited to 'graphics/asymptote/main.cc')
-rw-r--r--graphics/asymptote/main.cc47
1 files changed, 38 insertions, 9 deletions
diff --git a/graphics/asymptote/main.cc b/graphics/asymptote/main.cc
index e4eb1dc590..4359111829 100644
--- a/graphics/asymptote/main.cc
+++ b/graphics/asymptote/main.cc
@@ -44,6 +44,10 @@
#include "interact.h"
#include "fileio.h"
+#ifdef HAVE_LSP
+#include "lspserv.h"
+#endif
+
#include "stack.h"
using namespace settings;
@@ -87,7 +91,7 @@ int sigsegv_handler (void *, int emergency)
}
#endif
-void setsignal(RETSIGTYPE (*handler)(int))
+void setsignal(void (*handler)(int))
{
#ifdef HAVE_LIBSIGSEGV
char mystack[16384];
@@ -126,6 +130,11 @@ struct Args
Args(int argc, char **argv) : argc(argc), argv(argv) {}
};
+int returnCode()
+{
+ return em.processStatus() || interact::interactive ? 0 : 1;
+}
+
void *asymain(void *A)
{
setsignal(signalHandler);
@@ -134,11 +143,32 @@ void *asymain(void *A)
if(interactive) {
Signal(SIGINT,interruptHandler);
- processPrompt();
+#ifdef HAVE_LSP
+ if (getSetting<bool>("lsp")) {
+ AsymptoteLsp::LspLog log;
+ auto jsonHandler=std::make_shared<lsp::ProtocolJsonHandler>();
+ auto endpoint=std::make_shared<GenericEndpoint>(log);
+
+ unique_ptr<AsymptoteLsp::AsymptoteLspServer> asylsp;
+
+ if(getSetting<string>("lspport") != "") {
+ asylsp=make_unique<AsymptoteLsp::TCPAsymptoteLSPServer>(
+ (std::string)getSetting<string>("lsphost").c_str(),
+ (std::string)getSetting<string>("lspport").c_str(),
+ jsonHandler, endpoint, log);
+ } else {
+ asylsp=make_unique<AsymptoteLsp::AsymptoteLspServer>(jsonHandler,
+ endpoint,
+ log);
+ }
+ asylsp->start();
+ } else
+#endif
+ processPrompt();
} else if (getSetting<bool>("listvariables") && numArgs()==0) {
try {
doUnrestrictedList();
- } catch(handled_error) {
+ } catch(handled_error const&) {
em.statusError();
}
} else {
@@ -155,7 +185,7 @@ void *asymain(void *A)
processFile("-",true);
try {
setOptions(args->argc,args->argv);
- } catch(handled_error) {
+ } catch(handled_error const&) {
em.statusError();
}
if(inpipe < 0) break;
@@ -166,7 +196,7 @@ void *asymain(void *A)
try {
if(ind < n-1)
setOptions(args->argc,args->argv);
- } catch(handled_error) {
+ } catch(handled_error const&) {
em.statusError();
}
}
@@ -193,12 +223,12 @@ void *asymain(void *A)
}
#endif
#endif
- exit(em.processStatus() || interact::interactive ? 0 : 1);
+ exit(returnCode());
}
void exitHandler(int)
{
- exit(0);
+ exit(returnCode());
}
int main(int argc, char *argv[])
@@ -211,7 +241,7 @@ int main(int argc, char *argv[])
try {
setOptions(argc,argv);
- } catch(handled_error) {
+ } catch(handled_error const&) {
em.statusError();
}
@@ -256,4 +286,3 @@ GC_API void GC_CALL GC_throw_bad_alloc() {
std::bad_alloc();
}
#endif
-