Code coverage report for fontkit/src/cff/CFFPointer.coffee

Statements: 100% (21 / 21)      Branches: 100% (2 / 2)      Functions: 100% (10 / 10)      Lines: 100% (21 / 21)      Ignored: none     

All files » fontkit/src/cff/ » CFFPointer.coffee
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 391   1   7 7     72 72   72   1   101     14     101   87 87   87 87   14 14   14   14 14   1  
r = require 'restructure'
 
class CFFPointer extends r.Pointer
  constructor: (type, options = {}) ->
    options.type ?= 'global'
    super null, type, options
  
  decode: (stream, parent, operands) ->
    @offsetType = 
      decode: -> operands[0]
  
    super
    
  class Ptr
    constructor: (@val) ->
      @forceLarge = true
      
    valueOf: ->
      @val
  
  encode: (stream, value, ctx) ->
    unless stream
      # compute the size (so ctx.pointerSize is correct)
      @offsetType =
        size: -> 0
        
      @size(value, ctx)
      return [new Ptr 0]
    
    ptr = null
    @offsetType =
      encode: (stream, val) ->
        ptr = val
      
    super    
    return [new Ptr ptr]
 
module.exports = CFFPointer