Skip to content
This repository has been archived by the owner on Aug 15, 2020. It is now read-only.

Commit

Permalink
- Change: Use helper.class.au3
Browse files Browse the repository at this point in the history
- Add: Delete old files from './dist/'
  • Loading branch information
Churanos committed Dec 14, 2017
1 parent ff6083d commit de70190
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 85 deletions.
3 changes: 2 additions & 1 deletion test.au3
Expand Up @@ -3,7 +3,8 @@

;~ $roma_compiler()


$roma_compiler.get_project_files()
ConsoleWrite('Typeof $roma_compiler.a_project_files: ' & $roma_helper.TypeOf($roma_compiler.a_project_files) & @CRLF)


$aTest = $roma_helper.Array()
Expand Down
114 changes: 30 additions & 84 deletions vendor/roma/compiler/compiler.class.au3
Expand Up @@ -3,7 +3,7 @@
#include "..\..\Autoit\Array.au3"
#include "..\..\AspirinJunkie\JSON.au3"
#include '..\..\AutoItObject\AutoItObject.au3'
#include '..\helper_functions.au3'
#include '..\helper.class.au3'

global $roma_compiler = obj_compiler()

Expand All @@ -24,7 +24,7 @@ func obj_compiler()
; ───────────────────────────────────────────────────────────────────────────────────────────────
with $this

.AddProperty('a_project_files', $ELSCOPE_READONLY, __Array())
.AddProperty('a_project_files', $ELSCOPE_READONLY, $roma_helper.Array())
.AddProperty('s_compiler_path', $ELSCOPE_READONLY, @ScriptDir & '\dist\')
.AddProperty('s_exclude_files', $ELSCOPE_READONLY, 'README.md;README_EN.MD;LICENSE;.gitignore;test.au3;.DS_Store;compiler.json;compiler.class.au3;*.isn')
.AddProperty('s_exclude_folder', $ELSCOPE_READONLY, '.git;storage;dist')
Expand All @@ -49,7 +49,7 @@ func __constructor($this)

$this.get_project_files()
$this.copy_files()
$this.set_namespace()
;~ $this.set_namespace()

endfunc

Expand All @@ -58,54 +58,45 @@ endfunc
@return: void
#ce ──────────────────────────────────────────────────────────────────────────────────────────────
func _meth_get_project_files($this)
#Region Old
;~ local $aFileList = _FileListToArrayRec('.', '*|' & $this.s_exclude_files &'|' & $this.s_exclude_folder, 1, 1)
;~ local $project_files[UBound($aFileList)][3]

;~ ; create array with path and modified date
;~ ; ───────────────────────────────────────────────────────────────────────────────────────────────
;~ for $i = 1 to UBound($aFileList) -1
;~ $project_files[$i][0] = $aFileList[$i]
;~ $project_files[$i][1] = FileGetTime($aFileList[$i], 0, 1)
;~ next

;~ $this.a_project_files = $project_files
#EndRegion

ConsoleWrite('$this.get_project_files()' & @CRLF)

local $aFileList = _FileListToArrayRec('.', '*|' & $this.s_exclude_files &'|' & $this.s_exclude_folder, 1, 1)
local $aProjectFiles = __Array()
local $aProjectFiles = $roma_helper.Array()
For $i = 1 To $aFileList[0]
_ArrayAdd($aProjectFiles, _oFile($aFileList[$i]))
_ArrayAdd($aProjectFiles, $roma_helper.File($aFileList[$i]))
Next
$this.a_project_files = $aProjectFiles

Return $this

endfunc

#cs :: copy files to dist
Method: PRIVATE
@return: void
#ce ──────────────────────────────────────────────────────────────────────────────────────────────
func _meth_copy_files($this)
#Region Old
; copy files if modified
; ───────────────────────────────────────────────────────────────────────────────────────────────
;~ for $i = 0 to UBound($this.a_project_files) -1
;~ if $this.a_project_files[$i][2] <> 0 then
;~ FileCopy($this.a_project_files[$i][0], $this.s_compiler_path & $this.a_project_files[$i][0], 8 + 1)
;~ endif
;~ next

;~ ; check if storage dir exists
;~ ; if not exists = create dir
;~ ; ───────────────────────────────────────────────────────────────────────────────────────────────
;~ if (FileExists($this.s_compiler_path & 'storage') = 0 ) then DirCreate($this.s_compiler_path & 'storage')
#EndRegion

; TODO: Remove old files from './dist/' before/after copying project files.
local $aOldFiles = _FileListToArrayRec('.\dist', '*', 1, 1)
If not @error Then
For $i = 1 To $aOldFiles[0]
Local $bInList = False
For $item in $this.a_project_files
If $item.name = $aOldFiles[$i] Then
$bInList = True
EndIf
Next

If Not $bInList Then
ConsoleWrite('File "'&$aOldFiles[$i]&'" no longer available, removing it.' & @CRLF)
FileDelete('.\dist\' & $aOldFiles[$i])
EndIf
Next
EndIf



ConsoleWrite('$this.copy_files()' & @CRLF)
For $item in $this.a_project_files
; TODO: Help!!! What should i compare here?
ConsoleWrite('Copying file "' & $item.name & '".' & @CRLF)
FileCopy($item.name, $this.s_compiler_path & $item.name, 8 + 1)
Next
Expand All @@ -115,59 +106,15 @@ func _meth_copy_files($this)
EndIf

Return $this

endfunc

#cs :: get all *.class.au3 files
Method: PRIVATE
@return: void
#ce ──────────────────────────────────────────────────────────────────────────────────────────────
func _meth_set_namespace($this)
#Region Old
;~ local $aFileList = _FileListToArrayRec('./dist', '*.class.au3', 1, 1)
;~
;~ for $i = 1 to UBound($aFileList) -1

;~ $fOpen = FileOpen('dist\' & $aFileList[$i], 2)
;~ $sFile = FileRead($fOpen)
;~
;~ ; get namespace
;~ ; ───────────────────────────────────────────────────────────────────────────────────────────────
;~ local $aNamespace = StringRegExp($sFile,'(;use.)(.*)',2)
;~ if IsArray($aNamespace) = 0 then ContinueLoop
;~ local $sNamespace = $aNamespace[2]

;~ ; Bringe alle addmethod in eine einheitliche form
;~ ; ───────────────────────────────────────────────────────────────────────────────────────────────
;~ local $pattern = '(?i)(.addmethod\()(.*)'
;~ local $a_methods = StringRegExp($sFile, $pattern, 4)

;~ for $i = 0 to UBound($a_methods) -1
;~ $a_method = $a_methods[$i]
;~ $sFile = StringReplace($sFile, $a_method[0], StringStripWs($a_method[0], 8))
;~ next

;~ ConsoleWrite($sFile)

;~ ; set namespcae
;~ ; ───────────────────────────────────────────────────────────────────────────────────────────────
;~ local $pattern = '(?i)(\.addmethod\(.\w*.{3})(\w*)(?:.\))|(?:_AutoItObject_AddMethod\(\$\w*.{2}\w*.{3})(\w*)(?:.\))'
;~ local $a_methods = StringRegExp( StringStripWS($sFile, 8), $pattern, 4)

;~ For $i = 0 to UBound($a_methods) -1
;~ $a_method = $a_methods[$i]
;~ $s_method = StringReplace($a_method[0], $a_method[2], $namespace & '__' & $a_method[2])
;~ $sFile = StringReplace($sFile, $a_method[0], $s_method)
;~ Next

;~ FileWrite($fOpen, $sFile)
;~ next

#EndRegion

ConsoleWrite('$this.set_namespace()' & @CRLF)
; ============================================================================
; ============================================================================
; ============================================================================
For $file in $this.a_project_files
If Not StringRegExp($file.name, '(?i)\.class\.au3$') Then ContinueLoop
ConsoleWrite('Parsing file "'&$file.name&'".' & @CRLF)
Expand Down Expand Up @@ -197,8 +144,8 @@ func _meth_set_namespace($this)
$sFile = StringReplace($sFile, $a_method[0], StringStripWs($a_method[0], 8))
next


ConsoleWrite($sFile)
; Show content for newly file
;~ ConsoleWrite($sFile)

; set namespcae
; ───────────────────────────────────────────────────────────────────────────────────────────────
Expand All @@ -219,6 +166,5 @@ func _meth_set_namespace($this)
Next

Return $this
; ============================================================================

endfunc

0 comments on commit de70190

Please sign in to comment.