SizeMatchExpression.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. "use strict";
  2. var ArrayMatchingMatchExpression = require('./ArrayMatchingMatchExpression');
  3. // Autogenerated by cport.py on 2013-09-17 14:37
  4. var SizeMatchExpression = module.exports = function SizeMatchExpression(){
  5. base.call(this);
  6. this._matchType = 'SIZE';
  7. }, klass = SizeMatchExpression, base = ArrayMatchingMatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  8. // File: expression_array.h lines: 131-131
  9. proto._size = undefined;
  10. /**
  11. *
  12. * Writes a debug string for this object
  13. * @method debugString
  14. * @param level
  15. *
  16. */
  17. proto.debugString = function debugString(level) {
  18. // File: expression_array.cpp lines: 259-261
  19. return this._debugAddSpace( level ) + this.path() + " $size : " + this._size.toString() + "\n";
  20. };
  21. /**
  22. *
  23. * checks if this expression is == to the other
  24. * @method equivalent
  25. * @param other
  26. *
  27. */
  28. proto.equivalent = function equivalent(other) {
  29. // File: expression_array.cpp lines: 264-269
  30. if(other._matchType != 'SIZE') {
  31. return false;
  32. }
  33. return this._size == other._size && this._path == other._path;
  34. };
  35. /**
  36. *
  37. * Return the _size property
  38. * @method getData
  39. *
  40. */
  41. proto.getData = function getData(){
  42. // File: expression_array.h lines: 128-127
  43. return this._size;
  44. };
  45. /**
  46. *
  47. * Initialize the necessary items
  48. * @method init
  49. * @param path
  50. * @param size
  51. *
  52. */
  53. proto.init = function init(path,size) {
  54. // File: expression_array.cpp lines: 248-250
  55. if(size === null)
  56. return {code:'BAD_VALUE', 'description':'Cannot assign null to size'};
  57. this._size = size;
  58. return this.initPath(path);
  59. };
  60. /**
  61. *
  62. * Check if the input array matches
  63. * @method matchesArray
  64. * @param anArray
  65. * @param details
  66. *
  67. */
  68. proto.matchesArray = function matchesArray(anArray, details) {
  69. // File: expression_array.cpp lines: 253-256
  70. if(this._size < 0) {
  71. return false;
  72. }
  73. return anArray.length == this._size;
  74. };
  75. /**
  76. *
  77. * clone this instance to a new one
  78. * @method shallowClone
  79. *
  80. */
  81. proto.shallowClone = function shallowClone(){
  82. // File: expression_array.h lines: 116-119
  83. var e = new SizeMatchExpression();
  84. e.init(this.path(),this._size);
  85. return e;
  86. };