MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / setStringValue

Method setStringValue

Engine/source/console/consoleInternal.cpp:495–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493}
494
495void ConsoleValue::setStringValue(const char * value)
496{
497 if (value == NULL) value = typeValueEmpty;
498
499 if(type <= ConsoleValue::TypeInternalString)
500 {
501 // Let's not remove empty-string-valued global vars from the dict.
502 // If we remove them, then they won't be exported, and sometimes
503 // it could be necessary to export such a global. There are very
504 // few empty-string global vars so there's no performance-related
505 // need to remove them from the dict.
506/*
507 if(!value[0] && name[0] == '$')
508 {
509 gEvalState.globalVars.remove(this);
510 return;
511 }
512*/
513 if (value == typeValueEmpty)
514 {
515 if (bufferLen > 0)
516 {
517 dFree(sval);
518 bufferLen = 0;
519 }
520
521 sval = typeValueEmpty;
522 fval = 0.f;
523 ival = 0;
524 type = TypeInternalString;
525 return;
526 }
527
528 U32 stringLen = dStrlen(value);
529
530 // If it's longer than 256 bytes, it's certainly not a number.
531 //
532 // (This decision may come back to haunt you. Shame on you if it
533 // does.)
534 if(stringLen < 256)
535 {
536 fval = dAtof(value);
537 ival = dAtoi(value);
538 }
539 else
540 {
541 fval = 0.f;
542 ival = 0;
543 }
544
545 // may as well pad to the next cache line
546 U32 newLen = ((stringLen + 1) + 15) & ~15;
547
548 if(bufferLen == 0)
549 sval = (char *) dMalloc(newLen);
550 else if(newLen > bufferLen)
551 sval = (char *) dRealloc(sval, newLen);
552

Callers 10

setStringVariableMethod · 0.45
setCopyVariableMethod · 0.45
execMethod · 0.45
SimConsoleEventMethod · 0.45
setBoolVariableFunction · 0.45
postConsoleInputFunction · 0.45
console.cppFile · 0.45
setVariableMethod · 0.45
pushValueMethod · 0.45
pushStringMethod · 0.45

Calls 6

dStrcpyFunction · 0.85
setDataFunction · 0.85
dAtofFunction · 0.70
dAtoiFunction · 0.70
dFreeFunction · 0.50
dStrlenFunction · 0.50

Tested by

no test coverage detected