PageRenderTime 100ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/src/error.cpp

http://github.com/mono/moon
C++ | 115 lines | 83 code | 18 blank | 14 comment | 5 complexity | b8c67d45fed4f7520ed5f11151abafc0 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, MIT, LGPL-2.1, MPL-2.0-no-copyleft-exception, GPL-3.0
  1. /*
  2. * error.cpp: ErrorEventArgs and its subclasses
  3. *
  4. * Contact:
  5. * Moonlight List (moonlight-list@lists.ximian.com)
  6. *
  7. * Copyright 2007 Novell, Inc. (http://www.novell.com)
  8. *
  9. * See the LICENSE file included with the distribution for details.
  10. *
  11. */
  12. #include <config.h>
  13. #include "error.h"
  14. #include "eventargs.h"
  15. #include "deployment.h"
  16. namespace Moonlight {
  17. //
  18. // MoonError
  19. //
  20. MoonError::MoonError ()
  21. {
  22. number = (ExceptionType) 0;
  23. code = 0;
  24. message = 0;
  25. char_position = -1;
  26. line_number = -1;
  27. }
  28. MoonError::MoonError (ExceptionType type, int code, const char *message)
  29. {
  30. this->number = type;
  31. this->code = code;
  32. this->message = g_strdup (message);
  33. char_position = -1;
  34. line_number = -1;
  35. }
  36. MoonError::MoonError (const MoonError &e)
  37. {
  38. number = e.number;
  39. code = e.code;
  40. message = g_strdup (e.message);
  41. char_position = e.char_position;
  42. line_number = e.line_number;
  43. gchandle = Deployment::GetCurrent ()->CloneGCHandle (e.gchandle);
  44. }
  45. MoonError::~MoonError ()
  46. {
  47. Clear ();
  48. }
  49. void
  50. MoonError::Clear ()
  51. {
  52. Deployment::GetCurrent ()->FreeGCHandle (gchandle);
  53. gchandle.Clear ();
  54. number = NO_ERROR;
  55. code = 0;
  56. g_free (message);
  57. message = NULL;
  58. }
  59. MoonError&
  60. MoonError::operator= (const MoonError& other)
  61. {
  62. if (&other == this)
  63. return *this;
  64. number = other.number;
  65. code = other.code;
  66. message = g_strdup (other.message);
  67. char_position = other.char_position;
  68. line_number = other.line_number;
  69. gchandle = Deployment::GetCurrent ()->CloneGCHandle (other.gchandle);
  70. return *this;
  71. }
  72. void
  73. MoonError::FillIn (MoonError *error, ExceptionType number, int code, const char *message)
  74. {
  75. if (!error)
  76. return;
  77. error->number = number;
  78. error->code = code;
  79. error->message = g_strdup (message);
  80. }
  81. void
  82. MoonError::FillIn (MoonError *error, ExceptionType type, const char *message)
  83. {
  84. if (!error)
  85. return;
  86. FillIn (error, type, 0, message);
  87. }
  88. void
  89. MoonError::FillIn (MoonError *error, ParserErrorEventArgs *error_args)
  90. {
  91. if (!error)
  92. return;
  93. FillIn (error, MoonError::XAML_PARSE_EXCEPTION, error_args->GetErrorMessage());
  94. error->char_position = error_args->char_position;
  95. error->line_number = error_args->line_number;
  96. }
  97. };