Changeset 62416 in webkit for trunk/JavaScriptCore/parser/SourceProvider.h
- Timestamp:
- Jul 2, 2010, 4:49:07 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/parser/SourceProvider.h
r62410 r62416 35 35 namespace JSC { 36 36 37 enum SourceBOMPresence { SourceHasNoBOMs, SourceCouldHaveBOMs }; 38 37 39 class SourceProvider : public RefCounted<SourceProvider> { 38 40 public: 39 SourceProvider(const UString& url )41 SourceProvider(const UString& url, SourceBOMPresence hasBOMs = SourceCouldHaveBOMs) 40 42 : m_url(url) 43 , m_hasBOMs(hasBOMs) 41 44 { 42 45 } … … 50 53 intptr_t asID() { return reinterpret_cast<intptr_t>(this); } 51 54 55 SourceBOMPresence hasBOMs() const { return m_hasBOMs; } 56 52 57 private: 53 58 UString m_url; 59 SourceBOMPresence m_hasBOMs; 54 60 }; 55 61 56 62 class UStringSourceProvider : public SourceProvider { 57 63 public: 58 static PassRefPtr<UStringSourceProvider> create(const UString& source, const UString& url , bool hasBOMs = true)64 static PassRefPtr<UStringSourceProvider> create(const UString& source, const UString& url) 59 65 { 60 return adoptRef(new UStringSourceProvider(source, url , hasBOMs));66 return adoptRef(new UStringSourceProvider(source, url)); 61 67 } 62 68 63 UString getRange(int start, int end) const 64 { 65 return m_source.substr(start, end - start); 66 } 69 UString getRange(int start, int end) const { return m_source.substr(start, end - start); } 67 70 const UChar* data() const { return m_source.data(); } 68 71 int length() const { return m_source.size(); } 69 72 70 73 private: 71 UStringSourceProvider(const UString& source, const UString& url , bool hasBOMs)74 UStringSourceProvider(const UString& source, const UString& url) 72 75 : SourceProvider(url) 73 76 , m_source(source) 74 77 { 75 if (hasBOMs && m_source.size()) {76 bool scratch = false;77 m_source = UString(m_source.rep()->copyStringWithoutBOMs(false, scratch));78 }79 78 } 80 79
Note:
See TracChangeset
for help on using the changeset viewer.