Changeset View
Changeset View
Standalone View
Standalone View
src/backends/R/rserver/rserver.cpp
Show First 20 Lines • Show All 420 Lines • ▼ Show 20 Line(s) | |||||
421 | // I am not sure whether or not asking the server with each keypress if what he typed was | 421 | // I am not sure whether or not asking the server with each keypress if what he typed was | ||
422 | // acceptable or not is a good idea. I'll leave it under investigation, let it be this way just for now | 422 | // acceptable or not is a good idea. I'll leave it under investigation, let it be this way just for now | ||
423 | // ~Landswellsong | 423 | // ~Landswellsong | ||
424 | 424 | | |||
425 | void RServer::listSymbols() | 425 | void RServer::listSymbols() | ||
426 | { | 426 | { | ||
427 | // setStatus(RServer::Busy); | 427 | // setStatus(RServer::Busy); | ||
428 | 428 | | |||
429 | QStringList vars,funcs, namespaces; | 429 | QStringList vars, values, funcs; | ||
430 | int errorOccurred; // TODO: error checks | 430 | int errorOccurred; // TODO: error checks | ||
431 | 431 | | |||
432 | /* Obtaining a list of user namespace objects */ | 432 | /* Obtaining a list of user namespace objects */ | ||
433 | SEXP usr=PROTECT(R_tryEval(lang1(install("ls")),NULL,&errorOccurred)); | 433 | SEXP usr=PROTECT(R_tryEval(lang1(install("ls")),NULL,&errorOccurred)); | ||
434 | for (int i=0;i<length(usr);i++) | 434 | for (int i=0;i<length(usr);i++) | ||
435 | vars<<QLatin1String(translateCharUTF8(STRING_ELT(usr,i))); | 435 | { | ||
436 | SEXP variable = STRING_ELT(usr,i); | ||||
437 | vars << QString::fromUtf8(translateCharUTF8(variable)); | ||||
438 | SEXP value = findVar(installChar(variable), R_GlobalEnv); | ||||
439 | SEXP valueAsString = PROTECT(R_tryEval(lang2(install("toString"),value),NULL,&errorOccurred)); | ||||
440 | values << QString::fromUtf8(translateCharUTF8(asChar(valueAsString))); | ||||
441 | } | ||||
436 | UNPROTECT(1); | 442 | UNPROTECT(1); | ||
437 | 443 | | |||
438 | /* Obtaining a list of active packages */ | 444 | /* Obtaining a list of active packages */ | ||
439 | SEXP packages=PROTECT(R_tryEval(lang1(install("search")),NULL,&errorOccurred)); | 445 | SEXP packages=PROTECT(R_tryEval(lang1(install("search")),NULL,&errorOccurred)); | ||
440 | //int i=1; // HACK to prevent scalability issues | 446 | //int i=1; // HACK to prevent scalability issues | ||
441 | for (int i=1;i<length(packages);i++) // Package #0 is user environment, so starting with 1 | 447 | for (int i=1;i<length(packages);i++) // Package #0 is user environment, so starting with 1 | ||
442 | { | 448 | { | ||
443 | char pos[32]; | 449 | char pos[32]; | ||
444 | sprintf(pos,"%d",i+1); | 450 | sprintf(pos,"%d",i+1); | ||
445 | SEXP f=PROTECT(R_tryEval(lang2(install("ls"),ScalarInteger(i+1)),NULL,&errorOccurred)); | 451 | SEXP f=PROTECT(R_tryEval(lang2(install("ls"),ScalarInteger(i+1)),NULL,&errorOccurred)); | ||
446 | for (int i=0;i<length(f);i++) | 452 | for (int i=0;i<length(f);i++) | ||
447 | funcs<<QLatin1String(translateCharUTF8(STRING_ELT(f,i))); | 453 | funcs<<QString::fromUtf8(translateCharUTF8(STRING_ELT(f,i))); | ||
448 | UNPROTECT(1); | 454 | UNPROTECT(1); | ||
449 | } | 455 | } | ||
450 | UNPROTECT(1); | 456 | UNPROTECT(1); | ||
451 | 457 | | |||
452 | emit symbolList(vars,funcs); | 458 | emit symbolList(vars, values, funcs); | ||
453 | 459 | | |||
454 | // setStatus(RServer::Idle); | 460 | // setStatus(RServer::Idle); | ||
455 | } | 461 | } | ||
456 | 462 | | |||
457 | void RServer::setStatus(Status status) | 463 | void RServer::setStatus(Status status) | ||
458 | { | 464 | { | ||
459 | if(m_status!=status) | 465 | if(m_status!=status) | ||
460 | { | 466 | { | ||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |