Feature #11215
closedpack/unpack for (u)intptr_t
Description
以前にも似たようなものを提案したような気がしないでもないですが、
WindowsのAPIを叩いてるとどうしても必要になるので改めて提案します。
pack/unpackのテンプレート文字として、新たに、
j: intptr_t, native endian
J: uintptr_t, native endian
を追加することを提案します。
他のプラットフォームではlongがこれと一致することが多いためにあまり問題に
ならないようですが、WindowsではそうではないのでAPIを叩くたびに毎度苦労しています。
(そもそもAPIを叩く頻度もWindowsは他のプラットフォームより高そうな気がします)
パッチも用意したので添付しておきます。
Files
Updated by usa (Usaku NAKAMURA) almost 10 years ago
あ、言い忘れましたが、j/Jはperlでは
j A Perl internal signed integer value (IV).
J A Perl internal unsigned integer value (UV).
だそうです。( http://perldoc.perl.org/functions/pack.html )
これはRubyのVALUEとはちょっと意味合いが違いますし、必ずしもポインタ幅でもないので、
本提案はperlのものとは意味がずれることになります。
が、perl独自幅の整数をRubyでサポートするはずはないので問題はないかと。
Updated by akr (Akira Tanaka) almost 10 years ago
パッチの中に /* j for intptr_t */ というコメントがふたつありますが、ひとつは J ですかね。
Updated by matz (Yukihiro Matsumoto) almost 10 years ago
English please, next time.
Both functionality and template character selection are OK.
Go ahead.
Matz.
Updated by usa (Usaku NAKAMURA) almost 10 years ago
- Status changed from Open to Closed
Applied in changeset r50849.
-
pack.c (pack_{un,}pack): new template character
j
andJ
, pointer
with signed and unsigned integers. -
NEWS: mention bout this featre.
[Feature #11215] [ruby-dev:49015]
Updated by usa (Usaku NAKAMURA) almost 10 years ago
Akira Tanaka wrote:
パッチの中に /* j for intptr_t */ というコメントがふたつありますが、ひとつは J ですかね。
ご指摘の通りです。ありがとうございます。