forked from dolphinsmalltalk/DolphinVM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTString.h
More file actions
73 lines (54 loc) · 1.65 KB
/
STString.h
File metadata and controls
73 lines (54 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/******************************************************************************
File: STString.h
Description:
VM representation of Smalltalk String class.
N.B. The representation of this class must NOT be changed.
******************************************************************************/
#ifndef _IST_STString_H_
#define _IST_STString_H_
#include "STCollection.h"
// Turn off warning about zero length arrays
#pragma warning ( disable : 4200)
class String;
typedef TOTE<String> StringOTE;
class String : public ArrayedCollection
{
public:
char m_characters[]; // Variable length array of data
static StringOTE* __fastcall NewWithLen(const char* value, unsigned len);
static StringOTE* __stdcall New(LPCSTR sz);
static StringOTE* __fastcall NewFromWide(LPCWSTR wsz);
static StringOTE* __fastcall NewFromBSTR(BSTR bs);
static StringOTE* NewLiteral(const char* szValue);
};
inline StringOTE* String::New(const char* value)
{
unsigned len = strlen(value);
return NewWithLen(value, len);
}
// Allocate a new String from a Unicode string
inline StringOTE* __fastcall String::NewFromBSTR(BSTR bs)
{
return bs == NULL ? NewWithLen("", 0) : NewFromWide(bs);
}
inline StringOTE* String::NewLiteral(const char* value)
{
unsigned len = strlen(value);
if (len > 0)
{
StringOTE* oteLiteral = NewWithLen(value, len);
oteLiteral->beImmutable();
return oteLiteral;
}
else
return Pointers.EmptyString;
}
class Symbol : public ArrayedCollection // Actually a String subclass
{
public:
char m_characters[];
};
typedef TOTE<Symbol> SymbolOTE;
ostream& operator<<(ostream& st, const StringOTE*);
ostream& operator<<(ostream& st, const SymbolOTE*);
#endif // EOF