Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
74417542
Commit
74417542
authored
11 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Move the method functions into the prototype for better awesome.
parent
f88e9e2d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exec/load/recordfile.js
+17
-26
17 additions, 26 deletions
exec/load/recordfile.js
with
17 additions
and
26 deletions
exec/load/recordfile.js
+
17
−
26
View file @
74417542
...
...
@@ -32,7 +32,17 @@ function GetRecordLength(RecordDef)
return
(
len
);
}
function
RecordFileRecord_ReInit
()
function
RecordFile
(
filename
,
definition
)
{
this
.
file
=
new
File
(
filename
);
this
.
fields
=
definition
;
this
.
RecordLength
=
GetRecordLength
(
this
.
fields
);
if
(
!
this
.
file
.
open
(
file_exists
(
this
.
file
.
name
)?
"
rb+
"
:
"
wb+
"
,
true
,
this
.
RecordLength
))
return
(
null
);
this
.
__defineGetter__
(
"
length
"
,
function
()
{
return
parseInt
(
this
.
file
.
length
/
this
.
RecordLength
);});
}
RecordFile
.
prototype
.
ReInit
=
function
()
{
var
i
;
...
...
@@ -40,7 +50,7 @@ function RecordFileRecord_ReInit()
this
[
this
.
parent
.
fields
[
i
].
prop
]
=
eval
(
this
.
parent
.
fields
[
i
].
def
.
toSource
());
}
function
RecordFile
Record_Put
()
RecordFile
.
prototype
.
Put
=
function
()
{
var
i
;
...
...
@@ -49,7 +59,7 @@ function RecordFileRecord_Put()
this
.
parent
.
WriteField
(
this
[
this
.
parent
.
fields
[
i
].
prop
],
this
.
parent
.
fields
[
i
].
type
,
this
.
parent
.
fields
[
i
].
def
);
}
function
RecordFile
Record_ReLoad
(
num
)
RecordFile
.
prototype
.
ReLoad
=
function
(
num
)
{
var
i
;
...
...
@@ -58,7 +68,7 @@ function RecordFileRecord_ReLoad(num)
this
[
this
.
parent
.
fields
[
i
].
prop
]
=
this
.
parent
.
ReadField
(
this
.
parent
.
fields
[
i
].
type
);
}
function
RecordFile
_Get
(
num
)
RecordFile
.
prototype
.
Get
=
function
(
num
)
{
var
rec
=
0
;
var
i
;
...
...
@@ -85,7 +95,7 @@ function RecordFile_Get(num)
return
(
ret
);
}
function
RecordFile
_New
()
RecordFile
.
prototype
.
New
=
function
()
{
var
i
;
var
ret
=
new
Object
();
...
...
@@ -102,7 +112,7 @@ function RecordFile_New()
return
(
ret
);
}
function
RecordFile
_ReadField
(
fieldtype
)
RecordFile
.
prototype
.
ReadField
=
function
(
fieldtype
)
{
var
i
;
var
m
=
fieldtype
.
match
(
/^Array:
([
0-9
]
+
)
:
(
.*
)
$/
);
...
...
@@ -145,7 +155,7 @@ function RecordFile_ReadField(fieldtype)
}
}
function
RecordFile
_WriteField
(
val
,
fieldtype
,
def
)
RecordFile
.
prototype
.
WriteField
=
function
(
val
,
fieldtype
,
def
)
{
var
i
;
var
m
=
fieldtype
.
match
(
/^Array:
([
0-9
]
+
)
:
(
.*
)
$/
);
...
...
@@ -210,22 +220,3 @@ function RecordFile_WriteField(val, fieldtype, def)
}
}
function
RecordFile
(
filename
,
definition
)
{
this
.
file
=
new
File
(
filename
);
this
.
fields
=
definition
;
this
.
RecordLength
=
GetRecordLength
(
this
.
fields
);
if
(
!
this
.
file
.
open
(
file_exists
(
this
.
file
.
name
)?
"
rb+
"
:
"
wb+
"
,
true
,
this
.
RecordLength
))
return
(
null
);
this
.
__defineGetter__
(
"
length
"
,
function
()
{
return
parseInt
(
this
.
file
.
length
/
this
.
RecordLength
);});
/* Read a record by index */
this
.
Get
=
RecordFile_Get
;
/* Create a new record */
this
.
New
=
RecordFile_New
;
/* Read a single field from the current position */
this
.
ReadField
=
RecordFile_ReadField
;
/* Write a single field from the current position */
this
.
WriteField
=
RecordFile_WriteField
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment