OLD | NEW |
| (Empty) |
1 // Copyright 2010 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can | |
3 // be found in the LICENSE file. | |
4 using System.Collections.Generic; | |
5 using System.Linq; | |
6 using Microsoft.VisualStudio; | |
7 using Microsoft.VisualStudio.Debugger.Interop; | |
8 | |
9 namespace Google.MsAd7.BaseImpl { | |
10 namespace Ad7Enumerators { | |
11 /// <summary> | |
12 /// For documentation of IEnumDebugErrorBreakpoint2 members, please see the VS
2008 MSDN | |
13 /// documentation. | |
14 /// </summary> | |
15 public class EnumErrorBreakpoints : IEnumDebugErrorBreakpoints2 { | |
16 public EnumErrorBreakpoints() { | |
17 breakpointErrors_ = new List<IDebugErrorBreakpoint2>(); | |
18 iterator_ = 0; | |
19 } | |
20 | |
21 /// <summary> | |
22 /// This function exists so the PendingBreakpoint can add itself to the erro
rs in this | |
23 /// enumeration after BreakpointInfo generates them. | |
24 /// </summary> | |
25 public int PopulateBreakpoint(PendingBreakpoint breakpoint) { | |
26 int populated = VSConstants.S_FALSE; | |
27 foreach ( | |
28 ErrorBreakpoint assignable in | |
29 breakpointErrors_.OfType<ErrorBreakpoint>()) { | |
30 assignable.PendingBreakpoint = breakpoint; | |
31 populated = VSConstants.S_OK; | |
32 } | |
33 return populated; | |
34 } | |
35 | |
36 public void Insert(IDebugErrorBreakpoint2 breakpointError) { | |
37 breakpointErrors_.Add(breakpointError); | |
38 } | |
39 | |
40 #region IEnumDebugErrorBreakpoints2 Members | |
41 | |
42 public int Next(uint celt, | |
43 IDebugErrorBreakpoint2[] rgelt, | |
44 ref uint pceltFetched) { | |
45 int inRange = VSConstants.S_FALSE; | |
46 var requestedSize = (int) celt; | |
47 if ((requestedSize > 0) && | |
48 (iterator_ + requestedSize <= breakpointErrors_.Count)) { | |
49 breakpointErrors_.CopyTo(iterator_, rgelt, 0, requestedSize); | |
50 iterator_ += requestedSize; | |
51 pceltFetched = celt; | |
52 inRange = VSConstants.S_OK; | |
53 } | |
54 return inRange; | |
55 } | |
56 | |
57 public int Skip(uint celt) { | |
58 int inRange = VSConstants.S_FALSE; | |
59 var requestedSize = (int) celt; | |
60 if ((requestedSize > 0) && | |
61 (iterator_ + celt) < breakpointErrors_.Count) { | |
62 iterator_ += requestedSize; | |
63 inRange = VSConstants.S_OK; | |
64 } | |
65 return inRange; | |
66 } | |
67 | |
68 public int Reset() { | |
69 iterator_ = 0; | |
70 return VSConstants.S_OK; | |
71 } | |
72 | |
73 public int Clone(out IEnumDebugErrorBreakpoints2 ppEnum) { | |
74 int success = VSConstants.S_FALSE; | |
75 var clone = new EnumErrorBreakpoints(); | |
76 ppEnum = clone; | |
77 foreach (IDebugErrorBreakpoint2 debugErrorBreakpoint2 in breakpointErrors_ | |
78 ) { | |
79 clone.Insert(debugErrorBreakpoint2); | |
80 } | |
81 uint cloneCount; | |
82 clone.GetCount(out cloneCount); | |
83 if (breakpointErrors_.Count == cloneCount) { | |
84 success = VSConstants.S_OK; | |
85 } | |
86 return success; | |
87 } | |
88 | |
89 public int GetCount(out uint pcelt) { | |
90 int rValue = VSConstants.S_FALSE; | |
91 pcelt = 0; | |
92 if (breakpointErrors_ != null) { | |
93 pcelt = (uint) breakpointErrors_.Count; | |
94 rValue = VSConstants.S_OK; | |
95 } | |
96 return rValue; | |
97 } | |
98 | |
99 #endregion | |
100 | |
101 #region Private Implementation | |
102 | |
103 readonly List<IDebugErrorBreakpoint2> breakpointErrors_; | |
104 int iterator_; | |
105 | |
106 #endregion | |
107 } | |
108 } | |
OLD | NEW |