Skip to content

Commit

Permalink
Merge pull request #27 from soburi/update_ot_api
Browse files Browse the repository at this point in the history
Update Openthread APIs
  • Loading branch information
soburi authored Jul 22, 2020
2 parents cc01d04 + 9b20aa3 commit bfdb7bb
Show file tree
Hide file tree
Showing 11 changed files with 1,204 additions and 438 deletions.
35 changes: 35 additions & 0 deletions libraries/OpenThread/dist/format_protptype.rb
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
15 changes: 15 additions & 0 deletions libraries/OpenThread/dist/funclist_filter_api.rb
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
34 changes: 34 additions & 0 deletions libraries/OpenThread/dist/gen_class_decls.rb
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

25 changes: 25 additions & 0 deletions libraries/OpenThread/dist/gen_funclist_from_doxyxml.rb
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
29 changes: 29 additions & 0 deletions libraries/OpenThread/dist/gen_impls.rb
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
Loading

0 comments on commit bfdb7bb

Please sign in to comment.