Skip to content

Commit

Permalink
Removed class String from Core.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkie committed Apr 7, 2010
1 parent 8d0f2de commit c8e8d5d
Show file tree
Hide file tree
Showing 79 changed files with 2,919 additions and 5,119 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ DFILES_PLATFORM_WIN = binding/win32/gdipluscolormatrix.d binding/win32/gdiplusin
DFILES_PLATFORM_XOMB = platform/xomb/main.d platform/xomb/common.d platform/xomb/scaffold.d platform/xomb/vars.d platform/xomb/console.d platform/xomb/definitions.d platform/xomb/scaffolds/wave.d platform/xomb/scaffolds/graphics.d platform/xomb/scaffolds/thread.d platform/xomb/scaffolds/menu.d platform/xomb/scaffolds/window.d platform/xomb/scaffolds/view.d platform/xomb/scaffolds/color.d platform/xomb/scaffolds/file.d platform/xomb/scaffolds/socket.d platform/xomb/scaffolds/app.d platform/xomb/scaffolds/time.d platform/xomb/oscontrolinterface.d

DFILES_ANALYZING = analyzing/debugger.d
DFILES_CORE = core/tostring.d core/locales/en_us.d core/locales/fr_fr.d core/date.d core/locale.d core/variant.d core/list.d core/exception.d core/event.d core/library.d core/system.d core/random.d core/regex.d core/arguments.d core/definitions.d core/application.d core/time.d core/timezone.d core/unicode.d core/endian.d core/stream.d core/string.d core/main.d core/color.d
DFILES_CORE = core/locales/en_us.d core/locales/fr_fr.d core/date.d core/locale.d core/variant.d core/list.d core/exception.d core/event.d core/library.d core/system.d core/random.d core/regex.d core/arguments.d core/definitions.d core/application.d core/time.d core/timezone.d core/unicode.d core/endian.d core/stream.d core/string.d core/main.d core/color.d
DFILES_GUI = gui/container.d gui/trackbar.d gui/radiogroup.d gui/progressbar.d gui/togglefield.d gui/listfield.d gui/listbox.d gui/vscrollbar.d gui/hscrollbar.d gui/button.d gui/textfield.d gui/window.d gui/widget.d gui/application.d
DFILES_UTILS = utils/stack.d utils/linkedlist.d utils/fibonacci.d utils/heap.d
DFILES_PARSING = parsing/d/trees.d parsing/d/addexprunit.d parsing/d/andexprunit.d parsing/d/assignexprunit.d parsing/d/blockstmtunit.d parsing/d/switchstmtunit.d parsing/d/casestmtunit.d parsing/d/defaultstmtunit.d parsing/d/breakstmtunit.d parsing/d/continuestmtunit.d parsing/d/gotostmtunit.d parsing/d/returnstmtunit.d parsing/d/volatilestmtunit.d parsing/d/throwstmtunit.d parsing/d/postfixexprlistunit.d parsing/d/cmpexprunit.d parsing/d/conditionalexprunit.d parsing/d/declarationunit.d parsing/d/expressionunit.d parsing/d/importdeclunit.d parsing/d/isexprunit.d parsing/d/lexer.d parsing/d/logicalandexprunit.d parsing/d/logicalorexprunit.d parsing/d/moduledeclunit.d parsing/d/moduleunit.d parsing/d/mulexprunit.d parsing/d/nodes.d parsing/d/orexprunit.d parsing/d/parser.d parsing/d/postfixexprunit.d parsing/d/primaryexprunit.d parsing/d/shiftexprunit.d parsing/d/staticunit.d parsing/d/declaratorunit.d parsing/d/declaratorsuffixunit.d parsing/d/declaratortypeunit.d parsing/d/tokens.d parsing/d/enumdeclunit.d parsing/d/typeunit.d parsing/d/enumbodyunit.d parsing/d/aggregatedeclunit.d parsing/d/aggregatebodyunit.d parsing/d/classbodyunit.d parsing/d/templatebodyunit.d parsing/d/interfacebodyunit.d parsing/d/classdeclunit.d parsing/d/interfacedeclunit.d parsing/d/constructorunit.d parsing/d/destructorunit.d parsing/d/parameterlistunit.d parsing/d/functionbodyunit.d parsing/d/staticifunit.d parsing/d/versionunit.d parsing/d/debugunit.d parsing/d/unittestunit.d parsing/d/parameterunit.d parsing/d/basictypeunit.d parsing/d/statementunit.d parsing/d/pragmastmtunit.d parsing/d/staticassertunit.d parsing/d/foreachstmtunit.d parsing/d/scopedstmtunit.d parsing/d/forstmtunit.d parsing/d/typedeclarationunit.d parsing/d/unaryexprunit.d parsing/d/xorexprunit.d parsing/ast.d parsing/lexer.d parsing/token.d parsing/parser.d parsing/options.d parsing/cfg.d parsing/parseunit.d
Expand All @@ -56,7 +56,7 @@ DFILES_CONSOLE = console/prompt.d
DFILES_TUI = tui/filebox.d tui/container.d tui/dialog.d tui/window.d tui/application.d tui/widget.d tui/telnet.d tui/buffer.d tui/vt100.d tui/listbox.d tui/textfield.d tui/label.d tui/textbox.d tui/codebox.d tui/tabbox.d
DFILES_SCRIPTING = scripting/lua.d
DFILES_BINDING = binding/opengl/gl.d binding/opengl/glu.d binding/lua.d
DFILES_INTERFACES = interfaces/container.d interfaces/mod.d
DFILES_INTERFACES = interfaces/container.d
DFILES_MATH = math/currency.d math/fixed.d math/integer.d math/common.d math/vector.d math/matrix.d math/mathobject.d
DFILES_OPENGL = opengl/window.d opengl/texture.d opengl/light.d
DFILES_SPECS = specs/test.d
Expand Down
8 changes: 4 additions & 4 deletions analyzing/debugger.d
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ public:
if (w !is null) {
// get class name
ClassInfo ci = w.classinfo;
String className = new String(ci.name);
string className = ci.name.dup;

Console.putln(" window: ", className.array, " [", w.text.array, "]");
Console.putln(" window: ", className, " [", w.text, "]");
}

if (t !is null) {
// get class name
ClassInfo ci = t.classinfo;
String className = new String(ci.name);
string className = ci.name.dup;

Console.putln(" thread: ", className.array);
Console.putln(" thread: ", className);
}

Console.setColor(fgColor.White);
Expand Down
95 changes: 44 additions & 51 deletions console/prompt.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module console.prompt;

import core.string;
import core.unicode;

import io.console;

Expand All @@ -14,25 +15,19 @@ import utils.linkedlist;
class Prompt {
// TODO: Allow ANSI emulated prompt strings
this() {
_prompt = new String("");
}

// Description: This will set the prompt string that will precede the input.
// prompt: A string representing the prompt.
void prompt(String prompt) {
_prompt = new String(prompt);
_prompt = "";
}

// Description: This will set the prompt string that will precede the input.
// prompt: A string representing the prompt.
void prompt(string prompt) {
_prompt = new String(prompt);
_prompt = prompt.dup;
}

// Description: This function will return the current prompt.
// Returns: The current prompt.
String prompt() {
return new String(_prompt);
string prompt() {
return _prompt.dup;
}

void promptColor(fgColor fgClr) {
Expand All @@ -51,7 +46,7 @@ class Prompt {
}

if (bufferSize != 0) {
_lineBuffer = new LinkedList!(String)();
_lineBuffer = new LinkedList!(string)();
}
else {
_lineBuffer = null;
Expand All @@ -62,18 +57,18 @@ class Prompt {

// Description: This will display the prompt and return the line typed by the user.
// Returns: The line typed by the user.
String line() {
string line() {
// the current displayed line
String line;
string line;

// the 'working' line being edited
String workingLine;
string workingLine;

// Print out the prompt string

Console.setColor(_promptClr);

Console.put(_prompt.array);
Console.put(_prompt);

// Go into a key loop, wait for a return
// On any special key, fire the callback and expect a result (for instance, on TAB)
Expand All @@ -83,7 +78,7 @@ class Prompt {

uint code;

line = new String("");
line = "";

workingLine = line;
if (_lineBuffer !is null) {
Expand All @@ -105,23 +100,23 @@ class Prompt {
else if (code == Key.Backspace) {
// backspace

if (line.length() > 0 && _pos > 0) {
if (line.length > 0 && _pos > 0) {
Console.put(chr);
Console.put(' ');
Console.put(chr);

if (_pos == line.length()) {
line = line.subString(0, line.length()-1);
if (_pos == line.length) {
line = line.substring(0, line.length-1);
}
else {
String newLine = line.subString(0, _pos-1);
String restLine = line.subString(_pos);
newLine.append(restLine);
string newLine = line.substring(0, _pos-1);
string restLine = line.substring(_pos);
newLine ~= restLine;

Console.put(restLine.array);
Console.put(restLine);
Console.put(' ');

for (uint i=0; i<=restLine.length(); i++) {
for (uint i=0; i<=restLine.length; i++) {
Console.put(cast(char)0x8);
}

Expand All @@ -144,7 +139,7 @@ class Prompt {
}
}
else if (code == Key.Right) {
if (_pos < line.length()) {
if (_pos < line.length) {
Console.setRelative(1,0);

_pos++;
Expand All @@ -156,32 +151,32 @@ class Prompt {
// And then the line buffer spits out
// the previous line submitted
if (_lineBuffer !is null) {
if (_bufferPos+1 < cast(int)_lineBuffer.length() && _lineBuffer.length() > 0) {
if (_bufferPos+1 < cast(int)_lineBuffer.length && _lineBuffer.length > 0) {
// grab the line from the line buffer

_bufferPos++;
line = _lineBuffer.peekAt(_bufferPos);

uint i;

if (line.length() < _pos) {
for (i=line.length(); i<_pos; i++) {
if (line.length < _pos) {
for (i=line.length; i<_pos; i++) {
Console.put(cast(char)0x8);
Console.put(' ');
Console.put(cast(char)0x8);
}

_pos = line.length();
_pos = line.length;
}

for (i=0; i<_pos; i++) {
Console.put(cast(char)0x8);
}

// print the line
Console.put(line.array);
Console.put(line);

_pos = line.length();
_pos = line.length;
}
}
}
Expand Down Expand Up @@ -209,58 +204,56 @@ class Prompt {

uint i;

if (line.length() < _pos) {
for (i=line.length(); i<_pos; i++) {
if (line.length < _pos) {
for (i=line.length; i<_pos; i++) {
Console.put(cast(char)0x8);
Console.put(' ');
Console.put(cast(char)0x8);
}

_pos = line.length();
_pos = line.length;
}

for (i=0; i<_pos; i++) {
Console.put(cast(char)0x8);
}

// print the line
Console.put(line.array);
Console.put(line);

// erase the rest of the previous line

_pos = line.length();
_pos = line.length;
}
}
else if (chr != 0) {
// written character

if (_pos == line.length()) {
if (_pos == line.length) {
Console.put(chr);
line.appendChar(chr);
line ~= chr;
}
else if (_pos == 0) {
String newLine = new String("");
newLine.appendChar(chr);
newLine.append(line);
string newLine = "" ~ Unicode.toUtf8([chr]) ~ line;

Console.put(newLine.array);
Console.put(newLine);

for (uint i=1; i<newLine.length(); i++) {
for (uint i=1; i<newLine.length; i++) {
Console.put(cast(char)0x8);
}

line = newLine;
}
else {
Console.put(chr);
String leftLine = line.subString(0, _pos);
leftLine.appendChar(chr);
String rightLine = line.subString(_pos);
leftLine.append(rightLine);
string leftLine = line.substring(0, _pos);
leftLine ~= chr;
string rightLine = line.substring(_pos);
leftLine ~= rightLine;

Console.put(rightLine.array);
Console.put(rightLine);

for (uint i=0; i<rightLine.length(); i++) {
for (uint i=0; i<rightLine.length; i++) {
Console.put(cast(char)0x8);
}

Expand Down Expand Up @@ -294,11 +287,11 @@ class Prompt {
protected:

// the prompt string, for instance "# " or "C:\>"
String _prompt;
string _prompt;
fgColor _promptClr = fgColor.White;
fgColor _clr = fgColor.White;

LinkedList!(String) _lineBuffer;
LinkedList!(string) _lineBuffer;
int _bufferSize;
int _bufferPos;

Expand Down
2 changes: 1 addition & 1 deletion core/arguments.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import core.string;
import core.list;

// Description: This class holds the command line arguments that were passed into the app and will aid in parsing them.
class Arguments : List!(String) {
class Arguments : List!(string) {
public:

this() {
Expand Down
4 changes: 0 additions & 4 deletions core/exception.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ template CustomException(char[] name, char[] error, char[] error_more) {
super("`~error~`");
}
this(String msg) {
super("`~error~error_more~`" ~ msg.toString());
}
this(string msg) {
super("`~error~error_more~`" ~ msg);
}
Expand Down
17 changes: 2 additions & 15 deletions core/library.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@ import scaffold.system;
// Description: This class will allow runtime linking to dynamic libraries.
class Library {

// Description: This constructor will dynamically load the library found at the given framework path.
// path: The path to the library in question.
this(String path) {
SystemLoadLibrary(_pfvars, path);
}

// Description: This constructor will dynamically load the library found at the given framework path.
// path: The path to the library in question.
this(string path) {
this(new String(path));
SystemLoadLibrary(_pfvars, path);
}

~this() {
Expand All @@ -48,20 +42,13 @@ protected:
}

// acquire the signature (or null)
void* signature = SystemLoadLibraryProc(_pfvars, new String(proc));
void* signature = SystemLoadLibraryProc(_pfvars, proc);

// set in hash
_funcs[proc] = signature;
return signature;
}

// Description: This function can only be called within an instance of the class. It will give the function pointer to the procedure specified by proc and null when the procedure cannot be found.
// proc: The name of the procedure to call upon.
// Returns: Will return null if the procedure cannot be found, otherwise it will return the address to this function.
final void* getProc(String proc) {
return getProc(proc.toString());
}

final void*[string] _funcs;

LibraryPlatformVars _pfvars;
Expand Down
2 changes: 1 addition & 1 deletion core/list.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
module core.list;

import core.definitions;
import core.string;
import core.util;
import core.tostring;
import core.exception;

// Description: This template resolves to true when the type T is
Expand Down
4 changes: 2 additions & 2 deletions core/locales/en_us.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import core.locale;

import core.time;
import core.date;
import core.tostring;
import core.definitions;
import core.string;

class LocaleEnglish_US : LocaleInterface {
string formatTime(Time time) {
Expand Down Expand Up @@ -166,7 +166,7 @@ class LocaleEnglish_US : LocaleInterface {
}
}
ret ~= ".";
ret ~= ftoa(value, 10, false);
ret ~= toStr(value);

// round last digit
bool roundUp = (ret[$-1] >= '5');
Expand Down
4 changes: 2 additions & 2 deletions core/locales/fr_fr.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import core.locale;

import core.time;
import core.date;
import core.tostring;
import core.string;
import core.definitions;

class LocaleFrench_FR : LocaleInterface {
Expand Down Expand Up @@ -154,7 +154,7 @@ class LocaleFrench_FR : LocaleInterface {
}
}
ret ~= ",";
ret ~= ftoa(value, 10, false);
ret ~= toStr(value);

// round last digit
bool roundUp = (ret[$-1] >= '5');
Expand Down
Loading

0 comments on commit c8e8d5d

Please sign in to comment.