method.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. var RTL$ = {
  2. extend: function extend(methods){
  3. function Type(){
  4. for(var m in methods)
  5. this[m] = methods[m];
  6. }
  7. Type.prototype = this.prototype;
  8. var result = methods.init;
  9. result.prototype = new Type(); // inherit this.prototype
  10. result.prototype.constructor = result; // to see constructor name in diagnostic
  11. result.extend = extend;
  12. return result;
  13. }
  14. };
  15. var m = function (){
  16. var T = RTL$.extend({
  17. init: function T(){
  18. this.i = 0;
  19. }
  20. });
  21. var D = T.extend({
  22. init: function D(){
  23. T.prototype.init.call(this);
  24. }
  25. });
  26. var dp = null;
  27. T.prototype.p = function(){
  28. this.i = 123;
  29. }
  30. T.prototype.p2 = function(i/*INTEGER*/){
  31. return i;
  32. }
  33. function acceptPointer(p/*PT*/){
  34. }
  35. function acceptReferenace(p/*VAR T*/){
  36. }
  37. function acceptConstReferenace(p/*T*/){
  38. }
  39. T.prototype.useSelfAsPointer = function(){
  40. var pVar = null;
  41. pVar = this;
  42. acceptPointer(this);
  43. acceptReferenace(this);
  44. acceptConstReferenace(this);
  45. }
  46. D.prototype.p = function(){
  47. T.prototype.p.call(this);
  48. }
  49. D.prototype.p2 = function(i/*INTEGER*/){
  50. return T.prototype.p2.call(this, i);
  51. }
  52. dp = new D();
  53. dp.p();
  54. dp.p();
  55. }();