@@ -50,6 +50,39 @@ function recursively_add_types!(types::Base.IdSet{DataType}, @nospecialize(T::Da
50
50
return types
51
51
end
52
52
53
+ function write_logfile (io:: IO )
54
+ iotmp = IOBuffer ()
55
+ types = Base. IdSet {DataType} ()
56
+ Base. visit (Core. GlobalMethods) do method
57
+ if isdefined (method, :ccallable )
58
+ rt, sig = method. ccallable
59
+ name = length (method. ccallable) > 2 ? Symbol (method. ccallable[3 ]) : method. name
60
+ print (IOContext (iotmp, :print_method_signature_only => true ), method)
61
+ methodstr = String (take! (iotmp))
62
+ if name != = method. name
63
+ methodstr = replace (methodstr, String (method. name) => String (name))
64
+ end
65
+ println (io, methodstr, " ::" , rt)
66
+ for T in sig. parameters[2 : end ]
67
+ recursively_add_types! (types, T)
68
+ end
69
+ end
70
+ end
71
+ println (io) # blank line separates methods from types
72
+ for T in types
73
+ println (io, T)
74
+ dtfd = Base. DataTypeFieldDesc (T)
75
+ local fd
76
+ for i = 1 : Base. datatype_nfields (T)
77
+ fd = dtfd[i]
78
+ fn = fieldname (T, i)
79
+ ft = fieldtype (T, i)
80
+ println (io, " " , fn, " ::" , ft, " [" , fd. offset, " ]" )
81
+ end
82
+ println (io, fd. offset + fd. size, " bytes" )
83
+ end
84
+ end
85
+
53
86
# Load user code
54
87
55
88
import Base. Experimental. entrypoint
@@ -100,37 +133,8 @@ let mod = Base.include(Main, ARGS[1])
100
133
# Export info about entrypoints and structs needed to create header files
101
134
if length (ARGS ) >= 4
102
135
logfile = ARGS [4 ]
103
- iotmp = IOBuffer ()
104
136
open (logfile, " w" ) do io
105
- types = Base. IdSet {DataType} ()
106
- Base. visit (Core. GlobalMethods) do method
107
- if isdefined (method, :ccallable )
108
- rt, sig = method. ccallable
109
- name = length (method. ccallable) > 2 ? Symbol (method. ccallable[3 ]) : method. name
110
- print (IOContext (iotmp, :print_method_signature_only => true ), method)
111
- methodstr = String (take! (iotmp))
112
- if name != = method. name
113
- methodstr = replace (methodstr, String (method. name) => String (name))
114
- end
115
- println (io, methodstr, " ::" , rt)
116
- for T in sig. parameters[2 : end ]
117
- recursively_add_types! (types, T)
118
- end
119
- end
120
- end
121
- println (io) # blank line separates methods from types
122
- for T in types
123
- println (io, T)
124
- dtfd = Base. DataTypeFieldDesc (T)
125
- local fd
126
- for i = 1 : Base. datatype_nfields (T)
127
- fd = dtfd[i]
128
- fn = fieldname (T, i)
129
- ft = fieldtype (T, i)
130
- println (io, " " , fn, " ::" , ft, " [" , fd. offset, " ]" )
131
- end
132
- println (io, fd. offset + fd. size, " bytes" )
133
- end
137
+ write_logfile (io)
134
138
end
135
139
end
136
140
end
0 commit comments