+16
-4
lines changedFilter options
+16
-4
lines changed Original file line number Diff line number Diff line change
@@ -7,8 +7,11 @@ class Pointer
7
7
@options.allowNull ?= true
8
8
@options.nullValue ?= 0
9
9
@options.lazy ?= false
10
-
if @options.relativeTo
11
-
@relativeToGetter = new Function('ctx', "return ctx.#{@options.relativeTo}")
10
+
11
+
relativeToGetter: (ctx) ->
12
+
@options.relativeTo.split('.').reduce((obj, prop) ->
13
+
obj[prop]
14
+
, ctx)
12
15
13
16
decode: (stream, ctx) ->
14
17
offset = @offsetType.decode(stream, ctx)
Original file line number Diff line number Diff line change
@@ -2,9 +2,18 @@ Struct = require './Struct'
2
2
3
3
class VersionedStruct extends Struct
4
4
constructor: (@type, @versions = {}) ->
5
+
6
+
versionGetter: (parent) ->
7
+
if typeof @type is 'string'
8
+
@type.split('.').reduce((obj, prop) ->
9
+
if typeof obj != 'undefined' then obj[prop] else undefined
10
+
, parent)
11
+
12
+
versionSetter: (parent, version) ->
5
13
if typeof @type is 'string'
6
-
@versionGetter = new Function('parent', "return parent.#{@type}")
7
-
@versionSetter = new Function('parent', 'version', "return parent.#{@type} = version")
14
+
@type.split('.').reduce((obj, prop) ->
15
+
obj[prop] = version
16
+
, parent)
8
17
9
18
decode: (stream, parent, length = 0) ->
10
19
res = @_setup stream, parent, length
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4