mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge branch 'master' of github.com:mruby/mruby
This commit is contained in:
+5
-2
@@ -3,6 +3,7 @@
|
||||
*.dylib
|
||||
*.inc
|
||||
*.o
|
||||
*.a
|
||||
*.orig
|
||||
*.rej
|
||||
*.sav
|
||||
@@ -14,5 +15,7 @@
|
||||
.svn
|
||||
/.git
|
||||
cscope.out
|
||||
mruby.exe
|
||||
y.tab.c
|
||||
/src/y.tab.c
|
||||
/bin
|
||||
/mrblib/mrblib.c
|
||||
/mrblib/*.*tmp
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
mRuby is copyrighted free software by mruby developers <info@mruby.org>.
|
||||
You can redistribute it and/or modify it under either the terms of the
|
||||
MIT license (see the file MITL), or the conditions below:
|
||||
|
||||
1. You may make and give away verbatim copies of the source form of the
|
||||
software without restriction, provided that you duplicate all of the
|
||||
original copyright notices and associated disclaimers.
|
||||
|
||||
2. You may modify your copy of the software in any way, provided that
|
||||
you do at least ONE of the following:
|
||||
|
||||
a) place your modifications in the Public Domain or otherwise
|
||||
make them Freely Available, such as by posting said
|
||||
modifications to Usenet or an equivalent medium, or by allowing
|
||||
the author to include your modifications in the software.
|
||||
|
||||
b) use the modified software only within your corporation or
|
||||
organization.
|
||||
|
||||
c) give non-standard binaries non-standard names, with
|
||||
instructions on where to get the original software distribution.
|
||||
|
||||
d) make other distribution arrangements with the author.
|
||||
|
||||
3. You may distribute the software in object code or binary form,
|
||||
provided that you do at least ONE of the following:
|
||||
|
||||
a) distribute the binaries and library files of the software,
|
||||
together with instructions (in the manual page or equivalent)
|
||||
on where to get the original distribution.
|
||||
|
||||
b) accompany the distribution with the machine-readable source of
|
||||
the software.
|
||||
|
||||
c) give non-standard binaries non-standard names, with
|
||||
instructions on where to get the original software distribution.
|
||||
|
||||
d) make other distribution arrangements with the author.
|
||||
|
||||
4. You may modify and include the part of the software into any other
|
||||
software (possibly commercial). But some files in the distribution
|
||||
are not written by the author, so that they are not under these terms.
|
||||
|
||||
For the list of those files and their copying conditions, see the
|
||||
file LEGAL.
|
||||
|
||||
5. The scripts and library files supplied as input to or produced as
|
||||
output from the software do not automatically fall under the
|
||||
copyright of the software, but belong to whomever generated them,
|
||||
and may be sold commercially, and may be aggregated with this
|
||||
software.
|
||||
|
||||
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE.
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
本プログラムはフリーソフトウェアです.MITライセンス
|
||||
または以下に示す条件で本プログラムを再配布できます
|
||||
MITライセンスについてはMTILファイル(参考訳:MITL.ja)を
|
||||
参照して下さい.
|
||||
|
||||
1. 複製は制限なく自由です.
|
||||
|
||||
2. 以下の条件のいずれかを満たす時に本プログラムのソースを
|
||||
自由に変更できます.
|
||||
|
||||
(a) ネットニューズにポストしたり,作者に変更を送付する
|
||||
などの方法で,変更を公開する.
|
||||
|
||||
(b) 変更した本プログラムを自分の所属する組織内部だけで
|
||||
使う.
|
||||
|
||||
(c) 変更点を明示したうえ,ソフトウェアの名前を変更する.
|
||||
そのソフトウェアを配布する時には変更前の本プログラ
|
||||
ムも同時に配布する.または変更前の本プログラムのソー
|
||||
スの入手法を明示する.
|
||||
|
||||
(d) その他の変更条件を作者と合意する.
|
||||
|
||||
3. 以下の条件のいずれかを満たす時に本プログラムをコンパイ
|
||||
ルしたオブジェクトコードや実行形式でも配布できます.
|
||||
|
||||
(a) バイナリを受け取った人がソースを入手できるように,
|
||||
ソースの入手法を明示する.
|
||||
|
||||
(b) 機械可読なソースコードを添付する.
|
||||
|
||||
(c) 変更を行ったバイナリは名前を変更したうえ,オリジナ
|
||||
ルのソースコードの入手法を明示する.
|
||||
|
||||
(d) その他の配布条件を作者と合意する.
|
||||
|
||||
4. 他のプログラムへの引用はいかなる目的であれ自由です.た
|
||||
だし,本プログラムに含まれる他の作者によるコードは,そ
|
||||
れぞれの作者の意向による制限が加えられる場合があります.
|
||||
|
||||
それらファイルの一覧とそれぞれの配布条件などに付いては
|
||||
LEGALファイルを参照してください.
|
||||
|
||||
5. 本プログラムへの入力となるスクリプトおよび,本プログラ
|
||||
ムからの出力の権利は本プログラムの作者ではなく,それぞ
|
||||
れの入出力を生成した人に属します.また,本プログラムに
|
||||
組み込まれるための拡張ライブラリについても同様です.
|
||||
|
||||
6. 本プログラムは無保証です.作者は本プログラムをサポート
|
||||
する意志はありますが,プログラム自身のバグあるいは本プ
|
||||
ログラムの実行などから発生するいかなる損害に対しても責
|
||||
任を持ちません.
|
||||
@@ -9,7 +9,7 @@
|
||||
* lib
|
||||
* include
|
||||
|
||||
If an error occurs when compiling mRuby, it will be helpful for others if you
|
||||
If an error occurs when compiling mruby, it will be helpful for others if you
|
||||
send a detailed report to the developers that includes the error log, machine,
|
||||
and OS type.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ LEGAL NOTICE INFORMATION
|
||||
------------------------
|
||||
|
||||
All the files in this distribution are covered under the MIT license
|
||||
(see the file COPYING) except some files mentioned below:
|
||||
(see the file MITL) except some files mentioned below:
|
||||
|
||||
|
||||
(Currently no items are listed.)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
Copyright (c) 2012 mruby developers
|
||||
|
||||
以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウ
|
||||
ェア」)の複製を取得するすべての人に対し、ソフトウェアを無制限に扱うことを無償
|
||||
で許可します。これには、ソフトウェアの複製を使用、複写、変更、結合、掲載、頒布、
|
||||
サブライセンス、および/または販売する権利、およびソフトウェアを提供する相手に
|
||||
同じことを許可する権利も無制限に含まれます。
|
||||
|
||||
上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分
|
||||
に記載するものとします。
|
||||
|
||||
ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証も
|
||||
なく提供されます。ここでいう保証とは、商品性、特定の目的への適合性、および権利
|
||||
非侵害についての保証も含みますが、それに限定されるものではありません。
|
||||
作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェ
|
||||
アに起因または関連し、あるいはソフトウェアの使用またはその他の扱いによって生じ
|
||||
る一切の請求、損害、その他の義務について何らの責任も負わないものとします。
|
||||
@@ -113,8 +113,10 @@ $(OBJM) : $(MSRC)
|
||||
.PHONY : clean
|
||||
clean :
|
||||
$(MAKE) clean -C src $(MAKE_FLAGS)
|
||||
$(MAKE) clean -C tools/mrbc $(MAKE_FLAGS)
|
||||
$(MAKE) clean -C tools/mruby $(MAKE_FLAGS)
|
||||
-rm -f $(EXE) $(OBJM)
|
||||
-rm -f $(OBJM:.o=.d)
|
||||
-rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1))
|
||||
-rm -f $(IOSLIB) $(IOSSIMLIB) $(IOSDEVLIB)
|
||||
@echo "make: removing targets, objects and depend files of `pwd`"
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
!!Notice!! This is a preliminary release for internal team reviewing.
|
||||
The URL and address discribed below are not available yet.
|
||||
The official release will be announced later. Thanks.
|
||||
Any suggestion of the modification are welcome,
|
||||
but the response might be delayed. Sorry for that in advance.
|
||||
|
||||
* What's mRuby
|
||||
|
||||
mRuby is the light-weight implementation of the Ruby language complied to the ISO
|
||||
standard to execute various environments. It can run in 'interpreter form' or
|
||||
'compile and execute on vm form' according to its module construction.
|
||||
|
||||
This achievement is due to the Regional Innovation Creation R&D Programs of
|
||||
the Ministry of Economy, Trade and Industry of Japan.
|
||||
|
||||
|
||||
* Features of mRuby
|
||||
|
||||
|FIXME:
|
||||
| + Simple Syntax
|
||||
| + *Normal* Object-Oriented features(ex. class, method calls)
|
||||
| + *Advanced* Object-Oriented features(ex. Mix-in, Singleton-method)
|
||||
| + Operator Overloading
|
||||
| + Exception Handling
|
||||
| + Iterators and Closures
|
||||
| + Garbage Collection
|
||||
| + Dynamic Loading of Object files(on some architecture)
|
||||
| + Highly Portable (works on many Unix-like/POSIX compatible platforms
|
||||
| as well as Windows, Mac OS X, BeOS etc.)
|
||||
| cf. http://redmine.ruby-lang.org/wiki/ruby-19/SupportedPlatforms
|
||||
|
||||
|
||||
* How to get mRuby
|
||||
|
||||
The mRuby distribution files can be found in the following site:
|
||||
|
||||
https://github.com/mruby/mruby/zipball/master
|
||||
|
||||
The trunk of the mRuby source tree can be checked out with the
|
||||
following command:
|
||||
|
||||
$ git ...
|
||||
|
||||
There are some other branches under development. Try the following
|
||||
command and see the list of branches:
|
||||
|
||||
$ git ...
|
||||
|
||||
|
||||
* mRuby home-page (sorry, it's not launched yet. we're working on this)
|
||||
|
||||
The URL of the mRuby home-page is:
|
||||
|
||||
http://www.mruby.org/
|
||||
|
||||
|
||||
* Mailing list
|
||||
|
||||
There is a mailing list to talk about mRuby.
|
||||
To subscribe this list....
|
||||
|
||||
* How to compile and install
|
||||
|
||||
See the file INSTALL.
|
||||
|
||||
|
||||
* Copying
|
||||
|
||||
See the file COPYING.
|
||||
|
||||
|
||||
* About Contribution
|
||||
|
||||
Thank you for considering of contribution for mRuby.
|
||||
mRuby has chosen a MIT License as comparatively loose condition,
|
||||
to expect to apply into various environment such as embedded system.
|
||||
However, the license requires to display copyright notice and license
|
||||
sentenses, for example manual or so. Especially for the recent bigger
|
||||
system, it is comlecated or very troublesome.
|
||||
So, mRuby has decided to display "mruby developers" as copyright name
|
||||
to make it simple conventionally.
|
||||
In the future, mRuby might ask you to distribute your new codes
|
||||
(that you will commit,) under MIT License as a member of
|
||||
"mruby developers" with keeping copyright of you.
|
||||
(We did not intend you to transfer or waive your copyright,
|
||||
Actual copyright holder name, you, will be listed in AUTHORS file.)
|
||||
|
||||
Please ask us if you want to distribute your code under other license
|
||||
or if your code is derived from GPL code.
|
||||
|
||||
|
||||
* The Author
|
||||
|
||||
See the file AUTHORS.
|
||||
|
||||
|
||||
Feel free to send comments and bug reports to the author. Here is the
|
||||
author's latest mail address:
|
||||
|
||||
devel@mruby.org
|
||||
|
||||
-------------------------------------------------------
|
||||
created at: Fri Apr 20 11:57:36 JST 2012
|
||||
Local variables:
|
||||
mode: indented-text
|
||||
end:
|
||||
@@ -1,109 +0,0 @@
|
||||
※注意 これはチーム内レビューの為の事前公開です。
|
||||
記述されているURLやメールアドレスは現在使用できません。
|
||||
正式リリースは後日アナウンス予定です。
|
||||
|
||||
* mRubyとは
|
||||
|
||||
mRubyはISO規格に準拠したRuby言語を様々な環境で動作可能となるように
|
||||
軽量化したものです。モジュール構成によりインタプリタ実行形式や
|
||||
コンパイル&VM実行形式でも動作させることができます。
|
||||
|
||||
2010年度の経済産業省の地域イノベーション創出事業により開発されました。
|
||||
|
||||
|
||||
* mRubyの特長
|
||||
|
||||
|MRI(Matz Ruby Implementation)版との互換性
|
||||
|
|
||||
|以下要修正
|
||||
| + シンプルな文法
|
||||
| + 普通のオブジェクト指向機能(クラス,メソッドコールなど)
|
||||
| + 特殊なオブジェクト指向機能(Mixin, 特異メソッドなど)
|
||||
| + 演算子オーバーロード
|
||||
| + 例外処理機能
|
||||
| + イテレータとクロージャ
|
||||
| + ガーベージコレクタ
|
||||
| + ダイナミックローディング (アーキテクチャによる)
|
||||
| + 移植性が高い.多くのUnix-like/POSIX互換プラットフォーム上で
|
||||
| 動くだけでなく,Windows, Mac OS X,BeOSなどの上でも動く
|
||||
| cf. http://redmine.ruby-lang.org/wiki/ruby-19/SupportedPlatformsJa
|
||||
|
||||
* 入手法
|
||||
|
||||
** Zipで
|
||||
|
||||
以下の場所においてあります.
|
||||
|
||||
https://github.com/mruby/mruby/zipball/master
|
||||
|
||||
** GitHubで
|
||||
|
||||
開発先端のソースコードは次のコマンドで取得できます.
|
||||
|
||||
$ git …..
|
||||
|
||||
他に開発中のブランチの一覧は次のコマンドで見られます.
|
||||
|
||||
$ git …
|
||||
|
||||
|
||||
* ホームページ (まだ準備中です。ただいま鋭意製作中です。)
|
||||
|
||||
mRubyのホームページのURLは
|
||||
|
||||
http://www.mruby.org/
|
||||
|
||||
です.
|
||||
|
||||
|
||||
* メーリングリスト
|
||||
|
||||
mRubyのメーリングリストがあります。参加希望の方は….
|
||||
|
||||
|
||||
Ruby開発者向けメーリングリストもあります。こちらではrubyのバ
|
||||
グ、将来の仕様拡張など実装上の問題について議論されています。
|
||||
参加希望の方は…
|
||||
|
||||
|
||||
* コンパイル・インストール・移植
|
||||
|
||||
INSTALL.ja ファイルを参照してください。
|
||||
|
||||
|
||||
* 配布条件
|
||||
|
||||
COPYING.ja ファイルを参照してください。
|
||||
|
||||
|
||||
* コントリビュートについて
|
||||
|
||||
mRubyへの貢献の検討をありがとうございます。
|
||||
mRubyは組込み機器などの様々な環境で利用させることを期待し、ライセンスを
|
||||
比較的制限の緩いMITライセンスにすることにいたしました。
|
||||
しかしながら、ライセンスの実行条件としてマニュアル等の何らかの形で
|
||||
著作権表記及びライセンス文を記述する必要があります。
|
||||
昨今の規模の大きくなったシステムではこれらの対応も相当の煩雑さを伴います。
|
||||
そこで、mRubyではできる限り表記を簡便にするために、便宜上、著作権者名を
|
||||
"mruby developers"とすることにいたしました。
|
||||
今後、新たにmRubyへのコミットされるコードについては、著作権を保持したまま、
|
||||
"mruby developers"の一員としてMITライセンスでの配布をお願いしたいと
|
||||
考えています。
|
||||
(コミットしたコードの著作権を譲渡や放棄をお願いするものではありません。
|
||||
実質の著作者名はAUTHORSファイルに表記いたします。)
|
||||
|
||||
尚、その他のライセンスでの配布やGPL由来のコードのコミットについては
|
||||
別途ご相談ください。
|
||||
|
||||
|
||||
* 著者
|
||||
|
||||
AUTHORS ファイルを参照してください。
|
||||
|
||||
|
||||
コメント,バグレポートその他は devel@mruby.org まで.
|
||||
-------------------------------------------------------
|
||||
created at: Fri Apr 20 11:57:36 JST 2012
|
||||
Local variables:
|
||||
mode: indented-text
|
||||
end:
|
||||
+126
@@ -0,0 +1,126 @@
|
||||
# !!ご注意!!
|
||||
これはチーム内レビューの為の事前公開です。
|
||||
記述されているURLやメールアドレスは現在使用できません。
|
||||
正式リリースは後日アナウンス予定です。
|
||||
|
||||
修正のご指摘は随時受け付けていますが、対応が遅れる可能性があります。
|
||||
予めご了承ください。
|
||||
|
||||
## mrubyとは
|
||||
|
||||
mrubyは[ISO規格](http://www.ipa.go.jp/about/press/20120402_2.html)に準拠したRuby言語を様々な環境で動作可能となるように
|
||||
軽量化したものです。モジュール構成によりインタプリタ実行形式や
|
||||
コンパイル&VM実行形式でも動作させることができます。
|
||||
|
||||
2010年度の経済産業省の地域イノベーション創出事業により開発されました。
|
||||
|
||||
|
||||
## mrubyの特長
|
||||
|
||||
|MRI(Matz Ruby Implementation)版との互換性
|
||||
|
|
||||
|以下要修正
|
||||
| + シンプルな文法
|
||||
| + 普通のオブジェクト指向機能(クラス,メソッドコールなど)
|
||||
| + 特殊なオブジェクト指向機能(Mixin, 特異メソッドなど)
|
||||
| + 演算子オーバーロード
|
||||
| + 例外処理機能
|
||||
| + イテレータとクロージャ
|
||||
| + ガーベージコレクタ
|
||||
| + ダイナミックローディング (アーキテクチャによる)
|
||||
| + 移植性が高い.多くのUnix-like/POSIX互換プラットフォーム上で
|
||||
| 動くだけでなく,Windows, Mac OS X,BeOSなどの上でも動く
|
||||
| cf. http://redmine.ruby-lang.org/wiki/ruby-19/SupportedPlatformsJa
|
||||
|
||||
|
||||
## 入手法
|
||||
|
||||
### Zipで
|
||||
|
||||
以下の場所においてあります。
|
||||
|
||||
https://github.com/mruby/mruby/zipball/master
|
||||
|
||||
### GitHubで
|
||||
|
||||
開発先端のソースコードは次のコマンドで取得できます。
|
||||
|
||||
$ git clone https://github.com/mruby/mruby.git
|
||||
|
||||
他に開発中のブランチの一覧は次のコマンドで見られます。
|
||||
|
||||
$ git branch -r
|
||||
|
||||
|
||||
## ホームページ
|
||||
|
||||
まだ準備中です。ただいま鋭意製作中です。
|
||||
|
||||
mrubyのホームページのURLは
|
||||
|
||||
http://www.mruby.org/
|
||||
|
||||
になる予定です。
|
||||
|
||||
|
||||
## メーリングリスト
|
||||
|
||||
mrubyのメーリングリストがあります。参加希望の方は....[T.B.D.]
|
||||
|
||||
|
||||
mruby開発者向けメーリングリストもあります。こちらではrubyのバグ、
|
||||
将来の仕様拡張など実装上の問題について議論されています。
|
||||
参加希望の方は....[T.B.D.]
|
||||
|
||||
|
||||
## コンパイル・インストール・移植
|
||||
|
||||
INSTALL.ja ファイルを参照してください。
|
||||
|
||||
|
||||
## 配布条件
|
||||
|
||||
Copyright (c) 2012 mruby developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## ライセンスについて
|
||||
|
||||
mrubyは組込み機器などの様々な環境で利用させることを期待し、ライセンスを
|
||||
比較的制限の緩いMITライセンスにすることにいたしました。
|
||||
しかしながら、ライセンスの実行条件としてマニュアル等の何らかの形で
|
||||
著作権表記及びライセンス文を記述する必要があります。
|
||||
昨今の規模の大きくなったシステムではこれらの対応も相当の煩雑さを伴います。
|
||||
そこで、mrubyではできる限り表記を簡便にするために、便宜上、著作権者名を
|
||||
"mruby developers"とすることにいたしました。
|
||||
今後、新たにmrubyへのコミットされるコードについては、著作権を保持したまま、
|
||||
"mruby developers"の一員としてMITライセンスでの配布をお願いしたいと
|
||||
考えています。
|
||||
(コミットしたコードの著作権を譲渡や放棄をお願いするものではありません。
|
||||
希望があれば、著作者名はAUTHORSファイルに表記いたします。)
|
||||
|
||||
尚、その他のライセンスでの配布やGPL由来のコードのコミットについては
|
||||
別途ご相談ください。
|
||||
|
||||
## コントリビュートについて
|
||||
|
||||
<http://github.com/mruby/mruby>にpull requestを送ってください。
|
||||
pull requestに含まれるコードについてMITライセンスでの配布を承諾したものとみなします。
|
||||
もし、mruby developersとして名前を残したいということであれば、
|
||||
pull requestにAUTHORSファイルへの修正を含めてください。
|
||||
@@ -0,0 +1,115 @@
|
||||
# !!Notice!!
|
||||
This is a preliminary release for internal team review.
|
||||
The URLs and addresses described below are not available yet.
|
||||
The official release will be announced later.
|
||||
Any suggestion for modification is welcome.
|
||||
Delays in replies are to be expected. Sorry in advance.
|
||||
|
||||
## What's mruby
|
||||
|
||||
mruby is the lightweight implementation of the Ruby language complying to
|
||||
the [ISO standard](http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579).
|
||||
mruby can run Ruby code in 'interpreter mode' or 'compile and execute it on a virtual machine' depending on the developer's preference.
|
||||
|
||||
This achievement was sponsored by the Regional Innovation Creation R&D Programs of
|
||||
the Ministry of Economy, Trade and Industry of Japan.
|
||||
|
||||
|
||||
## Features of mruby
|
||||
|
||||
| Compatibility with MRI(Matz Ruby Implementation) version...
|
||||
|
|
||||
|FIXME:
|
||||
| + Simple Syntax
|
||||
| + *Normal* Object-Oriented features(ex. class, method calls)
|
||||
| + *Advanced* Object-Oriented features(ex. Mixin, Singleton-method)
|
||||
| + Operator Overloading
|
||||
| + Exception Handling
|
||||
| + Iterators and Closures
|
||||
| + Garbage Collection
|
||||
| + Dynamic Loading of Object files(on some architecture)
|
||||
| + Highly Portable (works on many Unix-like/POSIX compatible platforms
|
||||
| as well as Windows, Mac OS X, BeOS etc.)
|
||||
| cf. http://redmine.ruby-lang.org/wiki/ruby-19/SupportedPlatforms
|
||||
|
||||
|
||||
## How to get mruby
|
||||
|
||||
The mruby distribution files can be found in the following site:
|
||||
|
||||
https://github.com/mruby/mruby/zipball/master
|
||||
|
||||
The trunk of the mruby source tree can be checked out with the
|
||||
following command:
|
||||
|
||||
$ git clone https://github.com/mruby/mruby.git
|
||||
|
||||
There are some other branches under development. Try the following
|
||||
command and see the list of branches:
|
||||
|
||||
$ git branch -r
|
||||
|
||||
|
||||
## mruby home-page
|
||||
|
||||
mruby's website is not launched yet but we are actively working on it.
|
||||
|
||||
The URL of the mruby home-page will be:
|
||||
|
||||
http://www.mruby.org/
|
||||
|
||||
|
||||
## Mailing list
|
||||
|
||||
To subscribe to the mruby mailing list....[T.B.D.]
|
||||
|
||||
|
||||
## How to compile and install
|
||||
|
||||
See the INSTALL file.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2012 mruby developers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## Note for License
|
||||
|
||||
mruby has chosen a MIT License due to its permissive license allowing
|
||||
developers to target various environments such as embedded systems.
|
||||
However, the license requires the display of the copyright notice and license
|
||||
information in manuals for instance. Doing so for big projects can be
|
||||
complicated or troublesome.
|
||||
This is why mruby has decided to display "mruby developers" as the copyright name
|
||||
to make it simple conventionally.
|
||||
In the future, mruby might ask you to distribute your new code
|
||||
(that you will commit,) under the MIT License as a member of
|
||||
"mruby developers" but contributors will keep their copyright.
|
||||
(We did not intend for contributors to transfer or waive their copyrights,
|
||||
Actual copyright holder name (contributors) will be listed in the AUTHORS file.)
|
||||
|
||||
Please ask us if you want to distribute your code under another license.
|
||||
|
||||
## How to Contribute
|
||||
|
||||
Send pull request to <http://github.com/mruby/mruby>. We consider you have granted
|
||||
non-exclusive right to your contributed code under MIT license. If you want to be named
|
||||
as one of mruby developers, include update to the AUTHORS file in your pull request.
|
||||
@@ -1,14 +0,0 @@
|
||||
やること(まだできてないこと)
|
||||
|
||||
* ヒアドキュメント
|
||||
* 特殊変数 ($1,$2..)
|
||||
* super in aliased methods
|
||||
* BEGIN/END (対応しないんだっけ?)
|
||||
* const_missing
|
||||
* respond_to_missing
|
||||
|
||||
改善すること(できているが直すこと)
|
||||
|
||||
* Hash (サイズを減らす。khashを使うか、順序を保存するか)
|
||||
* stringEx (encoding削除、CODERANGE削除、UTF-8 or ASCII以外削除)
|
||||
* 気づいたら書き加える
|
||||
@@ -22,15 +22,6 @@ typedef intptr_t mrb_sym;
|
||||
#undef HAVE_UNISTD_H /* WINDOWS */
|
||||
#define HAVE_UNISTD_H /* LINUX */
|
||||
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF___INT64 0
|
||||
#define SIZEOF_VOIDP 4
|
||||
#define SIZEOF_FLOAT 4
|
||||
#define SIZEOF_DOUBLE 8
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
+35
-57
@@ -1,3 +1,29 @@
|
||||
/*
|
||||
** mruby - An embeddable Ruby implementaion
|
||||
**
|
||||
** Copyright (c) mruby developers 2010-2012
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
** [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
|
||||
*/
|
||||
#ifndef MRUBY_H
|
||||
#define MRUBY_H
|
||||
|
||||
@@ -49,7 +75,7 @@ typedef struct mrb_value {
|
||||
#define mrb_test(o) ((o).tt != MRB_TT_FALSE)
|
||||
#define mrb_fixnum(o) (o).value.i
|
||||
#define mrb_float(o) (o).value.f
|
||||
#define mrb_symbol(o) (o).value.sym
|
||||
#define mrb_symbol(o) (o).value.sym
|
||||
#define mrb_object(o) (o).value.p
|
||||
#define FIXNUM_P(o) ((o).tt == MRB_TT_FIXNUM)
|
||||
#define UNDEF_P(o) ((o).tt == MRB_TT_UNDEF)
|
||||
@@ -108,7 +134,7 @@ static inline mrb_value
|
||||
mrb_obj_value(void *p)
|
||||
{
|
||||
mrb_value v;
|
||||
struct RBasic *b = p;
|
||||
struct RBasic *b = (struct RBasic*) p;
|
||||
|
||||
v.tt = b->tt;
|
||||
v.value.p = p;
|
||||
@@ -362,6 +388,10 @@ void mrb_write_barrier(mrb_state *, struct RBasic*);
|
||||
|
||||
#define MRUBY_VERSION "Rite"
|
||||
|
||||
#ifdef DEBUG
|
||||
#undef DEBUG
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define DEBUG(x) x
|
||||
#else
|
||||
@@ -441,11 +471,14 @@ void mrb_bug(const char *fmt, ...);
|
||||
#ifdef __GNUC__
|
||||
# define NUM2CHR(x) __extension__ ({mrb_value num2chr_x = (x); NUM2CHR_internal(num2chr_x);})
|
||||
#else
|
||||
/* TODO: there is no definitions of RSTRING_* here, so cannot compile.
|
||||
static inline char
|
||||
NUM2CHR(mrb_value x)
|
||||
{
|
||||
return NUM2CHR_internal(x);
|
||||
}
|
||||
*/
|
||||
#define NUM2CHR(x) NUM2CHR_internal(x)
|
||||
#endif
|
||||
mrb_value mrb_io_gets(mrb_state *mrb, mrb_value);
|
||||
mrb_value mrb_io_getbyte(mrb_state *mrb, mrb_value);
|
||||
@@ -531,60 +564,6 @@ void mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t);
|
||||
#define ruby_setjmp(env) RUBY_SETJMP(env)
|
||||
#define ruby_longjmp(env,val) RUBY_LONGJMP(env,val)
|
||||
|
||||
#if defined PRIdPTR && !defined PRI_VALUE_PREFIX
|
||||
#define PRIdVALUE PRIdPTR
|
||||
#define PRIiVALUE PRIiPTR
|
||||
#define PRIoVALUE PRIoPTR
|
||||
#define PRIuVALUE PRIuPTR
|
||||
#define PRIxVALUE PRIxPTR
|
||||
#define PRIXVALUE PRIXPTR
|
||||
#else
|
||||
#define PRIdVALUE PRI_VALUE_PREFIX"d"
|
||||
#define PRIiVALUE PRI_VALUE_PREFIX"i"
|
||||
#define PRIoVALUE PRI_VALUE_PREFIX"o"
|
||||
#define PRIuVALUE PRI_VALUE_PREFIX"u"
|
||||
#define PRIxVALUE PRI_VALUE_PREFIX"x"
|
||||
#define PRIXVALUE PRI_VALUE_PREFIX"X"
|
||||
#endif
|
||||
#ifndef PRI_VALUE_PREFIX
|
||||
# define PRI_VALUE_PREFIX ""
|
||||
#endif
|
||||
|
||||
#if defined PRIdPTR
|
||||
# define PRI_PTRDIFF_PREFIX "t"
|
||||
#elif SIZEOF_PTRDIFF_T == SIZEOF_INT
|
||||
# define PRI_PTRDIFF_PREFIX
|
||||
#elif SIZEOF_PTRDIFF_T == SIZEOF_LONG
|
||||
# define PRI_PTRDIFF_PREFIX "l"
|
||||
#elif SIZEOF_PTRDIFF_T == SIZEOF_LONG_LONG
|
||||
# define PRI_PTRDIFF_PREFIX "ll"
|
||||
#else
|
||||
# define PRI_PTRDIFF_PREFIX
|
||||
#endif
|
||||
#define PRIdPTRDIFF PRI_PTRDIFF_PREFIX"d"
|
||||
#define PRIiPTRDIFF PRI_PTRDIFF_PREFIX"i"
|
||||
#define PRIoPTRDIFF PRI_PTRDIFF_PREFIX"o"
|
||||
#define PRIuPTRDIFF PRI_PTRDIFF_PREFIX"u"
|
||||
#define PRIxPTRDIFF PRI_PTRDIFF_PREFIX"x"
|
||||
#define PRIXPTRDIFF PRI_PTRDIFF_PREFIX"X"
|
||||
|
||||
#if defined PRIdPTR
|
||||
# define PRI_SIZE_PREFIX "z"
|
||||
#elif SIZEOF_SIZE_T == SIZEOF_INT
|
||||
# define PRI_SIZE_PREFIX
|
||||
#elif SIZEOF_SIZE_T == SIZEOF_LONG
|
||||
# define PRI_SIZE_PREFIX "l"
|
||||
#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
|
||||
# define PRI_SIZE_PREFIX "ll"
|
||||
#endif
|
||||
#define PRIdSIZE PRI_SIZE_PREFIX"d"
|
||||
#define PRIiSIZE PRI_SIZE_PREFIX"i"
|
||||
#define PRIoSIZE PRI_SIZE_PREFIX"o"
|
||||
#define PRIuSIZE PRI_SIZE_PREFIX"u"
|
||||
#define PRIxSIZE PRI_SIZE_PREFIX"x"
|
||||
#define PRIXSIZE PRI_SIZE_PREFIX"X"
|
||||
#define PRIdPTRDIFF PRI_PTRDIFF_PREFIX"d"
|
||||
|
||||
#define KHASH 0
|
||||
#define STHASH 1
|
||||
#define BASICHASH 2
|
||||
@@ -610,7 +589,6 @@ int mrb_cmpint(mrb_state *mrb, mrb_value val, mrb_value a, mrb_value b);
|
||||
# define ANYARGS
|
||||
# endif
|
||||
#endif
|
||||
void st_foreach_safe(mrb_state *mrb, void *table, int (*func)(ANYARGS), void * a);
|
||||
void mrb_define_alias(mrb_state *mrb, struct RClass *klass, const char *name1, const char *name2);
|
||||
const char *mrb_class_name(mrb_state *mrb, struct RClass* klass);
|
||||
void mrb_define_global_const(mrb_state *mrb, const char *name, mrb_value val);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**********************************************************************
|
||||
|
||||
mdata.h -
|
||||
data.h -
|
||||
|
||||
|
||||
Copyright (C) 2007 Yukihiro Matsumoto
|
||||
@@ -6,7 +6,7 @@
|
||||
int color:3;\
|
||||
unsigned int flags:21;\
|
||||
struct RClass *c;\
|
||||
struct RBasic *gcnext;
|
||||
struct RBasic *gcnext
|
||||
|
||||
|
||||
/* white: 011, black: 100, gray: 000 */
|
||||
|
||||
@@ -59,5 +59,6 @@ $(RLIB) : $(MRBS)
|
||||
.PHONY : clean
|
||||
clean :
|
||||
-rm -f $(MRBC) $(MLIB) $(CLIB) $(RLIB) $(DLIB)
|
||||
-rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1))
|
||||
@echo "make: removing targets, objects and depend files of `pwd`"
|
||||
|
||||
|
||||
+2
-1
@@ -40,7 +40,7 @@ YACC = bison
|
||||
|
||||
DEBUG_MODE = 1
|
||||
ifeq ($(DEBUG_MODE),1)
|
||||
CFLAGS = -g
|
||||
CFLAGS = -g -O3
|
||||
else
|
||||
CFLAGS = -O3
|
||||
endif
|
||||
@@ -86,5 +86,6 @@ clean :
|
||||
$(MAKE) clean -C ../mrblib $(MAKE_FLAGS)
|
||||
-rm -f $(LIB) $(OBJS) $(OBJY) $(YC)
|
||||
-rm -f $(OBJS:.o=.d) $(OBJY:.o=.d)
|
||||
-rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1))
|
||||
@echo "make: removing targets, objects and depend files of `pwd`"
|
||||
|
||||
|
||||
+7
-6
@@ -2,7 +2,6 @@
|
||||
#include "mruby/array.h"
|
||||
#include <string.h>
|
||||
#include "mruby/string.h"
|
||||
#include "mdata.h"
|
||||
#include "mruby/class.h"
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
@@ -35,10 +34,8 @@ mrb_value
|
||||
mrb_ary_new_capa(mrb_state *mrb, size_t capa)
|
||||
{
|
||||
struct RArray *a;
|
||||
size_t blen;
|
||||
|
||||
if (capa < 0) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "negative ary size (or size too big)");
|
||||
}
|
||||
#ifdef LONG_MAX
|
||||
if (capa > ARY_MAX_SIZE) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "ary size too big");
|
||||
@@ -47,10 +44,14 @@ mrb_ary_new_capa(mrb_state *mrb, size_t capa)
|
||||
if (capa < ARY_DEFAULT_LEN) {
|
||||
capa = ARY_DEFAULT_LEN;
|
||||
}
|
||||
blen = capa * sizeof(mrb_value) ;
|
||||
if (blen < capa) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "ary size too big");
|
||||
}
|
||||
|
||||
a = mrb_obj_alloc(mrb, MRB_TT_ARRAY, mrb->array_class);
|
||||
a->buf = mrb_malloc(mrb, sizeof(mrb_value) * capa);
|
||||
memset(a->buf, 0, sizeof(mrb_value) * capa);
|
||||
a->buf = mrb_malloc(mrb, blen);
|
||||
memset(a->buf, 0, blen);
|
||||
a->capa = capa;
|
||||
a->len = 0;
|
||||
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ make_cdump_irep(mrb_state *mrb, int irep_no, FILE *f)
|
||||
}
|
||||
}
|
||||
memset(buf, 0, buf_len);
|
||||
SOURCE_CODE(" irep->pool[%d] = mrb_str_new(mrb, \"%s\", %d);", n, str_to_format(irep->pool[n], buf), RSTRING_LEN(irep->pool[n])); break;
|
||||
SOURCE_CODE(" irep->pool[%d] = mrb_str_new(mrb, \"%s\", %zd);", n, str_to_format(irep->pool[n], buf), RSTRING_LEN(irep->pool[n])); break;
|
||||
/* TODO MRB_TT_REGEX */
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,12 @@ enum mrb_lex_state_enum {
|
||||
EXPR_MAX_STATE
|
||||
};
|
||||
|
||||
struct mrb_parser_message {
|
||||
int lineno;
|
||||
int column;
|
||||
char* message;
|
||||
};
|
||||
|
||||
struct mrb_parser_state {
|
||||
mrb_state *mrb;
|
||||
struct mrb_pool *pool;
|
||||
@@ -55,14 +61,20 @@ struct mrb_parser_state {
|
||||
void *ylval;
|
||||
|
||||
int nerr;
|
||||
int nwarn;
|
||||
mrb_ast_node *tree, *begin_tree;
|
||||
|
||||
int capture_errors;
|
||||
struct mrb_parser_message error_buffer[10];
|
||||
struct mrb_parser_message warn_buffer[10];
|
||||
|
||||
jmp_buf jmp;
|
||||
};
|
||||
|
||||
struct mrb_parser_state* mrb_parse_file(mrb_state*,FILE*);
|
||||
struct mrb_parser_state* mrb_parse_string(mrb_state*,char*);
|
||||
struct mrb_parser_state* mrb_parse_nstring(mrb_state*,char*,size_t);
|
||||
struct mrb_parser_state* mrb_parse_nstring_ext(mrb_state*,char*,size_t);
|
||||
int mrb_generate_code(mrb_state*, mrb_ast_node*);
|
||||
|
||||
int mrb_compile_file(mrb_state*,FILE*);
|
||||
|
||||
@@ -922,6 +922,31 @@ enc_name(mrb_state *mrb, mrb_value self)
|
||||
return mrb_usascii_str_new2(mrb, mrb_enc_name((mrb_encoding*)DATA_PTR(self)));
|
||||
}
|
||||
|
||||
struct fn_arg {
|
||||
mrb_state *mrb;
|
||||
int (*func)(ANYARGS);
|
||||
void *a;
|
||||
};
|
||||
|
||||
static int
|
||||
fn_i(st_data_t key, st_data_t val, st_data_t arg) {
|
||||
struct fn_arg *a = (struct fn_arg*)arg;
|
||||
|
||||
return (*a->func)(a->mrb, key, val, a->a);
|
||||
}
|
||||
|
||||
static int
|
||||
st_foreachNew(mrb_state *mrb, st_table *tbl, int (*func)(ANYARGS), void *a)
|
||||
{
|
||||
struct fn_arg arg = {
|
||||
mrb,
|
||||
func,
|
||||
a,
|
||||
};
|
||||
|
||||
return st_foreach(tbl, fn_i, (st_data_t)&arg);
|
||||
}
|
||||
|
||||
static int
|
||||
enc_names_i(mrb_state *mrb, st_data_t name, st_data_t idx, st_data_t args)
|
||||
{
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ extern "C" {
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "oniguruma.h"
|
||||
#include "mdata.h"
|
||||
#include "mruby/data.h"
|
||||
|
||||
int mrb_tolower(int c);
|
||||
int mrb_toupper(int c);
|
||||
|
||||
+1
-1
@@ -199,8 +199,8 @@ mrb_raise(mrb_state *mrb, struct RClass *c, const char *fmt, ...)
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, 256, fmt, args);
|
||||
mrb_raise_va(mrb, c, fmt, args);
|
||||
va_end(args);
|
||||
mrb_exc_raise(mrb, mrb_exc_new(mrb, c, buf, strlen(buf)));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "mruby.h"
|
||||
#include "mdata.h"
|
||||
#include "mruby/string.h"
|
||||
#include "error.h"
|
||||
#include "mruby/numeric.h"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <stdio.h>
|
||||
#include "mruby/struct.h"
|
||||
#include "mruby/proc.h"
|
||||
#include "mdata.h"
|
||||
#include "mruby/data.h"
|
||||
#include "mruby/numeric.h"
|
||||
|
||||
/*
|
||||
@@ -401,8 +401,8 @@ obj_free(mrb_state *mrb, struct RBasic *obj)
|
||||
struct REnv *e = (struct REnv *)obj;
|
||||
|
||||
if (e->cioff < 0) {
|
||||
mrb_free(mrb, mrb->stack);
|
||||
mrb->stack = 0;
|
||||
mrb_free(mrb, e->stack);
|
||||
e->stack = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ typedef struct mrb_irep {
|
||||
|
||||
mrb_code *iseq;
|
||||
mrb_value *pool;
|
||||
int *syms;
|
||||
mrb_sym *syms;
|
||||
|
||||
int ilen, plen, slen;
|
||||
} mrb_irep;
|
||||
|
||||
+27
-112
@@ -14,7 +14,6 @@
|
||||
#include "ritehash.h"
|
||||
#include "error.h"
|
||||
#include "method.h"
|
||||
#include "mdata.h"
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#include "re.h"
|
||||
@@ -32,85 +31,12 @@ KHASH_MAP_INIT_INT(iv, mrb_value);
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
static mrb_value tst_setconst(mrb_state *mrb, mrb_value obj);
|
||||
int kiv_lookup(khash_t(iv) *table, mrb_sym key, mrb_value *value);
|
||||
|
||||
struct obj_ivar_tag {
|
||||
mrb_value obj;
|
||||
int (*func)(mrb_sym key, mrb_value val, void * arg);
|
||||
void * arg;
|
||||
};
|
||||
|
||||
static int
|
||||
obj_ivar_i(mrb_sym key, int index, struct obj_ivar_tag *arg)
|
||||
{
|
||||
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
|
||||
struct obj_ivar_tag *data = (struct obj_ivar_tag *)arg;
|
||||
if ((long)index < ROBJECT_NUMIV(data->obj)) {
|
||||
mrb_value val = ROBJECT_IVPTR(data->obj)->vals[(long)index];
|
||||
if (val.tt != MRB_TT_FREE) {
|
||||
return (data->func)((mrb_sym)key, val, data->arg);
|
||||
}
|
||||
}
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
void
|
||||
mrb_ivar_foreach(mrb_state *mrb, mrb_value obj, int (*func)(ANYARGS), void* arg)
|
||||
{
|
||||
struct obj_ivar_tag data;
|
||||
switch (mrb_type(obj)) {
|
||||
case MRB_TT_OBJECT:
|
||||
//obj_ivar_each(mrb, obj, func, arg);
|
||||
if (RCLASS_IV_TBL(obj)) {
|
||||
data.obj = obj;
|
||||
data.func = (int (*)(mrb_sym key, mrb_value val, void * arg))func;
|
||||
data.arg = arg;
|
||||
st_foreach_safe(mrb, RCLASS_IV_TBL(obj), obj_ivar_i, (void *)&data);
|
||||
}
|
||||
break;
|
||||
case MRB_TT_CLASS:
|
||||
case MRB_TT_MODULE:
|
||||
if (RCLASS_IV_TBL(obj)) {
|
||||
st_foreach_safe(mrb, RCLASS_IV_TBL(obj), func, arg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!ROBJECT_IVPTR(obj)/*generic_iv_tbl*/) break;
|
||||
if (/*FL_TEST(obj, FL_EXIVAR) ||*/ mrb_special_const_p(obj)) {
|
||||
mrb_value *tbl=0;
|
||||
if (kiv_lookup(ROBJECT_IVPTR(obj)/*generic_iv_tbl*/, SYM2ID(obj), tbl)) {
|
||||
st_foreach_safe(mrb, (void *)tbl, func, arg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
inspect_i(mrb_state *mrb, mrb_sym id, mrb_value value, mrb_value str)
|
||||
{
|
||||
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
|
||||
mrb_value str2;
|
||||
const char *ivname;
|
||||
/* need not to show internal data */
|
||||
if (RSTRING_PTR(str)[0] == '-') { /* first element */
|
||||
RSTRING_PTR(str)[0] = '#';
|
||||
mrb_str_cat2(mrb, str, " ");
|
||||
}
|
||||
else {
|
||||
mrb_str_cat2(mrb, str, ", ");
|
||||
}
|
||||
ivname = mrb_sym2name(mrb, id);
|
||||
mrb_str_cat2(mrb, str, ivname);
|
||||
mrb_str_cat2(mrb, str, "=");
|
||||
str2 = mrb_inspect(mrb, value);
|
||||
mrb_str_append(mrb, str, str2);
|
||||
//OBJ_INFECT(str, str2);
|
||||
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
inspect_obj(mrb_state *mrb, mrb_value obj, mrb_value str, int recur)
|
||||
{
|
||||
@@ -118,11 +44,32 @@ inspect_obj(mrb_state *mrb, mrb_value obj, mrb_value str, int recur)
|
||||
mrb_str_cat2(mrb, str, " ...");
|
||||
}
|
||||
else {
|
||||
mrb_ivar_foreach(mrb, obj, inspect_i, &str);
|
||||
khiter_t k;
|
||||
kh_iv_t *h = RCLASS_IV_TBL(obj);
|
||||
|
||||
if (h) {
|
||||
for (k = kh_begin(h); k != kh_end(h); k++) {
|
||||
if (kh_exist(h, k)){
|
||||
mrb_sym id = kh_key(h, k);
|
||||
mrb_value value = kh_value(h, k);
|
||||
|
||||
/* need not to show internal data */
|
||||
if (RSTRING_PTR(str)[0] == '-') { /* first element */
|
||||
RSTRING_PTR(str)[0] = '#';
|
||||
mrb_str_cat2(mrb, str, " ");
|
||||
}
|
||||
else {
|
||||
mrb_str_cat2(mrb, str, ", ");
|
||||
}
|
||||
mrb_str_cat2(mrb, str, mrb_sym2name(mrb, id));
|
||||
mrb_str_cat2(mrb, str, "=");
|
||||
mrb_str_append(mrb, str, mrb_inspect(mrb, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mrb_str_cat2(mrb, str, ">");
|
||||
RSTRING_PTR(str)[0] = '#';
|
||||
//OBJ_INFECT(str, obj);
|
||||
|
||||
return str;
|
||||
}
|
||||
@@ -157,19 +104,9 @@ mrb_value
|
||||
mrb_obj_inspect(mrb_state *mrb, mrb_value obj)
|
||||
{
|
||||
if ((mrb_type(obj) == MRB_TT_OBJECT) && mrb_obj_basic_to_s_p(mrb, obj)) {
|
||||
int has_ivar = 0;
|
||||
mrb_value *ptr = (mrb_value *)ROBJECT_IVPTR(obj);
|
||||
long len = ROBJECT_NUMIV(obj);
|
||||
long i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (ptr[i].tt != MRB_TT_FREE) {
|
||||
has_ivar = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_ivar) {
|
||||
if (len > 0) {
|
||||
mrb_value str;
|
||||
const char *c = mrb_obj_classname(mrb, obj);
|
||||
|
||||
@@ -424,7 +361,6 @@ mrb_singleton_class_clone(mrb_state *mrb, mrb_value obj)
|
||||
|
||||
clone->super = klass->super;
|
||||
if (klass->iv) {
|
||||
//clone->iv = st_copy(klass->iv);
|
||||
clone->iv = klass->iv;
|
||||
}
|
||||
clone->mt = kh_init(mt, mrb);
|
||||
@@ -450,11 +386,9 @@ init_copy(mrb_state *mrb, mrb_value dest, mrb_value obj)
|
||||
case MRB_TT_CLASS:
|
||||
case MRB_TT_MODULE:
|
||||
if (ROBJECT(dest)->iv) {
|
||||
//st_free_table(ROBJECT(dest)->iv);
|
||||
ROBJECT(dest)->iv = 0;
|
||||
}
|
||||
if (ROBJECT(obj)->iv) {
|
||||
//ROBJECT(dest)->iv = st_copy((st_table *)ROBJECT(obj)->iv);
|
||||
ROBJECT(dest)->iv = ROBJECT(obj)->iv;
|
||||
}
|
||||
}
|
||||
@@ -995,7 +929,6 @@ class_instance_method_list(mrb_state *mrb, int argc, mrb_value *argv, struct RCl
|
||||
{
|
||||
mrb_value ary;
|
||||
int recur;
|
||||
//st_table *list;
|
||||
struct RClass* oldklass;
|
||||
|
||||
if (argc == 0) {
|
||||
@@ -1007,25 +940,19 @@ class_instance_method_list(mrb_state *mrb, int argc, mrb_value *argv, struct RCl
|
||||
recur = mrb_test(r);
|
||||
}
|
||||
|
||||
//list = st_init_numtable();
|
||||
ary = mrb_ary_new(mrb);
|
||||
//for (; mod; mod = RCLASS_SUPER(mod)) {
|
||||
oldklass = 0;
|
||||
while (klass && (klass != oldklass)) {
|
||||
//st_foreach(RCLASS_M_TBL(mod), method_entry, (st_data_t)list);
|
||||
method_entry_loop(mrb, klass, ary);
|
||||
if ((klass->tt == MRB_TT_ICLASS) ||
|
||||
(klass->tt == MRB_TT_SCLASS)) {
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
if (!recur) break;
|
||||
}
|
||||
oldklass = klass;
|
||||
klass = klass->super;
|
||||
}
|
||||
//st_foreach(list, func, ary);
|
||||
//st_free_table(list);
|
||||
|
||||
return ary;
|
||||
}
|
||||
@@ -1034,7 +961,6 @@ mrb_value
|
||||
mrb_obj_singleton_methods(mrb_state *mrb, int argc, mrb_value *argv, mrb_value obj)
|
||||
{
|
||||
mrb_value recur, ary;
|
||||
//st_table *list;
|
||||
struct RClass* klass;
|
||||
|
||||
if (argc == 0) {
|
||||
@@ -1045,22 +971,17 @@ mrb_obj_singleton_methods(mrb_state *mrb, int argc, mrb_value *argv, mrb_value o
|
||||
recur = argv[0];
|
||||
}
|
||||
klass = mrb_class(mrb, obj);
|
||||
//list = st_init_numtable();
|
||||
ary = mrb_ary_new(mrb);
|
||||
if (klass && (klass->tt == MRB_TT_SCLASS)) {
|
||||
//st_foreach(RCLASS_M_TBL(klass), method_entry, (st_data_t)list);
|
||||
method_entry_loop(mrb, klass, ary);
|
||||
klass = klass->super;
|
||||
}
|
||||
if (RTEST(recur)) {
|
||||
while (klass && ((klass->tt == MRB_TT_SCLASS) || (klass->tt == MRB_TT_ICLASS))) {
|
||||
//st_foreach(RCLASS_M_TBL(klass), method_entry, (st_data_t)list);
|
||||
method_entry_loop(mrb, klass, ary);
|
||||
klass = klass->super;
|
||||
}
|
||||
}
|
||||
//st_foreach(list, ins_methods_i, ary);
|
||||
//st_free_table(list);
|
||||
|
||||
return ary;
|
||||
}
|
||||
@@ -1327,14 +1248,8 @@ mrb_obj_remove_instance_variable(mrb_state *mrb, mrb_value self)
|
||||
}
|
||||
}
|
||||
break;
|
||||
//default:
|
||||
// if (mrb_special_const_p(obj)) {
|
||||
// v = val;
|
||||
// if (generic_ivar_remove(obj, (st_data_t)id, &v)) {
|
||||
// return (VALUE)v;
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mrb_name_error(mrb, sym, "instance variable %s not defined", mrb_sym2name(mrb, sym));
|
||||
return mrb_nil_value(); /* not reached */
|
||||
|
||||
+1
-1
@@ -444,7 +444,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
|
||||
irep->slen = bin_to_uint32(src); //syms length
|
||||
src += MRB_DUMP_SIZE_OF_LONG;
|
||||
if (irep->slen > 0) {
|
||||
if ((irep->syms = mrb_malloc(mrb, MRB_DUMP_SIZE_OF_INT * irep->slen)) == NULL) {
|
||||
if ((irep->syms = mrb_malloc(mrb, sizeof(mrb_sym) * irep->slen)) == NULL) {
|
||||
ret = MRB_DUMP_INVALID_IREP;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
+7
-166
@@ -88,34 +88,9 @@
|
||||
|
||||
#define mrb_rational_raw1(x) mrb_rational_raw(x, INT2FIX(1))
|
||||
|
||||
#if SIZEOF_LONG_LONG > 0
|
||||
# define LONG_LONG long long
|
||||
#elif SIZEOF___INT64 > 0
|
||||
# define HAVE_LONG_LONG 1
|
||||
# define LONG_LONG __int64
|
||||
# undef SIZEOF_LONG_LONG
|
||||
# define SIZEOF_LONG_LONG SIZEOF___INT64
|
||||
#endif
|
||||
|
||||
#if defined HAVE_UINTPTR_T && 0
|
||||
typedef uintptr_t VALUE;
|
||||
typedef uintptr_t ID;
|
||||
# define SIGNED_VALUE intptr_t
|
||||
# define SIZEOF_VALUE SIZEOF_UINTPTR_T
|
||||
#elif SIZEOF_LONG == SIZEOF_VOIDP
|
||||
//typedef unsigned long VALUE;
|
||||
//typedef unsigned long ID;
|
||||
# define SIGNED_VALUE long long
|
||||
# define SIZEOF_VALUE SIZEOF_LONG
|
||||
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
|
||||
typedef unsigned LONG_LONG VALUE;
|
||||
typedef unsigned LONG_LONG ID;
|
||||
# define SIGNED_VALUE LONG_LONG
|
||||
# define LONG_LONG_VALUE 1
|
||||
# define SIZEOF_VALUE SIZEOF_LONG_LONG
|
||||
#else
|
||||
# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
|
||||
#endif
|
||||
#define SIGNED_VALUE intptr_t
|
||||
|
||||
#ifdef HAVE_INFINITY
|
||||
#elif BYTE_ORDER == LITTLE_ENDIAN
|
||||
@@ -980,80 +955,6 @@ mrb_num2ulong(mrb_state *mrb, mrb_value val)
|
||||
}
|
||||
}
|
||||
|
||||
#if SIZEOF_INT < SIZEOF_VALUE
|
||||
void
|
||||
mrb_out_of_int(mrb_state *mrb, SIGNED_VALUE num)
|
||||
{
|
||||
mrb_raise(mrb, E_RANGE_ERROR, "integer %"PRIdVALUE " too %s to convert to `int'",
|
||||
num, num < 0 ? "small" : "big");
|
||||
}
|
||||
|
||||
static void
|
||||
check_int(SIGNED_VALUE num)
|
||||
{
|
||||
if ((SIGNED_VALUE)(int)num != num) {
|
||||
mrb_out_of_int(num);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
check_uint(mrb_state *mrb, mrb_value num, mrb_value sign)
|
||||
{
|
||||
static const mrb_value mask = ~(mrb_value)UINT_MAX;
|
||||
|
||||
if (RTEST(sign)) {
|
||||
/* minus */
|
||||
if ((num & mask) != mask || (num & ~mask) <= INT_MAX + 1UL)
|
||||
mrb_raise(mrb, E_RANGE_ERROR, "integer %"PRIdVALUE " too small to convert to `unsigned int'", num);
|
||||
}
|
||||
else {
|
||||
/* plus */
|
||||
if ((num & mask) != 0)
|
||||
mrb_raise(mrb, E_RANGE_ERROR, "integer %"PRIuVALUE " too big to convert to `unsigned int'", num);
|
||||
}
|
||||
}
|
||||
|
||||
long
|
||||
mrb_num2int(mrb_value val)
|
||||
{
|
||||
long num = mrb_num2long(mrb, val);
|
||||
|
||||
check_int(num);
|
||||
return num;
|
||||
}
|
||||
|
||||
long
|
||||
mrb_fix2int(mrb_state *mrb, mrb_value val)
|
||||
{
|
||||
long num = FIXNUM_P(val)?mrb_fixnum(val):mrb_num2long(mrb, val);
|
||||
|
||||
check_int(num);
|
||||
return num;
|
||||
}
|
||||
|
||||
unsigned long
|
||||
mrb_num2uint(mrb_value val)
|
||||
{
|
||||
unsigned long num = mrb_num2ulong(val);
|
||||
|
||||
check_uint(num, mrb_funcall(mrb, val, "<", 1, mrb_fixnum_value(0)));
|
||||
return num;
|
||||
}
|
||||
|
||||
unsigned long
|
||||
mrb_fix2uint(mrb_state *mrb, mrb_value val)
|
||||
{
|
||||
unsigned long num;
|
||||
|
||||
if (!FIXNUM_P(val)) {
|
||||
return mrb_num2uint(mrb, val);
|
||||
}
|
||||
num = FIX2ULONG(val);
|
||||
|
||||
check_uint(num, mrb_funcall(mrb, val, "<", 1, mrb_fixnum_value(0)));
|
||||
return num;
|
||||
}
|
||||
#else
|
||||
long
|
||||
mrb_num2int(mrb_state *mrb, mrb_value val)
|
||||
{
|
||||
@@ -1065,7 +966,6 @@ mrb_fix2int(mrb_value val)
|
||||
{
|
||||
return mrb_fixnum(val);
|
||||
}
|
||||
#endif
|
||||
|
||||
mrb_value
|
||||
mrb_num2fix(mrb_state *mrb, mrb_value val)
|
||||
@@ -1076,59 +976,10 @@ mrb_num2fix(mrb_state *mrb, mrb_value val)
|
||||
|
||||
v = mrb_num2long(mrb, val);
|
||||
if (!FIXABLE(v))
|
||||
mrb_raise(mrb, E_RANGE_ERROR, "integer %"PRIdVALUE " out of range of fixnum", v);
|
||||
mrb_raise(mrb, E_RANGE_ERROR, "integer %ld out of range of fixnum", v);
|
||||
return mrb_fixnum_value(v);
|
||||
}
|
||||
|
||||
#if HAVE_LONG_LONG
|
||||
|
||||
LONG_LONG
|
||||
mrb_num2ll(mrb_state *mrb, mrb_value val)
|
||||
{
|
||||
if (mrb_nil_p(val)) {
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "no implicit conversion from nil");
|
||||
}
|
||||
|
||||
if (FIXNUM_P(val)) return (LONG_LONG)mrb_fixnum(val);
|
||||
|
||||
switch (mrb_type(val)) {
|
||||
case MRB_TT_FLOAT:
|
||||
if (mrb_float(val) <= (double)LLONG_MAX
|
||||
&& mrb_float(val) >= (double)LLONG_MIN) {
|
||||
return (LONG_LONG)(mrb_float(val));
|
||||
}
|
||||
else {
|
||||
char buf[24];
|
||||
char *s;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%-.10g", mrb_float(val));
|
||||
if ((s = strchr(buf, ' ')) != 0) *s = '\0';
|
||||
mrb_raise(mrb, E_RANGE_ERROR, "float %s out of range of long long", buf);
|
||||
}
|
||||
|
||||
case MRB_TT_STRING:
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "no implicit conversion from string");
|
||||
return mrb_nil_value(); /* not reached */
|
||||
|
||||
case MRB_TT_TRUE:
|
||||
case MRB_TT_FALSE:
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "no implicit conversion from boolean");
|
||||
return mrb_nil_value(); /* not reached */
|
||||
|
||||
default:
|
||||
val = mrb_to_int(mrb, val);
|
||||
return NUM2LL(val);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned LONG_LONG
|
||||
mrb_num2ull(mrb_state *mrb, mrb_value val)
|
||||
{
|
||||
return (unsigned LONG_LONG)mrb_num2ll(mrb, val);
|
||||
}
|
||||
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
|
||||
/*
|
||||
* Document-class: Integer
|
||||
*
|
||||
@@ -1204,7 +1055,7 @@ mrb_value
|
||||
rb_fix2str(mrb_state *mrb, mrb_value x, int base)
|
||||
{
|
||||
extern const char ruby_digitmap[];
|
||||
char buf[SIZEOF_VALUE*CHAR_BIT + 2], *b = buf + sizeof buf;
|
||||
char buf[sizeof(mrb_int)*CHAR_BIT + 2], *b = buf + sizeof buf;
|
||||
long val = mrb_fixnum(x);
|
||||
int neg = 0;
|
||||
|
||||
@@ -1229,7 +1080,7 @@ rb_fix2str(mrb_state *mrb, mrb_value x, int base)
|
||||
return mrb_usascii_str_new2(mrb, b);
|
||||
}
|
||||
|
||||
#define SQRT_LONG_MAX ((SIGNED_VALUE)1<<((SIZEOF_LONG*CHAR_BIT-1)/2))
|
||||
#define SQRT_LONG_MAX ((SIGNED_VALUE)1<<((sizeof(intptr_t)*CHAR_BIT-1)/2))
|
||||
/*tests if N*N would overflow*/
|
||||
#define FIT_SQRT_LONG(n) (((n)<SQRT_LONG_MAX)&&((n)>=-SQRT_LONG_MAX))
|
||||
|
||||
@@ -1255,21 +1106,12 @@ fix_mul(mrb_state *mrb, mrb_value x)
|
||||
volatile
|
||||
#endif
|
||||
long a, b;
|
||||
#if SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
|
||||
LONG_LONG d;
|
||||
#else
|
||||
long c;
|
||||
mrb_value r;
|
||||
#endif
|
||||
|
||||
a = mrb_fixnum(x);
|
||||
b = mrb_fixnum(y);
|
||||
|
||||
#if SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
|
||||
d = (LONG_LONG)a * b;
|
||||
if (FIXABLE(d)) return mrb_fixnum_value(d);
|
||||
return mrb_nil_value();// rb_ll2inum(d);
|
||||
#else
|
||||
if (FIT_SQRT_LONG(a) && FIT_SQRT_LONG(b))
|
||||
return mrb_fixnum_value(a*b);
|
||||
c = a * b;
|
||||
@@ -1281,7 +1123,6 @@ fix_mul(mrb_state *mrb, mrb_value x)
|
||||
r = mrb_fixnum_value(a*b);
|
||||
}
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
switch (mrb_type(y)) {
|
||||
case MRB_TT_FLOAT:
|
||||
@@ -1615,9 +1456,9 @@ mrb_fix_lshift(mrb_state *mrb, mrb_value x)
|
||||
static mrb_value
|
||||
fix_lshift(mrb_state *mrb, long val, unsigned long width)
|
||||
{
|
||||
if (width > (SIZEOF_LONG*CHAR_BIT-1)
|
||||
|| ((unsigned long)abs(val))>>(SIZEOF_LONG*CHAR_BIT-1-width) > 0) {
|
||||
mrb_raise(mrb, E_RANGE_ERROR, "width(%d) > (SIZEOF_LONG*CHAR_BIT-1)", width);
|
||||
if (width > (sizeof(intptr_t)*CHAR_BIT-1)
|
||||
|| ((unsigned long)abs(val))>>(sizeof(intptr_t)*CHAR_BIT-1-width) > 0) {
|
||||
mrb_raise(mrb, E_RANGE_ERROR, "width(%d) > (sizeof(intptr_t)*CHAR_BIT-1)", width);
|
||||
}
|
||||
val = val << width;
|
||||
return mrb_fixnum_value(val);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "mruby/class.h"
|
||||
#include "method.h"
|
||||
#include "mruby/numeric.h"
|
||||
#include "mdata.h"
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#define mrb_usascii_str_new2 mrb_usascii_str_new_cstr
|
||||
|
||||
+58
-7
@@ -275,7 +275,7 @@ new_true(parser_state *p)
|
||||
return list1((node*)NODE_TRUE);
|
||||
}
|
||||
|
||||
// (:true)
|
||||
// (:false)
|
||||
static node*
|
||||
new_false(parser_state *p)
|
||||
{
|
||||
@@ -2898,8 +2898,21 @@ none : /* none */
|
||||
static void
|
||||
yyerror(parser_state *p, const char *s)
|
||||
{
|
||||
fputs(s, stderr);
|
||||
fputs("\n", stderr);
|
||||
char* c;
|
||||
size_t n;
|
||||
|
||||
if (! p->capture_errors) {
|
||||
fputs(s, stderr);
|
||||
fputs("\n", stderr);
|
||||
}
|
||||
else if (p->nerr < sizeof(p->error_buffer) / sizeof(p->error_buffer[0])) {
|
||||
n = strlen(s);
|
||||
c = parser_palloc(p, n + 1);
|
||||
memcpy(c, s, n + 1);
|
||||
p->error_buffer[p->nerr].message = c;
|
||||
p->error_buffer[p->nerr].lineno = p->lineno;
|
||||
p->error_buffer[p->nerr].column = p->column;
|
||||
}
|
||||
p->nerr++;
|
||||
}
|
||||
|
||||
@@ -2915,8 +2928,22 @@ yyerror_i(parser_state *p, const char *fmt, int i)
|
||||
static void
|
||||
yywarn(parser_state *p, const char *s)
|
||||
{
|
||||
fputs(s, stderr);
|
||||
fputs("\n", stderr);
|
||||
char* c;
|
||||
size_t n;
|
||||
|
||||
if (! p->capture_errors) {
|
||||
fputs(s, stderr);
|
||||
fputs("\n", stderr);
|
||||
}
|
||||
else if (p->nerr < sizeof(p->warn_buffer) / sizeof(p->warn_buffer[0])) {
|
||||
n = strlen(s);
|
||||
c = parser_palloc(p, n + 1);
|
||||
memcpy(c, s, n + 1);
|
||||
p->error_buffer[p->nwarn].message = c;
|
||||
p->error_buffer[p->nwarn].lineno = p->lineno;
|
||||
p->error_buffer[p->nwarn].column = p->column;
|
||||
}
|
||||
p->nwarn++;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2976,8 +3003,13 @@ nextc(parser_state *p)
|
||||
c = *p->s++;
|
||||
}
|
||||
if (c == '\n') {
|
||||
p->lineno++;
|
||||
p->column = 0;
|
||||
if (p->column < 0) {
|
||||
p->column++; // pushback caused an underflow
|
||||
}
|
||||
else {
|
||||
p->lineno++;
|
||||
p->column = 0;
|
||||
}
|
||||
// must understand heredoc
|
||||
}
|
||||
else {
|
||||
@@ -4228,6 +4260,7 @@ parser_yylex(parser_state *p)
|
||||
else if (term == '[') term = ']';
|
||||
else if (term == '{') term = '}';
|
||||
else if (term == '<') term = '>';
|
||||
p->sterm = term;
|
||||
#if 0
|
||||
else paren = 0;
|
||||
#endif
|
||||
@@ -4603,6 +4636,8 @@ parser_new(mrb_state *mrb)
|
||||
p->cmd_start = TRUE;
|
||||
p->in_def = p->in_single = FALSE;
|
||||
|
||||
p->capture_errors = NULL;
|
||||
|
||||
p->lineno = 1;
|
||||
#if defined(PARSER_TEST) || defined(PARSER_DEBUG)
|
||||
yydebug = 1;
|
||||
@@ -4640,6 +4675,22 @@ mrb_parse_nstring(mrb_state *mrb, char *s, size_t len)
|
||||
return p;
|
||||
}
|
||||
|
||||
parser_state*
|
||||
mrb_parse_nstring_ext(mrb_state *mrb, char *s, size_t len)
|
||||
{
|
||||
parser_state *p;
|
||||
|
||||
p = parser_new(mrb);
|
||||
if (!p) return 0;
|
||||
p->s = s;
|
||||
p->send = s + len;
|
||||
p->f = NULL;
|
||||
p->capture_errors = 1;
|
||||
|
||||
start_parser(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
parser_state*
|
||||
mrb_parse_string(mrb_state *mrb, char *s)
|
||||
{
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ mrb_pool_alloc(mrb_pool *pool, size_t len)
|
||||
if (page->offset + len <= page->len) {
|
||||
n = page->offset;
|
||||
page->offset += len;
|
||||
page->last = (void*)page->page+n;
|
||||
page->last = (char*)page->page+n;
|
||||
return page->last;
|
||||
}
|
||||
page = page->next;
|
||||
|
||||
+18
@@ -50,6 +50,22 @@ mrb_proc_new_cfunc(mrb_state *mrb, mrb_func_t func)
|
||||
return p;
|
||||
}
|
||||
|
||||
static mrb_value
|
||||
mrb_proc_initialize(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
mrb_value blk = mrb->stack[mrb->ci->argc+1];
|
||||
|
||||
if (!mrb_nil_p(blk)) {
|
||||
*mrb_proc_ptr(self) = *mrb_proc_ptr(blk);
|
||||
}
|
||||
else {
|
||||
/* Calling Proc.new without a block is not implemented yet */
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "tried to create Proc object without a block");
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
int
|
||||
mrb_proc_cfunc_p(struct RProc *p)
|
||||
{
|
||||
@@ -86,6 +102,8 @@ mrb_init_proc(mrb_state *mrb)
|
||||
|
||||
mrb->proc_class = mrb_define_class(mrb, "Proc", mrb->object_class);
|
||||
|
||||
mrb_define_method(mrb, mrb->proc_class, "initialize", mrb_proc_initialize, ARGS_NONE());
|
||||
|
||||
m = mrb_proc_new(mrb, call_irep);
|
||||
mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern(mrb, "call"), m);
|
||||
mrb_define_method_raw(mrb, mrb->proc_class, mrb_intern(mrb, "[]"), m);
|
||||
|
||||
@@ -1773,11 +1773,7 @@ static int
|
||||
pair_byte_cmp(const void *pair1, const void *pair2)
|
||||
{
|
||||
long diff = ((pair_t*)pair1)->byte_pos - ((pair_t*)pair2)->byte_pos;
|
||||
#if SIZEOF_LONG > SIZEOF_INT
|
||||
return diff ? diff > 0 ? 1 : -1 : 0;
|
||||
#else
|
||||
return (int)diff;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2958,48 +2954,6 @@ mrb_backref_set(mrb_state *mrb, mrb_value val)
|
||||
#endif //INCLUDE_REGEXP
|
||||
|
||||
#ifdef INCLUDE_ENCODING
|
||||
static inline long
|
||||
mrb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
|
||||
{
|
||||
const unsigned char *x = xs, *xe = xs + m;
|
||||
const unsigned char *y = ys, *ye = ys + n;
|
||||
#define SIZEOF_VOIDP 4
|
||||
#define SIZEOF_LONG 4
|
||||
|
||||
#ifndef VALUE_MAX
|
||||
# if SIZEOF_VALUE == 8
|
||||
# define VALUE_MAX 0xFFFFFFFFFFFFFFFFULL
|
||||
# elif SIZEOF_VALUE == 4
|
||||
# define VALUE_MAX 0xFFFFFFFFUL
|
||||
# elif SIZEOF_LONG == SIZEOF_VOIDP
|
||||
# define SIZEOF_VALUE 4
|
||||
# define VALUE_MAX 0xFFFFFFFFUL
|
||||
# endif
|
||||
#endif
|
||||
int hx, hy, mask = VALUE_MAX >> ((SIZEOF_VALUE - m) * CHAR_BIT);
|
||||
|
||||
if (m > SIZEOF_VALUE)
|
||||
mrb_bug("!!too long pattern string!!");
|
||||
|
||||
/* Prepare hash value */
|
||||
for (hx = *x++, hy = *y++; x < xe; ++x, ++y) {
|
||||
hx <<= CHAR_BIT;
|
||||
hy <<= CHAR_BIT;
|
||||
hx |= *x;
|
||||
hy |= *y;
|
||||
}
|
||||
/* Searching */
|
||||
while (hx != hy) {
|
||||
if (y == ye)
|
||||
return -1;
|
||||
hy <<= CHAR_BIT;
|
||||
hy |= *y;
|
||||
hy &= mask;
|
||||
y++;
|
||||
}
|
||||
return y - ys - m;
|
||||
}
|
||||
|
||||
static inline long
|
||||
mrb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)
|
||||
{
|
||||
@@ -3094,9 +3048,6 @@ mrb_memsearch(mrb_state *mrb, const void *x0, int m, const void *y0, int n, mrb_
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
else if (m <= SIZEOF_VALUE) {
|
||||
return mrb_memsearch_ss(x0, m, y0, n);
|
||||
}
|
||||
else if (enc == mrb_utf8_encoding(mrb)) {
|
||||
return mrb_memsearch_qs_utf8(x0, m, y0, n);
|
||||
}
|
||||
|
||||
+2
-2
@@ -246,11 +246,11 @@
|
||||
} while(0)
|
||||
|
||||
/* sizeof(OnigCodePoint) */
|
||||
#define WORD_ALIGNMENT_SIZE SIZEOF_LONG
|
||||
#define WORD_ALIGNMENT_SIZE sizeof(uintptr_t)
|
||||
|
||||
#define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
|
||||
(pad_size) = WORD_ALIGNMENT_SIZE \
|
||||
- ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
|
||||
- ((uintptr_t)(addr) % WORD_ALIGNMENT_SIZE);\
|
||||
if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
|
||||
} while (0)
|
||||
|
||||
|
||||
@@ -9,23 +9,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef RUBY_LIB_PREFIX
|
||||
|
||||
#ifdef RUBY_EXTCONF_H
|
||||
#include RUBY_EXTCONF_H
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined STDC_HEADERS
|
||||
#include <stddef.h>
|
||||
#elif defined HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# ifdef HAVE_LIMITS_H
|
||||
@@ -35,10 +20,6 @@ extern "C" {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _
|
||||
# define _(args) args
|
||||
#endif
|
||||
|
||||
#ifndef ANYARGS
|
||||
# ifdef __cplusplus
|
||||
# define ANYARGS ...
|
||||
@@ -64,27 +45,15 @@ struct st_table_entry {
|
||||
st_table_entry *fore, *back;
|
||||
};
|
||||
|
||||
#ifndef SIZEOF_VOIDP
|
||||
#define SIZEOF_VOIDP 4
|
||||
#endif
|
||||
|
||||
#define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
|
||||
|
||||
struct st_hash_type {
|
||||
int (*compare)(ANYARGS /*st_data_t, st_data_t*/); /* st_compare_func* */
|
||||
st_index_t (*hash)(ANYARGS /*st_data_t*/); /* st_hash_func* */
|
||||
};
|
||||
|
||||
#define ST_INDEX_BITS (sizeof(st_index_t) * CHAR_BIT)
|
||||
|
||||
struct st_table {
|
||||
const struct st_hash_type *type;
|
||||
st_index_t num_bins;
|
||||
unsigned int entries_packed : 1;
|
||||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
st_index_t num_entries : ST_INDEX_BITS - 1;
|
||||
int num_bins;
|
||||
int num_entries;
|
||||
struct st_table_entry **bins;
|
||||
struct st_table_entry *head, *tail;
|
||||
};
|
||||
@@ -94,46 +63,37 @@ struct st_table {
|
||||
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK};
|
||||
|
||||
st_table *st_init_table(const struct st_hash_type *);
|
||||
st_table *st_init_table_with_size(const struct st_hash_type *, st_index_t);
|
||||
st_table *st_init_table_with_size(const struct st_hash_type *, int);
|
||||
st_table *st_init_numtable(void);
|
||||
st_table *st_init_numtable_with_size(st_index_t);
|
||||
st_table *st_init_numtable_with_size(int);
|
||||
st_table *st_init_strtable(void);
|
||||
st_table *st_init_strtable_with_size(st_index_t);
|
||||
st_table *st_init_strtable_with_size(int);
|
||||
st_table *st_init_strcasetable(void);
|
||||
st_table *st_init_strcasetable_with_size(st_index_t);
|
||||
int st_delete(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */
|
||||
int st_delete(st_table *, st_data_t *, st_data_t *);
|
||||
int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t);
|
||||
int st_insert(st_table *, st_data_t, st_data_t);
|
||||
int st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t));
|
||||
int st_lookup(st_table *, st_data_t, st_data_t *);
|
||||
int st_get_key(st_table *, st_data_t, st_data_t *);
|
||||
int st_foreach(st_table *, int (*)(ANYARGS), st_data_t);
|
||||
int st_foreachNew(mrb_state *mrb, st_table *, int (*)(ANYARGS), void*);
|
||||
int st_reverse_foreach(st_table *, int (*)(ANYARGS), st_data_t);
|
||||
void st_add_direct(st_table *, st_data_t, st_data_t);
|
||||
void st_free_table(st_table *);
|
||||
void st_cleanup_safe(st_table *, st_data_t);
|
||||
void st_clear(st_table *);
|
||||
st_table *st_copy(st_table *);
|
||||
int st_numcmp(st_data_t, st_data_t);
|
||||
st_index_t st_numhash(st_data_t);
|
||||
int st_strcasecmp(const char *s1, const char *s2);
|
||||
int st_strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
size_t st_memsize(const st_table *);
|
||||
st_index_t st_hash(const void *ptr, size_t len, st_index_t h);
|
||||
st_index_t st_hash_uint32(st_index_t h, uint32_t i);
|
||||
st_index_t st_hash_uint(st_index_t h, st_index_t i);
|
||||
st_index_t st_hash_end(st_index_t h);
|
||||
st_index_t st_hash_start(st_index_t h);
|
||||
#define st_hash_start(h) ((st_index_t)(h))
|
||||
|
||||
int st_strcasecmp(const char *s1, const char *s2);
|
||||
int st_strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
#define STRCASECMP(s1, s2) (st_strcasecmp(s1, s2))
|
||||
#define STRNCASECMP(s1, s2, n) (st_strncasecmp(s1, s2, n))
|
||||
|
||||
#define ST_NUMCMP ((int (*)()) 0)
|
||||
#define ST_NUMHASH ((int (*)()) -2)
|
||||
|
||||
#define st_numcmp ST_NUMCMP
|
||||
#define st_numhash ST_NUMHASH
|
||||
|
||||
int st_strhash();
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} /* extern "C" { */
|
||||
#endif
|
||||
|
||||
#endif /* RUBY_ST_H */
|
||||
#endif /* ST_INCLUDED */
|
||||
|
||||
+11
-172
@@ -211,38 +211,12 @@ single_byte_optimizable(mrb_state *mrb, mrb_value str)
|
||||
static inline const char *
|
||||
search_nonascii(const char *p, const char *e)
|
||||
{
|
||||
#if SIZEOF_VALUE == 8
|
||||
# define NONASCII_MASK 0x8080808080808080ULL
|
||||
#elif SIZEOF_VALUE == 4
|
||||
# define NONASCII_MASK 0x80808080UL
|
||||
#endif
|
||||
#ifdef NONASCII_MASK
|
||||
if ((int)sizeof(intptr_t) * 2 < e - p) {
|
||||
const intptr_t *s, *t;
|
||||
const intptr_t lowbits = sizeof(intptr_t) - 1;
|
||||
s = (const intptr_t*)(~lowbits & ((intptr_t)p + lowbits));
|
||||
while (p < (const char *)s) {
|
||||
if (!ISASCII(*p))
|
||||
return p;
|
||||
p++;
|
||||
}
|
||||
t = (const intptr_t*)(~lowbits & (intptr_t)e);
|
||||
while (s < t) {
|
||||
if (*s & (intptr_t)NONASCII_MASK) {
|
||||
t = s;
|
||||
break;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
p = (const char *)t;
|
||||
}
|
||||
#endif
|
||||
while (p < e) {
|
||||
if (!ISASCII(*p))
|
||||
return p;
|
||||
p++;
|
||||
}
|
||||
return NULL;
|
||||
while (p < e) {
|
||||
if (!ISASCII(*p))
|
||||
return p;
|
||||
p++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif //INCLUDE_ENCODING
|
||||
|
||||
@@ -1167,63 +1141,6 @@ mrb_str_match(mrb_state *mrb, mrb_value self/* x */)
|
||||
}
|
||||
}
|
||||
/* ---------------------------------- */
|
||||
#ifdef INCLUDE_ENCODING
|
||||
#ifdef NONASCII_MASK
|
||||
#define is_utf8_lead_byte(c) (((c)&0xC0) != 0x80)
|
||||
static inline int
|
||||
count_utf8_lead_bytes_with_word(const intptr_t *s)
|
||||
{
|
||||
int d = *s;
|
||||
d |= ~(d>>1);
|
||||
d >>= 6;
|
||||
d &= NONASCII_MASK >> 7;
|
||||
d += (d>>8);
|
||||
d += (d>>16);
|
||||
#if SIZEOF_VALUE == 8
|
||||
d += (d>>32);
|
||||
#endif
|
||||
return (d&0xF);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NONASCII_MASK
|
||||
static char *
|
||||
str_utf8_nth(const char *p, const char *e, long nth)
|
||||
{
|
||||
if ((int)SIZEOF_VALUE < e - p && (int)SIZEOF_VALUE * 2 < nth) {
|
||||
const intptr_t *s, *t;
|
||||
const intptr_t lowbits = sizeof(int) - 1;
|
||||
s = (const intptr_t*)(~lowbits & ((intptr_t)p + lowbits));
|
||||
t = (const intptr_t*)(~lowbits & (intptr_t)e);
|
||||
while (p < (const char *)s) {
|
||||
if (is_utf8_lead_byte(*p)) nth--;
|
||||
p++;
|
||||
}
|
||||
do {
|
||||
nth -= count_utf8_lead_bytes_with_word(s);
|
||||
s++;
|
||||
} while (s < t && (int)sizeof(intptr_t) <= nth);
|
||||
p = (char *)s;
|
||||
}
|
||||
while (p < e) {
|
||||
if (is_utf8_lead_byte(*p)) {
|
||||
if (nth == 0) break;
|
||||
nth--;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
return (char *)p;
|
||||
}
|
||||
|
||||
static long
|
||||
str_utf8_offset(const char *p, const char *e, long nth)
|
||||
{
|
||||
const char *pp = str_utf8_nth(p, e, nth);
|
||||
return pp - p;
|
||||
}
|
||||
#endif
|
||||
#endif //INCLUDE_ENCODING
|
||||
|
||||
mrb_value
|
||||
mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, int len)
|
||||
{
|
||||
@@ -1283,13 +1200,6 @@ mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, int len)
|
||||
if (len == 0) {
|
||||
p = 0;
|
||||
}
|
||||
#ifdef NONASCII_MASK
|
||||
else if (ENC_CODERANGE(str) == ENC_CODERANGE_VALID &&
|
||||
enc == mrb_utf8_encoding(mrb)) {
|
||||
p = str_utf8_nth(s, e, beg);
|
||||
len = str_utf8_offset(p, e, len);
|
||||
}
|
||||
#endif
|
||||
else if (mrb_enc_mbmaxlen(enc) == mrb_enc_mbminlen(enc)) {
|
||||
int char_sz = mrb_enc_mbmaxlen(enc);
|
||||
|
||||
@@ -1405,46 +1315,6 @@ mrb_enc_strlen_cr(mrb_state *mrb, const char *p, const char *e, mrb_encoding *en
|
||||
/* --- 1-8-7parse.c --< */
|
||||
|
||||
#ifndef INCLUDE_ENCODING
|
||||
static inline long
|
||||
mrb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n)
|
||||
{
|
||||
const unsigned char *x = xs, *xe = xs + m;
|
||||
const unsigned char *y = ys, *ye = ys + n;
|
||||
//2011/06/30 #define SIZEOF_VALUE 4
|
||||
#ifndef VALUE_MAX
|
||||
# if SIZEOF_VALUE == 8
|
||||
# define VALUE_MAX 0xFFFFFFFFFFFFFFFFULL
|
||||
# elif SIZEOF_VALUE == 4
|
||||
# define VALUE_MAX 0xFFFFFFFFUL
|
||||
# elif SIZEOF_LONG == SIZEOF_VOIDP
|
||||
# define SIZEOF_VALUE 4
|
||||
# define VALUE_MAX 0xFFFFFFFFUL
|
||||
# endif
|
||||
#endif
|
||||
int hx, hy, mask = VALUE_MAX >> ((SIZEOF_VALUE - m) * CHAR_BIT);
|
||||
|
||||
if (m > SIZEOF_VALUE)
|
||||
mrb_bug("!!too long pattern string!!");
|
||||
|
||||
/* Prepare hash value */
|
||||
for (hx = *x++, hy = *y++; x < xe; ++x, ++y) {
|
||||
hx <<= CHAR_BIT;
|
||||
hy <<= CHAR_BIT;
|
||||
hx |= *x;
|
||||
hy |= *y;
|
||||
}
|
||||
/* Searching */
|
||||
while (hx != hy) {
|
||||
if (y == ye)
|
||||
return -1;
|
||||
hy <<= CHAR_BIT;
|
||||
hy |= *y;
|
||||
hy &= mask;
|
||||
y++;
|
||||
}
|
||||
return y - ys - m;
|
||||
}
|
||||
|
||||
static inline long
|
||||
mrb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n)
|
||||
{
|
||||
@@ -1464,6 +1334,7 @@ mrb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
mrb_memsearch(const void *x0, int m, const void *y0, int n)
|
||||
{
|
||||
@@ -1484,12 +1355,7 @@ mrb_memsearch(const void *x0, int m, const void *y0, int n)
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
else if (m <= SIZEOF_VALUE) {
|
||||
return mrb_memsearch_ss(x0, m, y0, n);
|
||||
}
|
||||
else {
|
||||
return mrb_memsearch_qs(x0, m, y0, n);
|
||||
}
|
||||
return mrb_memsearch_qs(x0, m, y0, n);
|
||||
}
|
||||
#endif //INCLUDE_ENCODING
|
||||
|
||||
@@ -1507,33 +1373,6 @@ str_strlen(mrb_state *mrb, mrb_value str, mrb_encoding *enc)
|
||||
p = RSTRING_PTR(str);
|
||||
e = RSTRING_END(str);
|
||||
cr = ENC_CODERANGE(str);
|
||||
#ifdef NONASCII_MASK
|
||||
if (ENC_CODERANGE(str) == ENC_CODERANGE_VALID &&
|
||||
enc == mrb_utf8_encoding(mrb)) {
|
||||
|
||||
int len = 0;
|
||||
if ((int)sizeof(intptr_t) * 2 < e - p) {
|
||||
const intptr_t *s, *t;
|
||||
const intptr_t lowbits = sizeof(int) - 1;
|
||||
s = (const intptr_t*)(~lowbits & ((intptr_t)p + lowbits));
|
||||
t = (const intptr_t*)(~lowbits & (intptr_t)e);
|
||||
while (p < (const char *)s) {
|
||||
if (is_utf8_lead_byte(*p)) len++;
|
||||
p++;
|
||||
}
|
||||
while (s < t) {
|
||||
len += count_utf8_lead_bytes_with_word(s);
|
||||
s++;
|
||||
}
|
||||
p = (const char *)s;
|
||||
}
|
||||
while (p < e) {
|
||||
if (is_utf8_lead_byte(*p)) len++;
|
||||
p++;
|
||||
}
|
||||
return (long)len;
|
||||
}
|
||||
#endif
|
||||
n = mrb_enc_strlen_cr(mrb, p, e, enc, &cr);
|
||||
if (cr) {
|
||||
ENC_CODERANGE_SET(str, cr);
|
||||
@@ -4994,9 +4833,9 @@ mrb_str_buf_cat_escaped_char(mrb_state *mrb, mrb_value result, unsigned int c, i
|
||||
char buf[CHAR_ESC_LEN + 1];
|
||||
int l;
|
||||
|
||||
#if SIZEOF_INT > 4
|
||||
c &= 0xffffffff;
|
||||
#endif
|
||||
if (sizeof(c) > 4) {
|
||||
c &= 0xffffffff;
|
||||
}
|
||||
if (unicode_p) {
|
||||
if (c < 0x7F && ISPRINT(c)) {
|
||||
snprintf(buf, CHAR_ESC_LEN, "%c", c);
|
||||
|
||||
+6
-6
@@ -632,14 +632,14 @@ transcode_restartable0(mrb_state *mrb,
|
||||
}
|
||||
continue;
|
||||
case FUNii:
|
||||
next_info = (mrb_value)(*tr->func_ii)(TRANSCODING_STATE(tc), next_info);
|
||||
next_info = (*tr->func_ii)(TRANSCODING_STATE(tc), next_info);
|
||||
goto follow_info;
|
||||
case FUNsi:
|
||||
{
|
||||
const unsigned char *char_start;
|
||||
size_t char_len;
|
||||
char_start = transcode_char_start(tc, *in_pos, inchar_start, in_p, &char_len);
|
||||
next_info = (mrb_value)(*tr->func_si)(TRANSCODING_STATE(tc), char_start, (size_t)char_len);
|
||||
next_info = (*tr->func_si)(TRANSCODING_STATE(tc), char_start, (size_t)char_len);
|
||||
goto follow_info;
|
||||
}
|
||||
case FUNio:
|
||||
@@ -1770,9 +1770,9 @@ mrb_econv_putbackable(mrb_econv_t *ec)
|
||||
{
|
||||
if (ec->num_trans == 0)
|
||||
return 0;
|
||||
#if SIZEOF_SIZE_T > SIZEOF_INT
|
||||
if (ec->elems[0].tc->readagain_len > INT_MAX) return INT_MAX;
|
||||
#endif
|
||||
if (sizeof(size_t) > sizeof(int)) {
|
||||
if (ec->elems[0].tc->readagain_len > INT_MAX) return INT_MAX;
|
||||
}
|
||||
return (int)ec->elems[0].tc->readagain_len;
|
||||
}
|
||||
|
||||
@@ -2625,7 +2625,7 @@ str_transcode0(mrb_state *mrb, int argc, mrb_value *argv, mrb_value *self, int e
|
||||
|
||||
transcode_loop(mrb, &fromp, &bp, (sp+slen), (bp+blen), dest, str_transcoding_resize, sname, dname, ecflags, ecopts);
|
||||
if (fromp != sp+slen) {
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "not fully converted, %"PRIdPTRDIFF" bytes left", sp+slen-fromp);
|
||||
mrb_raise(mrb, E_ARGUMENT_ERROR, "not fully converted, %td bytes left", sp+slen-fromp);
|
||||
}
|
||||
buf = (unsigned char *)RSTRING_PTR(dest);
|
||||
*bp = '\0';
|
||||
|
||||
@@ -30,7 +30,6 @@ int mrb_const_defined(mrb_state*, mrb_value, mrb_sym);
|
||||
mrb_value mrb_obj_iv_get(mrb_state*, struct RObject*, mrb_sym);
|
||||
void mrb_obj_iv_set(mrb_state*, struct RObject*, mrb_sym, mrb_value);
|
||||
const char * mrb_class2name(mrb_state *mrb, struct RClass* klass);
|
||||
void mrb_define_variable(mrb_state *mrb, const char *name, mrb_value *var);
|
||||
mrb_value mrb_iv_get(mrb_state *mrb, mrb_value obj, mrb_sym sym);
|
||||
void mrb_iv_set(mrb_state *mrb, mrb_value obj, mrb_sym sym, mrb_value v); /* mrb_iv_set */
|
||||
void mrb_copy_generic_ivar(mrb_value clone, mrb_value obj);
|
||||
|
||||
@@ -69,5 +69,6 @@ $(YC) : $(YSRC)
|
||||
clean :
|
||||
-rm -f $(EXE) $(OBJS) $(OBJY) $(YC)
|
||||
-rm -f $(OBJS:.o=.d) $(OBJY:.o=.d)
|
||||
-rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1))
|
||||
@echo "make: removing targets, objects and depend files of `pwd`"
|
||||
|
||||
|
||||
@@ -86,4 +86,5 @@ clean :
|
||||
$(MAKE) clean -C ../../mrblib $(MAKE_FLAGS)
|
||||
-rm -f $(EXE) $(OBJS) $(OBJY) $(YC) $(EXTS)
|
||||
-rm -f $(OBJS:.o=.d) $(OBJY:.o=.d) $(EXTS:.o=.d)
|
||||
-rm -f $(patsubst %.c,%.o,$(EXCEPT1)) $(patsubst %.c,%.d,$(EXCEPT1))
|
||||
@echo "make: removing targets, objects and depend files of `pwd`"
|
||||
|
||||
+3
-3
@@ -22,10 +22,10 @@ usage(const char *name)
|
||||
{
|
||||
static const char *const usage_msg[] = {
|
||||
"switches:",
|
||||
"-b load and execute RiteBinary(mrb) file",
|
||||
"-b load and execute RiteBinary (mrb) file",
|
||||
"-c check syntax only",
|
||||
"-v print version number, then trun on verbose mode",
|
||||
"--verbose run at verbose mode",
|
||||
"-v print version number, then run in verbose mode",
|
||||
"--verbose run in verbose mode",
|
||||
"--version print the version",
|
||||
"--copyright print the copyright",
|
||||
NULL
|
||||
|
||||
Reference in New Issue
Block a user