Project

General

Profile

Actions

Feature #11215

closed

pack/unpack for (u)intptr_t

Added by usa (Usaku NAKAMURA) almost 9 years ago. Updated almost 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-dev:49015]

Description

以前にも似たようなものを提案したような気がしないでもないですが、
WindowsのAPIを叩いてるとどうしても必要になるので改めて提案します。

pack/unpackのテンプレート文字として、新たに、

j: intptr_t, native endian
J: uintptr_t, native endian

を追加することを提案します。

他のプラットフォームではlongがこれと一致することが多いためにあまり問題に
ならないようですが、WindowsではそうではないのでAPIを叩くたびに毎度苦労しています。
(そもそもAPIを叩く頻度もWindowsは他のプラットフォームより高そうな気がします)

パッチも用意したので添付しておきます。


Files

pack_jJ.patch (10.5 KB) pack_jJ.patch usa (Usaku NAKAMURA), 06/03/2015 07:32 AM

Updated by usa (Usaku NAKAMURA) almost 9 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 9 years ago

パッチの中に /* j for intptr_t */ というコメントがふたつありますが、ひとつは J ですかね。

Updated by matz (Yukihiro Matsumoto) almost 9 years ago

English please, next time.

Both functionality and template character selection are OK.
Go ahead.

Matz.

Actions #4

Updated by usa (Usaku NAKAMURA) almost 9 years ago

  • Status changed from Open to Closed

Applied in changeset r50849.


  • pack.c (pack_{un,}pack): new template character j and J, pointer
    with signed and unsigned integers.

  • NEWS: mention bout this featre.
    [Feature #11215] [ruby-dev:49015]

Updated by usa (Usaku NAKAMURA) almost 9 years ago

Akira Tanaka wrote:

パッチの中に /* j for intptr_t */ というコメントがふたつありますが、ひとつは J ですかね。

ご指摘の通りです。ありがとうございます。

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0