-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from soburi/update_ot_api
Update Openthread APIs
- Loading branch information
Showing
11 changed files
with
1,204 additions
and
438 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
def classese_extract(line, classes) | ||
classes.each do |clz| | ||
if line =~ / ot#{clz}([^\(]*\()/ | ||
line.sub!(/ ot#{clz}/, "\t#{clz}::") | ||
return true | ||
end | ||
end | ||
|
||
return false | ||
end | ||
|
||
def compact_space(line) | ||
line.gsub!(/\ \ */," ") | ||
line.gsub!(/ \*/,"* ") | ||
line.gsub!(/const /,"const_") | ||
line.gsub!(/static_/,"static_") | ||
line.gsub!(/OT_TOOL_WEAK /,"OT_TOOL_WEAK_") | ||
end | ||
|
||
readlines.each do |line| | ||
compact_space(line) | ||
ret = classese_extract(line, | ||
['Udp', 'Thread', 'Tasklets', 'SntpClient', 'Server', 'RandomNonCrypto', 'RandomCrypto', | ||
'Plat', 'NetworkTime', 'NetData', 'Ncp', 'Message', 'Logging', 'Link', 'Joiner', 'JamDetection', | ||
'Ip6', 'Instance', 'Icmp6', 'Heap', 'Entropy', 'DnsClient', 'Diag', 'Dataset', | ||
'Crypto', 'Cli', 'Commissioner', 'CoapSecure', 'Coap', 'ChildSupervision', 'ChannelMonitor', | ||
'ChannelManager', 'BorderRouter', 'BorderAgent', 'BackboneRouter']) | ||
|
||
if ret | ||
STDOUT.print line | ||
else | ||
STDERR.print line | ||
end | ||
|
||
end |
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,15 @@ | ||
|
||
headers = [ "backbone_router.h", "backbone_router_ftd.h", "border_agent.h", "border_router.h", "channel_manager.h", "channel_monitor.h", "child_supervision.h", "cli.h", "coap.h", "coap_secure.h", "commissioner.h", "config.h", "crypto.h", "dataset.h", "dataset_ftd.h", "diag.h", "dns.h", "entropy.h", "error.h", "heap.h", "icmp6.h", "instance.h", "ip6.h", "jam_detection.h", "joiner.h", "link.h", "link_raw.h", "logging.h", "message.h", "ncp.h", "netdata.h", "netdiag.h", "network_time.h", "ot_api_doc.h", "platform", "random_crypto.h", "random_noncrypto.h", "server.h", "sntp.h", "tasklet.h", "thread.h", "thread_ftd.h", "udp.h"] | ||
|
||
filtered = readlines.select do |line| | ||
x = true | ||
x = false if not headers.include?( line.split("\t")[0].split(/\//).last ) | ||
x = false if not line =~ /\(/ | ||
x = false if line =~ /::/ | ||
x = false if line =~ /typedef/ | ||
x | ||
end | ||
|
||
filtered.sort.uniq.each do |line| | ||
print line | ||
end |
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,34 @@ | ||
|
||
lines = readlines | ||
|
||
clzz = [] | ||
|
||
lines.each do |line| | ||
line =~ /(\w*)::/ | ||
clzz.append($1) | ||
end | ||
|
||
|
||
clzz.sort.uniq.each do |clz| | ||
|
||
print " class OT#{clz} {\n" | ||
print " friend class OpenThreadClass;\n" | ||
print " public:\n" | ||
lines.each do |line| | ||
if line =~ /#{clz}::/ | ||
if line =~ /\(otInstance\* aInstance/ | ||
line.gsub!(/#{clz}::/,"") | ||
line.gsub!(/\(otInstance\* aInstance/,"(") | ||
line.gsub!(/\(, /,"(") | ||
print " #{line.strip.sub(/\t/, " ")}".gsub(/const_/, "const ") | ||
print ";\n" | ||
else | ||
print " //#{line.strip.sub(/\t/, " ")}".gsub(/const_/, "const ") | ||
print ";\n" | ||
end | ||
end | ||
end | ||
print " };\n" | ||
print "\n" | ||
end | ||
|
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,25 @@ | ||
require 'rexml/document' | ||
require 'rexml/formatters/pretty' | ||
require 'pp' | ||
require 'stringio' | ||
|
||
formatter = REXML::Formatters::Pretty.new | ||
|
||
ARGV.each do |file| | ||
xml = REXML::Document.new(File.new(file)) | ||
|
||
|
||
REXML::XPath.each(xml, "/doxygen/compounddef/sectiondef/memberdef") do |e| | ||
# print "---- #{file}\n" | ||
if e.elements['definition'] | ||
print e.elements['location'].attributes['file'] | ||
print "\t" | ||
print e.elements['definition'].text | ||
print e.elements['argsstring'].text if e.elements['argsstring'] | ||
print "\n" | ||
end | ||
end | ||
output = StringIO.new | ||
# formatter.write(xml, output) | ||
# print output.string | ||
end |
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,29 @@ | ||
print "#include \"OpenThread.h\"\n" | ||
print "#include <openthread/openthread-freertos.h>\n" | ||
print "\n" | ||
|
||
readlines.each do |line| | ||
line.gsub!(/\s[\w\*]*,/, ",") | ||
line.gsub!(/\s[\w\*]*\)/, ")") | ||
line.gsub!(/\s+\w+\[], /, "*, ") | ||
line.gsub!(/::/,"\t") | ||
line.gsub!(/\(/,"\t") | ||
line.gsub!(/,/,"\t") | ||
line.gsub!(/\)/,"") | ||
line.gsub!(/static /, "") | ||
data = line.chomp.split(/\t/).collect {|d| d.strip} | ||
|
||
if data[3] == "otInstance*" | ||
cols = [(data.count-4).to_s, data[1], data[0], data[2] ].concat( data[4..-1].reject{|i|i=='void'} ) | ||
if data[0] == "void" | ||
print "OT_DECL_VFUNC(#{cols.join(', ')})\n".gsub(/const_/,"const ") | ||
else | ||
print "OT_DECL__FUNC(#{cols.join(', ')})\n".gsub(/const_/,"const ") | ||
end | ||
else | ||
cols = [(data.count-3).to_s, data[1], data[2], data[0] ] + data[3..-1] | ||
print "/*OT_DECL__FUNC(#{cols.join(', ')})*/\n".gsub(/const_/,"const ") | ||
end | ||
|
||
|
||
end |
Oops, something went wrong.