mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 21:17:03 +00:00
41 lines
1.1 KiB
Ruby
Executable File
41 lines
1.1 KiB
Ruby
Executable File
#! /usr/bin/env ruby
|
|
|
|
def makeHeaderFileFrom(fileName)
|
|
# Grab the entire file (text)
|
|
data = File.new(fileName).read
|
|
|
|
# Extract out all the "implementation" lines. Note, there may be
|
|
# more than on in a given .j file.
|
|
m = data.scan(/.*?(@implementation.*?\{.*?\})/m)
|
|
|
|
if m.length > 0
|
|
for i in 0...m.length
|
|
line = m[i][0]
|
|
|
|
# Skip category definitions
|
|
if not /.*?\(.*?\).*?\{/m.match(line)
|
|
|
|
# Extract the class name
|
|
m2 = line.scan(/.*?@implementation(.*?):.*/m)
|
|
|
|
if !m2.nil? && !m2[0].nil?
|
|
className = m2[0][0].strip()
|
|
|
|
# Change "implementation" to "interface", create the .h file, and write the interface
|
|
newLine = line.sub("implementation", "interface")
|
|
newFileName = File.dirname(fileName) + "/" + className + ".h"
|
|
f = File.new(newFileName, "w")
|
|
f.write(newLine + "\n@end")
|
|
f.close()
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
fileList = Dir['AppKit.doc/**/*.j'] + Dir['Foundation.doc/**/*.j']
|
|
|
|
for fileName in fileList
|
|
makeHeaderFileFrom(fileName)
|
|
end
|