內容

名稱

ExtUtils::Typemaps::OutputMap - 在 typemap 的 OUTPUT 區段中的項目

語法

use ExtUtils::Typemaps;
...
my $output = $typemap->get_output_map('T_NV');
my $code = $output->code();
$output->code("...");

說明

有關詳細資訊,請參閱 ExtUtils::Typemaps

方法

new

需要 xstypecode 參數。

code

傳回或設定此項目的 OUTPUT 對應程式碼。

xstype

傳回 OUTPUT 對應的 XS 類型名稱。

cleaned_code

傳回已清除的程式碼副本,已套用特定轉換以使其更符合 ANSI 標準。

targetable

這是一個模糊但有效的最佳化,用於直接存在於 ExtUtils::ParseXS 中。不實作它絕不會導致類型映射的錯誤使用,僅會產生效率較低的程式碼。

簡而言之,這將檢查輸出程式碼是否涉及呼叫 sv_setivsv_setuvsv_setnvsv_setpvsv_setpvn,以將特殊 $arg 佔位符設定為新值在輸出程式碼的結尾。如果是這樣,程式碼就有資格使用與 TARG 相關的巨集來最佳化此程式碼。因此,方法的名稱:targetable

如果此最佳化適用,ExtUtils::ParseXS 將在所產生的 XSUB 程式碼的開頭發出 dXSTARG; 定義,以及類型(見下文)依賴的程式碼,以在所產生的 XSUB 程式碼的結尾設定 TARG 並將其推入堆疊。

如果無法套用最佳化,則傳回未定義。如果可以套用,則此方法傳回包含下列資訊的雜湊參考

type:      Any of the characters i, u, n, p
with_size: Bool indicating whether this is the sv_setpvn variant
what:      The code that actually evaluates to the output scalar
what_size: If "with_size", this has the string length (as code,
           not constant, including leading comma)

另請參閱

ExtUtils::Typemaps

作者

Steffen Mueller <smueller@cpan.org>

版權和授權

版權所有 2009、2010、2011、2012 Steffen Mueller

此程式為自由軟體;您可以在與 Perl 相同的條款下重新散布或修改它。