Commit Graph

121 Commits

Author SHA1 Message Date
KOBAYASHI Shuji feaf80d899 Use type predicate macros instead of mrb_type if possible
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for
all `enum mrb_vtype`).
2019-09-26 22:23:27 +09:00
Yukihiro "Matz" Matsumoto 184aeb0694 Merge pull request #4732 from dearblue/inttypes
Use inttypes for `snprintf()`
2019-09-26 06:31:07 +09:00
dearblue 84d9296c05 Use inttypes for snprintf() 2019-09-25 23:28:05 +09:00
KOBAYASHI Shuji 27e8ea4ea2 Remove MRB_TT_HAS_BASIC macro
The value of `MRB_TT_HAS_BASIC` is meaningless because `MRB_TT_HAS_BASIC` is
no longer used with `MRB_WORD_BOXING` at b2c3d88f.
2019-09-25 18:17:01 +09:00
KOBAYASHI Shuji 5dda4f5da3 Implement all type predicate macros for MRB_WORD_BOXING
The default implementations of type predicate macros use `mrb_type`.
But `mrb_type` with `MRB_WORD_BOXING` isn't very efficient, so the new
implementations avoid `mrb_type`.
2019-09-22 22:36:12 +09:00
Fangrui Song 7f044341f9 Rename MRB_USE_ETEXT_EDATA to MRB_USE_LINK_TIME_RO_DATA_P and support lld linked programs
In lld linked programs, .rodata comes before .text, thus mrb_ro_data_p
will return false for strings in .rodata. Change the lower bound from
_etext to __ehdr_start to catch these cases. This works for ld.bfd, gold
and lld, and it does not have false positives even if .init_array does
not exist.

Remove the branch that uses _edata: strings in .data can be modified so
this is semantically incorrect. Delete the __APPLE__ branch (its
manpages say get_etext() and get_edata() are strongly discouraged).
.init_array has been adopted by most ELF platforms to supersede .ctors.

Neither _etext nor _edata is used, so rename MRB_USE_ETEXT_EDATA to
MRB_USE_EHDR_START.
2019-09-21 17:55:14 -07:00
KOBAYASHI Shuji 19e2cc187b Avoid bit fields in mrb_value; ref b2c3d88f
The changes at b2c3d88f were inappropriate because the memory layout of bit
fields are implementation defined. Therefor, I fixed it not to use bit
fields.
2019-09-06 13:24:35 +09:00
Yukihiro "Matz" Matsumoto 1a4ea94bc7 Fix mrb_immediate_p(MRB_TT_FREE) to return false; ref #4679 2019-08-31 23:19:08 +09:00
KOBAYASHI Shuji b2c3d88fbf Implement mrb_immediate_p macro for MRB_WORD_BOXING
The default implementation of `mrb_immediate_p` uses `mrb_type`. However,
in `MRB_WORD_BOXING`, `mrb_type` has many branches and is inefficient, so
provide an implementation that does not use `mrb_type`.
2019-08-31 16:55:57 +09:00
David Siaw e1e96c0cf4 change doc directory and reduce warnings 2019-08-26 00:23:28 +09:00
David Siaw b5299b1c58 fix up documentation for values 2019-08-18 20:12:44 +09:00
dearblue 302ad847a3 Add customized mrb_ro_data_p()
User definable `mrb_ro_data_p()` functions are available
by defining `MRB_USE_CUSTOM_RO_DATA_P`.

(Limitation) It can not be defined as an inline function.
2019-04-26 21:28:57 +09:00
Yukihiro "Matz" Matsumoto 163a6d01e0 Reorganize defines related to MRB_INLINE; ref #4391 2019-04-24 12:09:16 +09:00
Yukihiro "Matz" Matsumoto 0c5f26e0ff Remove unnecessary mrb_regexp_check() and related functions. 2019-04-24 11:43:05 +09:00
Yukihiro "Matz" Matsumoto 49cb149033 Merge pull request #4391 from dearblue/inlines
Change modifier to `MRB_INLINE` from `static inline`
2019-04-22 21:17:27 +09:00
dearblue 125c3bef19 Add mrb_true_p() and mrb_false_p() macro functions 2019-04-19 22:50:05 +09:00
dearblue 6907e97fa1 Change modifier to MRB_INLINE from static inline 2019-04-19 22:24:22 +09:00
dearblue d1db959cab Fix to defined MRB_SYMBOL_BITSIZE and MRB_SYMBOL_MAX always; ref #4077 2019-02-16 21:24:05 +09:00
YAMAMOTO Masaya acdc2d1f24 Add MRB_WITHOUT_FLOAT 2017-10-11 17:58:11 +09:00
Yukihiro "Matz" Matsumoto d4d99dd6d7 Allow break from a block called by mrb_yield; close #3359
This means #3701 is now OK to merge.
2017-06-16 11:34:11 +09:00
Asmod4n 9057a3f3be Add macOS support to mrb_ro_data_p
This adds macOS support to mrb_ro_data_p, fixes #3636
2017-04-25 20:34:07 +02:00
Yukihiro "Matz" Matsumoto a0fbc46ccd Import locale insensitive strtod() from Ruby1.8; fix #3270
The function was renamed to `mrb_float_read(const char*, char**)`.
2016-12-03 18:47:04 +09:00
Tomasz Dąbrowski b21b02465e asserts checking validity of pointer and TT added for mrb_obj_value
Useful for testing when using boxing on different platforms.
2016-11-21 12:37:45 +01:00
Yukihiro "Matz" Matsumoto 8438792d27 renamed "inline" to "istruct" to represent inline struct; ref #3251 2016-11-17 17:19:49 +09:00
Tomasz Dąbrowski 4cca8bac6b inline structures data type for mruby (MRB_TT_INLINE) (fix #3237)
Inline structures have no instance variables, no finalizer, and offer as much space as possible in RBASIC object. This means 24 bytes on 64-bit platforms and 12 bytes on 32-bit platforms.
mruby-inline-struct gem is only provided for testing.
2016-11-17 17:19:49 +09:00
cremno 30b0100e6c fix VS2010/2012 build
They don't have <inttypes.h>, only <stdint.h>.
2016-03-22 11:46:49 +01:00
Yukihiro "Matz" Matsumoto 7c82bfa7fe mruby-sprintf to use mrb_int formatting macros; ref #3076 2016-01-07 12:23:17 +09:00
Kazuho Oku cd131d18a7 define MRB_PRI? that map to PRI?NN depending on the size of mrb_int 2016-01-06 12:00:56 +09:00
Yukihiro "Matz" Matsumoto 065966dae4 common.h are supposed to be included from other header, so call it with quotes; ref #3032 2015-11-28 00:10:38 +09:00
Yukihiro "Matz" Matsumoto 5c405dea3d include changed from by quotes ("") to by brackets (<>); close #3032 2015-11-27 17:48:23 +09:00
Seba Gamboa 84b70886cd Add block to document mrb_value type 2015-10-20 12:16:46 -03:00
Seba Gamboa e441fdaad8 Merge doc/api/mruby/value.h.md docs 2015-10-08 13:17:31 -03:00
Seba Gamboa a0fe0c40b1 Remove old doxygen tags 2015-10-08 12:29:10 -03:00
Seba Gamboa 88f9770f83 document mrb_nil_value 2015-09-21 14:50:59 -03:00
Seba Gamboa 40bf7bde78 Sorting documentation grouping 2015-09-21 01:48:42 -03:00
Seba Gamboa c127614638 Setting up doxygen groups 2015-09-20 21:14:07 -03:00
Yukihiro "Matz" Matsumoto d77249f006 Merge pull request #2754 from cremno/remove-unnecessary-inttypes.h-inclusion
remove unnecessary <inttypes.h> inclusion
2015-04-03 08:30:44 +09:00
cremno 18fdf7e03f remove unnecessary <inttypes.h> inclusion
The format specifier macros were needed to portably print a mrb_int,
because mrb_raisef() originally called vsnprintf(). It doesn't anymore
since 18b2683b97 and the mrb_int format
specifier macros are already gone.
2015-03-30 21:01:16 +02:00
cremno 6424569a63 MSVC 2015 implements inline keyword
Apparently the C compiler of Visual Studio 2015 CTP6 finally implements
inline as inline and not only as _inline and __inline.
2015-03-30 20:13:23 +02:00
cremno 6f893b5183 re-implement mrb_float_to_str()
The new implementation is backwards incompatible, but I couldn't find
any usage outside mruby and I also couldn't think of a different and
good name.

All ISO C99 printf conversion specifiers for floating point numbers and
an optional precision are supported.

It is largely based on code from the MIT licensed musl libc
(http://www.musl-libc.org/) and its floating point printing is exact
(unlike the current code behind Float#to_s).
2015-02-13 09:33:03 +01:00
Yukihiro "Matz" Matsumoto 6b956f1c1b use __init_array_start to determine readonly data section;
b72e94f used _etext and _edata to distinguish C string literals from heap allocated strings,
but using _edata, global char arrays may be considered as string literals.  to avoid the issue,
we have to use __init_array_start, which might be less portable.  you can still use _edata, by
using MRB_NO_INIT_ARRAY_START.
2014-10-02 09:27:39 +09:00
Yukihiro "Matz" Matsumoto b72e94fa6b mrbconf.h option MRB_USE_ETEXT_EDATA to reduce memory.
on platforms with _etext and _edata, mruby can distinguish string literals so that it avoids memory allocation to copy them.
for example, on my Linux box (x86 32bit), memory consumed by mrbtest decreased from 8,168,203 to 8,078,848 (reduced 88KB).
2014-09-30 23:48:57 +09:00
Yukihiro "Matz" Matsumoto 6057b2e378 change mrb_sym type from uint16_t to uint32_t 2014-09-15 01:48:08 +09:00
Yukihiro "Matz" Matsumoto 9b4ec380d2 use uint16_t instead of short; ref #2568 2014-09-05 00:47:22 +09:00
cremno 3ac4c24534 remove unused MSVC strtoll fallback 2014-08-26 00:52:31 +02:00
cremno b6e27218ad MSVC: add simple (v)snprintf implementation
_snprintf is not C99's snprintf!

This simple implementation, unlike _snprintf,
always null-terminates and returns the expected
return value (in most cases).
Other C99 behaviors (like format specifiers) require
adding a complete snprintf implementation.
Do we want or need that?

The same applies to vsnprintf (aka _vsnprintf).
2014-08-03 21:15:48 +02:00
Yukihiro "Matz" Matsumoto 206f89e209 add MRB_API modifiers to mruby API functions 2014-08-04 00:47:08 +09:00
Yukihiro "Matz" Matsumoto 5e5fad2f25 fix typo with MRB_INT16; fix #2495 2014-08-03 20:30:29 +09:00
Jonas Kulla ec606e3aa7 Silence "unused parameter" warnings in C++
This has been done already, but the fixes were accidentally
removed in 249f05e7d7.
2014-07-23 21:40:15 +02:00
take_cheeze 3c96602574 Use MRB_TT_EXCEPTION in exception object. 2014-07-21 23:09:13 +09:00