-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add support for the @inherit tag!
- Loading branch information
Showing
26 changed files
with
1,152 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
local Moonwave = require("moonwave") | ||
local Tags = require("tags") | ||
|
||
local Processor = {} | ||
|
||
function Processor.getObjectFromName(packageCommentJson: Moonwave.moonwaveDataExportArray, packageName: string): processedMoonwaveDataExportObject? | ||
for _, object in packageCommentJson do | ||
if object.name == packageName then | ||
return object | ||
end | ||
end | ||
|
||
return nil | ||
end | ||
|
||
function Processor.processInheritedObject(packageCommentJson: Moonwave.moonwaveDataExportArray, packageObject: processedMoonwaveDataExportObject) | ||
if packageObject._processed then | ||
return packageObject | ||
end | ||
|
||
local packageTags, tagCount = Tags.getTags(packageObject) | ||
|
||
if tagCount == 0 then | ||
packageObject._processed = true | ||
|
||
return packageObject | ||
end | ||
|
||
for tagName, tagArguments in packageTags do | ||
if tagName == "inherit" then | ||
local inheritedPackageObject = Processor.getObjectFromName(packageCommentJson, tagArguments[1]) | ||
|
||
assert(packageObject, `Object '{packageObject.name}' attempted to inherit from invalid class: '{inheritedPackageObject}'`) | ||
|
||
local processedPackageObject = Processor.processInheritedObject(packageCommentJson, inheritedPackageObject) | ||
|
||
if not packageObject.inherited then | ||
packageObject.inherited = {} | ||
end | ||
|
||
(packageObject.inherited :: { })[processedPackageObject.name] = { | ||
properties = processedPackageObject.properties, | ||
functions = processedPackageObject.functions | ||
} | ||
|
||
print(`{packageObject.name} INHERITS FROM {processedPackageObject.name}`) | ||
else | ||
warn(`Unknown tag '{packageTags}'`) | ||
end | ||
end | ||
|
||
packageObject._processed = true | ||
|
||
return packageObject | ||
end | ||
|
||
function Processor.processInheritedObjects(packageCommentJson: Moonwave.moonwaveDataExportArray) | ||
for _, object in packageCommentJson do | ||
Processor.processInheritedObject(packageCommentJson, object) | ||
end | ||
|
||
return packageCommentJson | ||
end | ||
|
||
type processedMoonwaveDataExportObject = Moonwave.moonwaveDataExportObject & { | ||
_processed: boolean? | ||
} | ||
|
||
return Processor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
local Moonwave = require("moonwave") | ||
|
||
local Tags = {} | ||
|
||
function Tags.getTags(packageObject: Moonwave.moonwaveDataExportObject) | ||
local tagObjects: { [string]: {string} } = {} | ||
local tagCount = 0 | ||
|
||
if packageObject.tags then | ||
for _, tagString in packageObject.tags do | ||
local tagMetadata = string.split(tagString, " ") | ||
local tagName = table.remove(tagMetadata, 1) | ||
|
||
tagCount += 1 | ||
tagObjects[tagName] = tagMetadata | ||
end | ||
end | ||
|
||
return tagObjects, tagCount | ||
end | ||
|
||
return Tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.