Skip to content

Commit d942505

Browse files
committed
refactor(swc/plugin_macro): refine internal macro fn ident name
1 parent 881833d commit d942505

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

crates/swc_cli/src/commands/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl VisitMut for TransformVisitor {
228228
/// as returning ptr back to host.
229229
///
230230
/// It is possible to opt out from macro by writing transform fn manually via
231-
/// `__plugin_process_impl(
231+
/// `__transform_plugin_process_impl(
232232
/// ast_ptr: *const u8,
233233
/// ast_ptr_len: i32,
234234
/// config_str_ptr: *const u8,

crates/swc_plugin_macro/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ pub fn plugin_transform(
1919

2020
fn handle_func(func: ItemFn) -> TokenStream {
2121
let ident = func.sig.ident.clone();
22-
let process_impl_ident = Ident::new("__plugin_process_impl", Span::call_site());
22+
let transform_process_impl_ident =
23+
Ident::new("__transform_plugin_process_impl", Span::call_site());
2324

2425
let ret = quote! {
2526
#func
@@ -59,7 +60,7 @@ fn handle_func(func: ItemFn) -> TokenStream {
5960
// There are some cases error won't be wrapped up however - for example, we expect
6061
// serialization of PluginError itself should succeed.
6162
#[no_mangle]
62-
pub fn #process_impl_ident(ast_ptr: *const u8, ast_ptr_len: i32, config_str_ptr: *const u8, config_str_ptr_len: i32, context_str_ptr: *const u8, context_str_ptr_len: i32, should_enable_comments_proxy: i32) -> i32 {
63+
pub fn #transform_process_impl_ident(ast_ptr: *const u8, ast_ptr_len: i32, config_str_ptr: *const u8, config_str_ptr_len: i32, context_str_ptr: *const u8, context_str_ptr_len: i32, should_enable_comments_proxy: i32) -> i32 {
6364
// Reconstruct `Program` & config string from serialized program
6465
// Host (SWC) should allocate memory, copy bytes and pass ptr to plugin.
6566
let program = unsafe { swc_plugin::deserialize_from_ptr(ast_ptr, ast_ptr_len).map(|v| v.into_inner()) };

crates/swc_plugin_runner/src/transform_executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl TransformExecutor {
4040
exported_plugin_transform: instance
4141
.exports
4242
.get_native_function::<(i32, i32, i32, i32, i32, i32, i32), i32>(
43-
"__plugin_process_impl",
43+
"__transform_plugin_process_impl",
4444
)?,
4545
exported_plugin_free: instance
4646
.exports

tests/rust-plugins/swc_internal_plugin/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl VisitMut for ConsoleOutputReplacer {
2929
/// as returning ptr back to host.
3030
///
3131
/// It is possible to opt out from macro by writing transform fn manually via
32-
/// `__plugin_process_impl(
32+
/// `__transform_plugin_process_impl(
3333
/// ast_ptr: *const u8,
3434
/// ast_ptr_len: i32,
3535
/// config_str_ptr: *const u8,

0 commit comments

Comments
 (0)