From: Jer Noble Date: Fri, 7 Dec 2012 22:10:33 +0000 (-0800) Subject: Add a helper function for getting the super prototype of an object. X-Git-Url: http://105106.c2e0p.group/movie_parser.git/commitdiff_plain/578248d58df5e9cb5c8de2ea7cabff4560db9fa6?hp=550e6dfa3c752008d9241f9617d41551f68b4827 Add a helper function for getting the super prototype of an object. --- diff --git a/Atom.js b/Atom.js index 7d15c3e..52e9e59 100644 --- a/Atom.js +++ b/Atom.js @@ -38,6 +38,10 @@ Atom.create = function(buffer, offset) { } } +Atom.prototype.super = function(object) { + return Object.getPrototypeOf(object.prototype); +} + Atom.prototype.setDefaults = function() { Object.defineProperty(this, "is64bit", { value: false, @@ -133,13 +137,13 @@ Atom.prototype.getAtomsByType = function(type) { }; var FileTypeAtom = function(buffer, offset) { - Object.getPrototypeOf(FileTypeAtom.prototype).constructor.call(this, buffer, offset); + this.super(FileTypeAtom).constructor.call(this, buffer, offset); } FileTypeAtom.prototype = Object.create(Atom.prototype); FileTypeAtom.prototype.setDefaults = function() { - Object.getPrototypeOf(FileTypeAtom.prototype).setDefaults.call(this); + this.super(FileTypeAtom).setDefaults.call(this); this.minimumSize = 16; this.brand = ""; this.version = 0; @@ -147,7 +151,7 @@ FileTypeAtom.prototype.setDefaults = function() { } FileTypeAtom.prototype.parse = function(buffer, offset) { - var headerOffset = Object.getPrototypeOf(FileTypeAtom.prototype).parse.call(this, buffer, offset); + var headerOffset = this.super(FileTypeAtom).parse.call(this, buffer, offset); if (!headerOffset) return 0; @@ -170,18 +174,18 @@ FileTypeAtom.prototype.parse = function(buffer, offset) { } var ContainerAtom = function(buffer, offset) { - Object.getPrototypeOf(ContainerAtom.prototype).constructor.call(this, buffer, offset); + this.super(ContainerAtom).constructor.call(this, buffer, offset); } ContainerAtom.prototype = Object.create(Atom.prototype); ContainerAtom.prototype.setDefaults = function() { - Object.getPrototypeOf(ContainerAtom.prototype).setDefaults.call(this); + this.super(ContainerAtom).setDefaults.call(this); this.childAtoms = []; } ContainerAtom.prototype.parse = function(buffer, offset) { - var headerOffset = Object.getPrototypeOf(ContainerAtom.prototype).parse.call(this, buffer, offset); + var headerOffset = this.super(ContainerAtom).parse.call(this, buffer, offset); if (!headerOffset) return 0; @@ -196,19 +200,19 @@ ContainerAtom.prototype.parse = function(buffer, offset) { } var VersionFlagsAtom = function(buffer, offset) { - Object.getPrototypeOf(VersionFlagsAtom.prototype).constructor.call(this, buffer, offset); + this.super(VersionFlagsAtom).constructor.call(this, buffer, offset); } VersionFlagsAtom.prototype = Object.create(Atom.prototype); VersionFlagsAtom.prototype.setDefaults = function() { - Object.getPrototypeOf(VersionFlagsAtom.prototype).setDefaults.call(this); + this.super(VersionFlagsAtom).setDefaults.call(this); this.version = 0; this.flags = 0; } VersionFlagsAtom.prototype.parse = function(buffer, offset) { - var headerOffset = Object.getPrototypeOf(VersionFlagsAtom.prototype).parse.call(this, buffer, offset); + var headerOffset = this.super(VersionFlagsAtom).parse.call(this, buffer, offset); if (!headerOffset) return 0; @@ -225,13 +229,13 @@ VersionFlagsAtom.prototype.parse = function(buffer, offset) { } var MovieHeaderAtom = function(buffer, offset) { - return Object.getPrototypeOf(MovieHeaderAtom.prototype).constructor.call(this, buffer, offset); + return this.super(MovieHeaderAtom).constructor.call(this, buffer, offset); } MovieHeaderAtom.prototype = Object.create(VersionFlagsAtom.prototype); MovieHeaderAtom.prototype.setDefaults = function() { - Object.getPrototypeOf(MovieHeaderAtom.prototype).setDefaults.call(this); + this.super(MovieHeaderAtom).setDefaults.call(this); this.creationTime = 0; this.modificationTime = 0; this.timeScale = 0; @@ -247,7 +251,7 @@ MovieHeaderAtom.prototype.setDefaults = function() { } MovieHeaderAtom.prototype.parse = function(buffer, offset) { - var headerOffset = Object.getPrototypeOf(MovieHeaderAtom.prototype).parse.call(this, buffer, offset); + var headerOffset = this.super(MovieHeaderAtom).parse.call(this, buffer, offset); if (!headerOffset) return 0; @@ -325,13 +329,13 @@ MovieHeaderAtom.prototype.parse = function(buffer, offset) { } var TrackHeaderAtom = function(buffer, offset) { - Object.getPrototypeOf(TrackHeaderAtom.prototype).constructor.call(this, buffer, offset); + this.super(TrackHeaderAtom).constructor.call(this, buffer, offset); } TrackHeaderAtom.prototype = Object.create(Atom.prototype); TrackHeaderAtom.prototype.setDefaults = function() { - Object.getPrototypeOf(TrackHeaderAtom.prototype).setDefaults.call(this); + this.super(TrackHeaderAtom).setDefaults.call(this); this.creationTime = 0; this.modificationTime = 0; @@ -346,7 +350,7 @@ TrackHeaderAtom.prototype.setDefaults = function() { } TrackHeaderAtom.prototype.parse = function(buffer, offset) { - var headerOffset = Object.getPrototypeOf(TrackHeaderAtom.prototype).parse.call(this, buffer, offset); + var headerOffset = this.super(TrackHeaderAtom).parse.call(this, buffer, offset); if (!headerOffset) return 0; @@ -421,13 +425,13 @@ TrackHeaderAtom.prototype.parse = function(buffer, offset) { } var MediaHeaderAtom = function(buffer, offset) { - Object.getPrototypeOf(MediaHeaderAtom.prototype).constructor.call(this, buffer, offset); + this.super(MediaHeaderAtom).constructor.call(this, buffer, offset); } MediaHeaderAtom.prototype = Object.create(VersionFlagsAtom.prototype); MediaHeaderAtom.prototype.setDefaults = function() { - Object.getPrototypeOf(MediaHeaderAtom.prototype).setDefaults.call(this); + this.super(MediaHeaderAtom).setDefaults.call(this); this.creationTime = 0; this.modificationTime = 0; @@ -438,7 +442,7 @@ MediaHeaderAtom.prototype.setDefaults = function() { } MediaHeaderAtom.prototype.parse = function(buffer, offset) { - var headerOffset = Object.getPrototypeOf(MediaHeaderAtom.prototype).parse.call(this, buffer, offset); + var headerOffset = this.super(MediaHeaderAtom).parse.call(this, buffer, offset); if (!headerOffset) return 0; @@ -464,13 +468,13 @@ MediaHeaderAtom.prototype.parse = function(buffer, offset) { } var SyncSampleAtom = function(buffer, offset) { - Object.getPrototypeOf(SyncSampleAtom.prototype).constructor.call(this, buffer, offset); + this.super(SyncSampleAtom).constructor.call(this, buffer, offset); } SyncSampleAtom.prototype = Object.create(Atom.prototype); SyncSampleAtom.prototype.setDefaults = function() { - Object.getPrototypeOf(SyncSampleAtom.prototype).setDefaults.call(this); + this.super(SyncSampleAtom).setDefaults.call(this); this.version = 0; this.flags = 0; @@ -479,7 +483,7 @@ SyncSampleAtom.prototype.setDefaults = function() { } SyncSampleAtom.prototype.parse = function(buffer, offset) { - var headerOffset = Object.getPrototypeOf(SyncSampleAtom.prototype).parse.call(this, buffer, offset); + var headerOffset = this.super(SyncSampleAtom).parse.call(this, buffer, offset); if (!headerOffset) return 0; @@ -503,13 +507,13 @@ SyncSampleAtom.prototype.parse = function(buffer, offset) { } var TimeToSampleAtom = function(buffer, offset) { - Object.getPrototypeOf(TimeToSampleAtom.prototype).constructor.call(this, buffer, offset); + this.super(TimeToSampleAtom).constructor.call(this, buffer, offset); } TimeToSampleAtom.prototype = Object.create(VersionFlagsAtom.prototype); TimeToSampleAtom.prototype.setDefaults = function() { - Object.getPrototypeOf(TimeToSampleAtom.prototype).setDefaults.call(this); + this.super(TimeToSampleAtom).setDefaults.call(this); this.entries = 0; @@ -522,7 +526,7 @@ TimeToSampleAtom.prototype.setDefaults = function() { } TimeToSampleAtom.prototype.parse = function(buffer, offset) { - var headerOffset = Object.getPrototypeOf(TimeToSampleAtom.prototype).parse.call(this, buffer, offset); + var headerOffset = this.super(TimeToSampleAtom).parse.call(this, buffer, offset); if (!headerOffset) return 0; diff --git a/AtomTester.html b/AtomTester.html index 0419988..d0bcbf1 100644 --- a/AtomTester.html +++ b/AtomTester.html @@ -3,26 +3,61 @@ AtomTester