Permalink
Browse files

Some reworking of pointer functioning to support multiple levels of i…

…ndirection. Remove event emitter part for now
  • Loading branch information...
1 parent 902a95d commit 6d1164b3243a297123f4e13034162019819c67d1 @Benvie committed Apr 2, 2012
Showing with 115 additions and 651 deletions.
  1. +0 −32 README.md
  2. +3 −3 browser/build.js
  3. +0 −535 browser/event-emitter2.js
  4. +3 −3 lib/array.js
  5. +3 −3 lib/bitfield.js
  6. +13 −5 lib/buffer.js
  7. +36 −18 lib/genesis.js
  8. +2 −2 lib/numeric.js
  9. +49 −44 lib/pointer.js
  10. +3 −3 lib/string.js
  11. +3 −3 lib/struct.js
View
@@ -282,38 +282,6 @@ Value can be either a JS value/object with the same structure (keys, indices, nu
* `<Bitfield>.toString` - String of the bits in 1's and 0's
-# Experimental EventEmitter API
-
-Currently a minimal event emitter API is implemented. It is still up for decision whether it will stay or not, based on performance impact and actual usefulness. Currently it's implemented with the goal of providing hooks into key processes, allowing modification of values. The example usage is when a field needs special treatment during reification, some special mapping to values not easily represented in reify's api. The following is from the TTF font format example:
-
-```javascript
-var TTFVersion = reified('TTFVersion', Uint8[4]);
-
-TTFVersion.prototype.on('reify', function(val){
- val = val.join('');
- this.reified = val === '0100' ? 'TrueType' : val === 'OTTO' ? 'OpenType' : 'Unknown';
-});
-```
-Before the event is emitted, the reified value is attached to the structure, such that it's possible to fully modify it just prior to it's finally returned. This allows arbitrary modification. The TTF example also uses it currently as a kind of jury rigged way to handle pointers/indirection, by forcibly reifying related but separate-in-memory values.
-
-The other event exposed is `<Data>.on('construct')`. This allows a similar connection of values where reified's api is lacking, like dynamically sized arrays based on a value read from memory. Ultimately a better API will be provided to solve some of these problems.However, it shows there's real potential value in having these the option to tap in.
-
-The emitter is attached on the primordial `Data` itself which allows the following:
-
-```javascript
-reified.Type.prototype.on('reify', function(){
- console.log(this.constructor.name + ' reified');
-});
-reified.Type.prototype.on('construct', function(){
- console.log(this.constructor.name + ' constructed');
-});
-reified.Type.prototype.on('deallocate', function(){
- console.log(this.constructor.name + ' deallocated');
-});
-```
-Which would emit those events for __every single type__.
-
-
## TODO
View
@@ -12,7 +12,9 @@ var libs = [
'struct',
'array',
'bitfield',
- 'index'
+ 'pointer',
+ 'string',
+ 'index',
].map(function(name){
return wrap('./'+name, load('../lib/'+name+'.js'));
});
@@ -21,8 +23,6 @@ function wrap(name, code){
return wrapper.replace(/\/\*NAME\*\//g, name).replace(/\/\*CONTENT\*\//g, code);
}
-libs.unshift(wrap('events', load('./event-emitter2.js')));
-
var output = [
'var reified = function(global, imports){',
libs.join('\n\n'),
Oops, something went wrong.

0 comments on commit 6d1164b

Please sign in to comment.