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