11use RustQ.Config
22
3- alias RustQ . { Rust , Rustler }
3+ alias RustQ.Rustler . { Atom , Nif , Term }
44
55codegen_atom_sources = [
66 "native/oxc_ex_nif/src/codegen.rs" ,
@@ -32,11 +32,11 @@ codegen_atoms =
3232 end )
3333
3434rust :codegen_atoms , "native/oxc_ex_nif/src/generated_codegen_atoms.rs" do
35- Rustler . atoms ( codegen_atoms , module: false )
35+ Atom . declaration ( codegen_atoms , module: false )
3636end
3737
3838rust "native/oxc_ex_nif/src/generated_atoms.rs" do
39- Rustler . atoms ( [
39+ Atom . declaration ( [
4040 :ok ,
4141 :error ,
4242 { :atom_static , "static" } ,
@@ -104,11 +104,11 @@ rust "native/oxc_ex_nif/src/generated_atoms.rs" do
104104end
105105
106106rust "native/oxc_lint_nif/src/generated_atoms.rs" do
107- Rustler . atoms ( [ :ok , :error , :warn , :deny , :allow ] )
107+ Atom . declaration ( [ :ok , :error , :warn , :deny , :allow ] )
108108end
109109
110110rust "native/oxc_fmt_nif/src/generated_atoms.rs" do
111- Rustler . atoms ( [
111+ Atom . declaration ( [
112112 :ok ,
113113 :error ,
114114 :print_width ,
@@ -147,20 +147,20 @@ rust "native/oxc_fmt_nif/src/generated_atoms.rs" do
147147end
148148
149149rust "native/oxc_fmt_nif/src/generated_option_helpers.rs" do
150- Rustler . term_helpers ( include: [ :get , :get_bool , :get_i64 , :get_string , :get_string_list , :get_map ] )
150+ Term . helpers ( include: [ :get , :get_bool , :get_i64 , :get_string , :get_string_list , :get_map ] )
151151end
152152
153- type_key = Rust . path ( [ :a , " r#type" ] ) <> " ()"
153+ type_key = "a:: r#type()"
154154
155155rust "native/oxc_ex_nif/src/generated_term_helpers.rs" do
156- Rustler . term_helpers (
156+ Term . helpers (
157157 type_key: type_key ,
158158 include: [ :get , :is_nil , :opt , :str_val , :bool_val , :f64_val , :list_val , :type_atom , :type_eq , :type_str ]
159159 )
160160end
161161
162162rust "native/oxc_ex_nif/src/generated_option_helpers.rs" do
163- Rustler . term_helpers (
163+ Term . helpers (
164164 include: [
165165 :get ,
166166 :is_nil ,
@@ -174,13 +174,13 @@ rust "native/oxc_ex_nif/src/generated_option_helpers.rs" do
174174end
175175
176176rust "native/oxc_ex_nif/src/generated_ast_decoders.rs" do
177- Rustler . term_decoder ( :ProgramInput ,
177+ Term . decoder ( :ProgramInput ,
178178 fields: [
179179 body: [ type: { :vec , "Term<'a>" } , key: "a::body()" , required: true ]
180180 ]
181181 )
182182
183- Rustler . term_decoder ( :IfStatementInput ,
183+ Term . decoder ( :IfStatementInput ,
184184 result: "R" ,
185185 fields: [
186186 test: [ type: "Term<'a>" , key: "a::test()" , required: true ] ,
@@ -191,60 +191,43 @@ rust "native/oxc_ex_nif/src/generated_ast_decoders.rs" do
191191end
192192
193193fmt_source = "native/oxc_fmt_nif/src/lib.rs"
194- fmt_nifs = [ format: [ lifetime: :a ] ]
194+ fmt_nifs = [ format: [ ] ]
195195
196196rust :fmt_nifs , "native/oxc_fmt_nif/src/generated_nifs.rs" do
197- Rustler . nif_exports_from_source ( fmt_source , fmt_nifs , schedule: :dirty_cpu )
197+ Nif . wrappers_from_source ( fmt_source , fmt_nifs , schedule: :dirty_cpu )
198198end
199199
200200generate :fmt_native_stubs , "lib/oxc/format/native/generated_stubs.ex" do
201201 build ( fn ->
202- Rustler . nif_stubs_from_source ( fmt_source , fmt_nifs , OXC.Format.Native.GeneratedStubs )
202+ Nif . stubs_from_source ( fmt_source , fmt_nifs , OXC.Format.Native.GeneratedStubs )
203203 end )
204204end
205205
206206lint_source = "native/oxc_lint_nif/src/lib.rs"
207- lint_nifs = [ lint: [ lifetime: :a ] ]
207+ lint_nifs = [ lint: [ ] ]
208208
209209rust :lint_nifs , "native/oxc_lint_nif/src/generated_nifs.rs" do
210- Rustler . nif_exports_from_source ( lint_source , lint_nifs , schedule: :dirty_cpu )
210+ Nif . wrappers_from_source ( lint_source , lint_nifs , schedule: :dirty_cpu )
211211end
212212
213213generate :lint_native_stubs , "lib/oxc/lint/native/generated_stubs.ex" do
214214 build ( fn ->
215- Rustler . nif_stubs_from_source ( lint_source , lint_nifs , OXC.Lint.Native.GeneratedStubs )
215+ Nif . stubs_from_source ( lint_source , lint_nifs , OXC.Lint.Native.GeneratedStubs )
216216 end )
217217end
218218
219219native_nif_groups = [
220- { "native/oxc_ex_nif/src/parse.rs" ,
221- [ parse: [ lifetime: :a ] , valid: [ ] , transform: [ lifetime: :a ] , minify: [ lifetime: :a ] ] } ,
222- { "native/oxc_ex_nif/src/bundle.rs" ,
223- [ bundle: [ lifetime: :a ] , bundle_entry: [ lifetime: :a ] , bundle_run: [ lifetime: :a ] ] } ,
224- { "native/oxc_ex_nif/src/imports.rs" , [ select: [ lifetime: :a ] ] } ,
225- { "native/oxc_ex_nif/src/transform_many.rs" , [ transform_many: [ lifetime: :a ] ] } ,
226- { "native/oxc_ex_nif/src/codegen.rs" , [ codegen: [ lifetime: :a ] ] }
220+ { "native/oxc_ex_nif/src/parse.rs" , [ parse: [ ] , valid: [ ] , transform: [ ] , minify: [ ] ] } ,
221+ { "native/oxc_ex_nif/src/bundle.rs" , [ bundle: [ ] , bundle_entry: [ ] , bundle_run: [ ] ] } ,
222+ { "native/oxc_ex_nif/src/imports.rs" , [ select: [ ] ] } ,
223+ { "native/oxc_ex_nif/src/transform_many.rs" , [ transform_many: [ ] ] } ,
224+ { "native/oxc_ex_nif/src/codegen.rs" , [ codegen: [ ] ] }
227225]
228226
229- native_nif_functions =
230- Enum . flat_map ( native_nif_groups , fn { source , nifs } ->
231- metadata = source |> RustQ.Syn . parse_file! ( ) |> RustQ.Syn . functions ( )
232-
233- Enum . map ( nifs , fn { name , _opts } ->
234- implementation = "#{ name } _impl"
235- function = Enum . find ( metadata , & ( & 1 . name == implementation ) )
236-
237- function || raise ArgumentError , "NIF implementation #{ implementation } not found in #{ source } "
238- { name , function }
239- end )
240- end )
241-
242227rust :native_nifs , "native/oxc_ex_nif/src/generated_nifs.rs" do
243- Enum . flat_map ( native_nif_groups , fn { source , nifs } ->
244- Rustler . nif_exports_from_source ( source , nifs , schedule: :dirty_cpu )
245- end )
228+ Nif . wrappers_from_sources ( native_nif_groups , schedule: :dirty_cpu )
246229end
247230
248231generate :native_stubs , "lib/oxc/native/generated_stubs.ex" do
249- content ( Rustler . nif_stubs_from_functions ( native_nif_functions , OXC.Native.GeneratedStubs ) )
232+ content ( Nif . stubs_from_sources ( native_nif_groups , OXC.Native.GeneratedStubs ) )
250233end
0 commit comments