Completely change naming conventions of field forms and definition macros. Close #32
This commit is contained in:
@@ -10,14 +10,14 @@
|
||||
(let [entryFiles (FileSystem.readDirectory entryDir)]
|
||||
(for file entryFiles =>(file.withoutExtension) (the Entry (Json.parse (File.getContent (joinPath archiveDir "entries" file)))))))])
|
||||
|
||||
(defmethod addSystem [:System system]
|
||||
(method addSystem [:System system]
|
||||
// Assign entries to the Systems that care about them
|
||||
(doFor =>id entry entries
|
||||
(system.checkEntryInOrOut this entry))
|
||||
(systems.push system)
|
||||
system)
|
||||
|
||||
(defmethod :Entry createEntry [:Entry->Dynamic initializer] // initializer returns Dynamic so ->:Void isn't required
|
||||
(method :Entry createEntry [:Entry->Dynamic initializer] // initializer returns Dynamic so ->:Void isn't required
|
||||
(let [e (_newEntry)]
|
||||
(initializer e)
|
||||
(dictSet entries e.id e)
|
||||
@@ -26,20 +26,20 @@
|
||||
|
||||
// After modifying an entry, this must be called. If you are writing in a createEntry initializer or a system's processEntry function, this will happen automatically.
|
||||
// Otherwise, you can guarantee it happens automatically by using the (withWritableEntry) macro in Lib.kiss
|
||||
(defmethod refreshEntry [:Entry e]
|
||||
(method refreshEntry [:Entry e]
|
||||
(_saveEntry e)
|
||||
(doFor system systems
|
||||
(system.checkEntryInOrOut this e)))
|
||||
|
||||
(defmethod _saveEntry [:Entry e]
|
||||
(method _saveEntry [:Entry e]
|
||||
(File.saveContent
|
||||
(joinPath archiveDir "entries" (e.id.withExtension "json"))
|
||||
(Json.stringify e)))
|
||||
|
||||
(defmethod componentData [:Entry e :String componentType]
|
||||
(method componentData [:Entry e :String componentType]
|
||||
(haxe.Json.parse (File.getContent (joinPath archiveDir "components" "$(dictGet e.components componentType).json"))))
|
||||
|
||||
(defmethod fullData [:Entry e]
|
||||
(method fullData [:Entry e]
|
||||
(object
|
||||
id e.id
|
||||
components
|
||||
@@ -48,11 +48,11 @@
|
||||
files
|
||||
e.files))
|
||||
|
||||
(defmethod fullString [:Entry e]
|
||||
(method fullString [:Entry e]
|
||||
(haxe.Json.stringify (fullData e) null "\t"))
|
||||
|
||||
(defun :Entry _newEntry []
|
||||
(function :Entry _newEntry []
|
||||
(object
|
||||
id (Uuid.v4)
|
||||
components (new Map)
|
||||
files []))
|
||||
files []))
|
||||
|
@@ -1,6 +1,6 @@
|
||||
(load "Lib.kiss")
|
||||
|
||||
(defmethod :Void _collectAndValidateArg [:CommandArg arg :Dynamic->Void continuation]
|
||||
(method :Void _collectAndValidateArg [:CommandArg arg :Dynamic->Void continuation]
|
||||
(case arg.type
|
||||
(SelectedEntry
|
||||
(if (= 1 selectedEntries.length)
|
||||
@@ -91,11 +91,11 @@
|
||||
min
|
||||
max))))
|
||||
|
||||
(defmethod :Void->Void _composeArgCollector [:Array<Dynamic> collectedArgs :CommandArg arg :Void->Void lastCollector]
|
||||
(method :Void->Void _composeArgCollector [:Array<Dynamic> collectedArgs :CommandArg arg :Void->Void lastCollector]
|
||||
(lambda :Void []
|
||||
(_collectAndValidateArg arg ->:Void [:Dynamic argValue] {(collectedArgs.push argValue) (lastCollector)})))
|
||||
|
||||
(defmethod :Void runCommand [:Command command]
|
||||
(method :Void runCommand [:Command command]
|
||||
(let [collectedArgs
|
||||
[]
|
||||
&mut lastCollector
|
||||
@@ -125,7 +125,7 @@
|
||||
(for [name type] argPairs
|
||||
`(object name ,(symbolName name) type ,type))]
|
||||
`{
|
||||
(defmethod ,name [,@methodArgs] ,@body)
|
||||
(method ,name [,@methodArgs] ,@body)
|
||||
(dictSet commands ,(symbolName name) (object args [,@commandArgs] handler (the Function ,name)))}))
|
||||
|
||||
(defnew [&prop :Archive archive
|
||||
@@ -184,4 +184,4 @@
|
||||
(selectEntries (filter archive.entries ->e (tagsMatch archive e tagsBoolExp))))
|
||||
|
||||
(defcommand selectByComponents [componentsBoolExp (Text null)]
|
||||
(selectEntries (filter archive.entries ->e (componentsMatch e componentsBoolExp)))))
|
||||
(selectEntries (filter archive.entries ->e (componentsMatch e componentsBoolExp)))))
|
||||
|
@@ -1,4 +1,4 @@
|
||||
(defun eval [:String expStr :Array<String> activeConditions]
|
||||
(function eval [:String expStr :Array<String> activeConditions]
|
||||
(let [hscriptExp
|
||||
(.parseString (new Parser)
|
||||
(Prelude.convertToHScript expStr))
|
||||
@@ -6,4 +6,4 @@
|
||||
(new BoolExpInterp)]
|
||||
(doFor condition activeConditions
|
||||
(interp.variables.set condition true))
|
||||
?(interp.execute hscriptExp)))
|
||||
?(interp.execute hscriptExp)))
|
||||
|
@@ -1,6 +1,6 @@
|
||||
(load "Lib.kiss")
|
||||
|
||||
(defun :Void main []
|
||||
(function :Void main []
|
||||
(let [[archiveDir] (Sys.args)
|
||||
controller
|
||||
(new ArchiveController
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
(defnew [])
|
||||
|
||||
(defmethod :Void enterText [prompt resolve maxLength]
|
||||
(method :Void enterText [prompt resolve maxLength]
|
||||
(Sys.print "$prompt ")
|
||||
(loop
|
||||
(let [entered (.toString (.readLine (Sys.stdin)))]
|
||||
@@ -25,7 +25,7 @@
|
||||
{(resolve entered)
|
||||
(break)}))))
|
||||
|
||||
(defmethod :Void enterNumber [prompt resolve min max &opt inStepsOf]
|
||||
(method :Void enterNumber [prompt resolve min max &opt inStepsOf]
|
||||
(Sys.print "$prompt ")
|
||||
(loop
|
||||
(let [entered (Std.parseFloat (.toString (.readLine (Sys.stdin))))]
|
||||
@@ -37,10 +37,10 @@
|
||||
{(resolve entered)
|
||||
(break)}))))
|
||||
|
||||
(defmethod :Void chooseEntry [prompt :Archive archive resolve]
|
||||
(method :Void chooseEntry [prompt :Archive archive resolve]
|
||||
(_chooseEntry prompt archive resolve ->(chooseEntry "empty name doesn't match any entries. Try again?" archive resolve)))
|
||||
|
||||
(defmethod :Void _chooseEntry [prompt :Archive archive resolve onEmptyString]
|
||||
(method :Void _chooseEntry [prompt :Archive archive resolve onEmptyString]
|
||||
// TODO allow narrowing down with a tag string
|
||||
(enterText "entry name for $prompt"
|
||||
->name {
|
||||
@@ -59,10 +59,10 @@
|
||||
(multipleEntries (throw "ambiguous between multiple entries")))))}
|
||||
Math.POSITIVE_INFINITY))
|
||||
|
||||
(defmethod :Void chooseEntries [prompt archive resolve min max]
|
||||
(method :Void chooseEntries [prompt archive resolve min max]
|
||||
(_chooseEntries prompt archive resolve min max []))
|
||||
|
||||
(defmethod :Void _chooseEntries [prompt archive resolve min max :Array<Entry> collectedEntries]
|
||||
(method :Void _chooseEntries [prompt archive resolve min max :Array<Entry> collectedEntries]
|
||||
(let [onEmptyString
|
||||
->(if (<= min collectedEntries.length)
|
||||
(resolve collectedEntries)
|
||||
@@ -84,12 +84,12 @@
|
||||
(_chooseNextEntry)))
|
||||
|
||||
|
||||
(defmethod handleChanges [:Archive archive :ChangeSet changeSet]
|
||||
(method handleChanges [:Archive archive :ChangeSet changeSet]
|
||||
(doFor e changeSet
|
||||
(print (archive.fullString e))))
|
||||
|
||||
(defmethod :Void displayMessage [message]
|
||||
(method :Void displayMessage [message]
|
||||
(print message))
|
||||
|
||||
(defmethod :Void reportError [error]
|
||||
(print error))
|
||||
(method :Void reportError [error]
|
||||
(print error))
|
||||
|
@@ -64,13 +64,13 @@
|
||||
(= ,value (readComponent ,archive e ,componentType))))
|
||||
,process))
|
||||
|
||||
(defun tagList [archive e]
|
||||
(function tagList [archive e]
|
||||
(let [t
|
||||
(readComponent archive e Tags)]
|
||||
(collect (t.keys))))
|
||||
|
||||
(defun tagsMatch [archive e tagsBoolExp]
|
||||
(function tagsMatch [archive e tagsBoolExp]
|
||||
(BoolExpInterp.eval tagsBoolExp (tagList archive e)))
|
||||
|
||||
(defun componentsMatch [:nat.Entry e componentsBoolExp]
|
||||
(BoolExpInterp.eval componentsBoolExp (for =>cType cId e.components cType)))
|
||||
(function componentsMatch [:nat.Entry e componentsBoolExp]
|
||||
(BoolExpInterp.eval componentsBoolExp (for =>cType cId e.components cType)))
|
||||
|
@@ -1,6 +1,6 @@
|
||||
(defprop :Map<String,Entry> entries (new Map))
|
||||
(prop :Map<String,Entry> entries (new Map))
|
||||
|
||||
(defmethod :Void process [:Archive archive]
|
||||
(method :Void process [:Archive archive]
|
||||
(doFor e (entries.iterator)
|
||||
(processEntry archive e)
|
||||
(archive.refreshEntry e)))
|
||||
@@ -9,7 +9,7 @@
|
||||
&prop :EntryProcessor processEntry]
|
||||
[])
|
||||
|
||||
(defmethod :Void checkEntryInOrOut [:Archive archive :Entry e]
|
||||
(method :Void checkEntryInOrOut [:Archive archive :Entry e]
|
||||
(if (canProcessEntry archive e)
|
||||
(dictSet entries e.id e)
|
||||
(entries.remove e.id)))
|
||||
|
@@ -4,7 +4,7 @@
|
||||
(load "../nat/Lib.kiss")
|
||||
|
||||
|
||||
(defun :Void main []
|
||||
(function :Void main []
|
||||
(assert (BoolExpInterp.eval "true" []))
|
||||
(assert !(BoolExpInterp.eval "false" []))
|
||||
(assert !(BoolExpInterp.eval "flag" []))
|
||||
@@ -32,4 +32,4 @@
|
||||
[author Author
|
||||
name Name]
|
||||
(assert (= author "Rafael Krux"))
|
||||
(assert (= name "Adventure")))))
|
||||
(assert (= name "Adventure")))))
|
||||
|
Reference in New Issue
Block a user