Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: Source/core/xml/XPathValue.h

Issue 1099613003: Oilpan: have xml/ objects on the heap by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: simplify XPathResult dtor Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/xml/XPathStep.cpp ('k') | Source/core/xml/XPathValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2005 Frerich Raabe <raabe@kde.org> 2 * Copyright 2005 Frerich Raabe <raabe@kde.org>
3 * Copyright (C) 2006 Apple Computer, Inc. 3 * Copyright (C) 2006 Apple Computer, Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 18 matching lines...) Expand all
29 29
30 #include "core/xml/XPathNodeSet.h" 30 #include "core/xml/XPathNodeSet.h"
31 #include "wtf/text/WTFString.h" 31 #include "wtf/text/WTFString.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 namespace XPath { 35 namespace XPath {
36 36
37 struct EvaluationContext; 37 struct EvaluationContext;
38 38
39 class ValueData : public RefCountedWillBeGarbageCollectedFinalized<ValueData> { 39 class ValueData : public GarbageCollectedFinalized<ValueData> {
40 public: 40 public:
41 static PassRefPtrWillBeRawPtr<ValueData> create() { return adoptRefWillBeNoo p(new ValueData); } 41 static ValueData* create() { return new ValueData; }
42 static PassRefPtrWillBeRawPtr<ValueData> create(const NodeSet& nodeSet) { re turn adoptRefWillBeNoop(new ValueData(nodeSet)); } 42 static ValueData* create(const NodeSet& nodeSet) { return new ValueData(node Set); }
43 static PassRefPtrWillBeRawPtr<ValueData> create(PassOwnPtrWillBeRawPtr<NodeS et> nodeSet) { return adoptRefWillBeNoop(new ValueData(nodeSet)); } 43 static ValueData* create(NodeSet* nodeSet) { return new ValueData(nodeSet); }
44 static PassRefPtrWillBeRawPtr<ValueData> create(const String& string) { retu rn adoptRefWillBeNoop(new ValueData(string)); } 44 static ValueData* create(const String& string) { return new ValueData(string ); }
45 DECLARE_TRACE(); 45 DECLARE_TRACE();
46 NodeSet& nodeSet() { return *m_nodeSet; } 46 NodeSet& nodeSet() { return *m_nodeSet; }
47 47
48 String m_string; 48 String m_string;
49 49
50 private: 50 private:
51 ValueData() : m_nodeSet(NodeSet::create()) { } 51 ValueData() : m_nodeSet(NodeSet::create()) { }
52 explicit ValueData(const NodeSet& nodeSet) : m_nodeSet(NodeSet::create(nodeS et)) { } 52 explicit ValueData(const NodeSet& nodeSet) : m_nodeSet(NodeSet::create(nodeS et)) { }
53 explicit ValueData(PassOwnPtrWillBeRawPtr<NodeSet> nodeSet) : m_nodeSet(node Set) { } 53 explicit ValueData(NodeSet* nodeSet) : m_nodeSet(nodeSet) { }
54 explicit ValueData(const String& string) : m_string(string), m_nodeSet(NodeS et::create()) { } 54 explicit ValueData(const String& string) : m_string(string), m_nodeSet(NodeS et::create()) { }
55 55
56 OwnPtrWillBeMember<NodeSet> m_nodeSet; 56 Member<NodeSet> m_nodeSet;
57 }; 57 };
58 58
59 // Copying Value objects makes their data partially shared, so care has to be ta ken when dealing with copies. 59 // Copying Value objects makes their data partially shared, so care has to be ta ken when dealing with copies.
60 class Value { 60 class Value {
61 DISALLOW_ALLOCATION(); 61 DISALLOW_ALLOCATION();
62 public: 62 public:
63 enum Type { NodeSetValue, BooleanValue, NumberValue, StringValue }; 63 enum Type { NodeSetValue, BooleanValue, NumberValue, StringValue };
64 64
65 Value(unsigned value) : m_type(NumberValue), m_bool(false), m_number(value) { } 65 Value(unsigned value) : m_type(NumberValue), m_bool(false), m_number(value) { }
66 Value(unsigned long value) : m_type(NumberValue), m_bool(false), m_number(va lue) { } 66 Value(unsigned long value) : m_type(NumberValue), m_bool(false), m_number(va lue) { }
67 Value(double value) : m_type(NumberValue), m_bool(false), m_number(value) { } 67 Value(double value) : m_type(NumberValue), m_bool(false), m_number(value) { }
68 68
69 Value(const char* value) : m_type(StringValue), m_bool(false), m_number(0), m_data(ValueData::create(value)) { } 69 Value(const char* value) : m_type(StringValue), m_bool(false), m_number(0), m_data(ValueData::create(value)) { }
70 Value(const String& value) : m_type(StringValue), m_bool(false), m_number(0) , m_data(ValueData::create(value)) { } 70 Value(const String& value) : m_type(StringValue), m_bool(false), m_number(0) , m_data(ValueData::create(value)) { }
71 Value(const NodeSet& value) : m_type(NodeSetValue), m_bool(false), m_number( 0), m_data(ValueData::create(value)) { } 71 Value(const NodeSet& value) : m_type(NodeSetValue), m_bool(false), m_number( 0), m_data(ValueData::create(value)) { }
72 Value(Node* value) : m_type(NodeSetValue), m_bool(false), m_number(0), m_dat a(ValueData::create()) { m_data->nodeSet().append(value); } 72 Value(Node* value) : m_type(NodeSetValue), m_bool(false), m_number(0), m_dat a(ValueData::create()) { m_data->nodeSet().append(value); }
73 DECLARE_TRACE(); 73 DECLARE_TRACE();
74 74
75 // This is needed to safely implement constructing from bool - with normal 75 // This is needed to safely implement constructing from bool - with normal
76 // function overloading, any pointer type would match. 76 // function overloading, any pointer type would match.
77 template<typename T> Value(T); 77 template<typename T> Value(T);
78 78
79 static const struct AdoptTag { } adopt; 79 static const struct AdoptTag { } adopt;
80 Value(PassOwnPtrWillBeRawPtr<NodeSet> value, const AdoptTag&) : m_type(NodeS etValue), m_bool(false), m_number(0), m_data(ValueData::create(value)) { } 80 Value(NodeSet* value, const AdoptTag&) : m_type(NodeSetValue), m_bool(false) , m_number(0), m_data(ValueData::create(value)) { }
81 81
82 Type type() const { return m_type; } 82 Type type() const { return m_type; }
83 83
84 bool isNodeSet() const { return m_type == NodeSetValue; } 84 bool isNodeSet() const { return m_type == NodeSetValue; }
85 bool isBoolean() const { return m_type == BooleanValue; } 85 bool isBoolean() const { return m_type == BooleanValue; }
86 bool isNumber() const { return m_type == NumberValue; } 86 bool isNumber() const { return m_type == NumberValue; }
87 bool isString() const { return m_type == StringValue; } 87 bool isString() const { return m_type == StringValue; }
88 88
89 // If this is called during XPathExpression::evaluate(), EvaluationContext 89 // If this is called during XPathExpression::evaluate(), EvaluationContext
90 // should be passed. 90 // should be passed.
91 const NodeSet& toNodeSet(EvaluationContext*) const; 91 const NodeSet& toNodeSet(EvaluationContext*) const;
92 NodeSet& modifiableNodeSet(EvaluationContext&); 92 NodeSet& modifiableNodeSet(EvaluationContext&);
93 bool toBoolean() const; 93 bool toBoolean() const;
94 double toNumber() const; 94 double toNumber() const;
95 String toString() const; 95 String toString() const;
96 96
97 private: 97 private:
98 Type m_type; 98 Type m_type;
99 bool m_bool; 99 bool m_bool;
100 double m_number; 100 double m_number;
101 RefPtrWillBeMember<ValueData> m_data; 101 Member<ValueData> m_data;
102 }; 102 };
103 103
104 template<> 104 template<>
105 inline Value::Value(bool value) 105 inline Value::Value(bool value)
106 : m_type(BooleanValue) 106 : m_type(BooleanValue)
107 , m_bool(value) 107 , m_bool(value)
108 , m_number(0) 108 , m_number(0)
109 { 109 {
110 } 110 }
111 111
112 } 112 } // namespace XPath
113 113
114 } 114 } // namespace blink
115
115 #endif // XPathValue_h 116 #endif // XPathValue_h
OLDNEW
« no previous file with comments | « Source/core/xml/XPathStep.cpp ('k') | Source/core/xml/XPathValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698