| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef PPAPI_CPP_PRIVATE_VAR_PRIVATE_H_ | 5 #ifndef PPAPI_CPP_PRIVATE_VAR_PRIVATE_H_ |
| 6 #define PPAPI_CPP_PRIVATE_VAR_PRIVATE_H_ | 6 #define PPAPI_CPP_PRIVATE_VAR_PRIVATE_H_ |
| 7 | 7 |
| 8 #include "ppapi/cpp/var.h" | 8 #include "ppapi/cpp/var.h" |
| 9 | 9 |
| 10 namespace pp { | 10 namespace pp { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // from get, and nothing else should change. | 79 // from get, and nothing else should change. |
| 80 // | 80 // |
| 81 // Example: | 81 // Example: |
| 82 // void FooBar(a, b, Var* exception = NULL) { | 82 // void FooBar(a, b, Var* exception = NULL) { |
| 83 // foo_interface->Bar(a, b, VarPrivate::OutException(exception).get()); | 83 // foo_interface->Bar(a, b, VarPrivate::OutException(exception).get()); |
| 84 // } | 84 // } |
| 85 class OutException { | 85 class OutException { |
| 86 public: | 86 public: |
| 87 OutException(Var* v) | 87 OutException(Var* v) |
| 88 : output_(v), | 88 : output_(v), |
| 89 originally_had_exception_(v && v->is_null()) { | 89 originally_had_exception_(v && !v->is_undefined()) { |
| 90 if (output_) { | 90 if (output_) { |
| 91 temp_ = output_->pp_var(); | 91 temp_ = output_->pp_var(); |
| 92 } else { | 92 } else { |
| 93 temp_.padding = 0; | 93 temp_.padding = 0; |
| 94 temp_.type = PP_VARTYPE_UNDEFINED; | 94 temp_.type = PP_VARTYPE_UNDEFINED; |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 ~OutException() { | 97 ~OutException() { |
| 98 if (output_ && !originally_had_exception_) | 98 if (output_ && !originally_had_exception_) |
| 99 *output_ = Var(PassRef(), temp_); | 99 *output_ = Var(PassRef(), temp_); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 114 private: | 114 private: |
| 115 // Prevent an arbitrary pointer argument from being implicitly converted to | 115 // Prevent an arbitrary pointer argument from being implicitly converted to |
| 116 // a bool at Var construction. If somebody makes such a mistake, (s)he will | 116 // a bool at Var construction. If somebody makes such a mistake, (s)he will |
| 117 // get a compilation error. | 117 // get a compilation error. |
| 118 VarPrivate(void* non_scriptable_object_pointer); | 118 VarPrivate(void* non_scriptable_object_pointer); |
| 119 }; | 119 }; |
| 120 | 120 |
| 121 } // namespace pp | 121 } // namespace pp |
| 122 | 122 |
| 123 #endif // PPAPI_CPP_PRIVATE_VAR_PRIVATE_H_ | 123 #endif // PPAPI_CPP_PRIVATE_VAR_PRIVATE_H_ |
| OLD | NEW |