Project

General

Profile

Feature #11215

pack/unpack for (u)intptr_t

Added by usa (Usaku NAKAMURA) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
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

Associated revisions

Revision dc0d502b
Added by usa (Usaku NAKAMURA) about 4 years ago

  • 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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 50849
Added by usa (Usaku NAKAMURA) about 4 years ago

  • 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]

Revision 50849
Added by usa (Usaku NAKAMURA) about 4 years ago

  • 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]

Revision 50849
Added by usa (Usaku NAKAMURA) about 4 years ago

  • 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]

Revision 50849
Added by usa (Usaku NAKAMURA) about 4 years ago

  • 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]

Revision 50849
Added by usa (Usaku NAKAMURA) about 4 years ago

  • 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]

History

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

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

Updated by matz (Yukihiro Matsumoto) about 4 years ago

English please, next time.

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

Matz.

#4

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

Akira Tanaka wrote:

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

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

Also available in: Atom PDF