Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
dd925578
Commit
dd925578
authored
Sep 21, 2015
by
Seba Gamboa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort compiler macros around
parent
40bf7bde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
31 deletions
+92
-31
include/mruby.h
include/mruby.h
+49
-21
include/mruby/common.h
include/mruby/common.h
+43
-10
No files found.
include/mruby.h
View file @
dd925578
...
...
@@ -39,7 +39,6 @@
/**
* @file mruby.h
* @brief Main header of mruby C API. Include this first.
* @defgroup mruby MRuby C API
* @{
*/
...
...
@@ -57,11 +56,13 @@ struct mrb_irep;
struct
mrb_state
;
/**
* Function pointer type of custom allocator used in mrb_open_allocf.
* Function pointer type of custom allocator used in
@ref
mrb_open_allocf.
*
* The function pointing it must behave similarly as realloc except:
* - If ptr is NULL it must allocate new space.
* - If s is NULL, ptr must be freed.
*
* See @ref mrb_default_allocf for the default implementation.
*/
typedef
void
*
(
*
mrb_allocf
)
(
struct
mrb_state
*
mrb
,
void
*
,
size_t
,
void
*
ud
);
...
...
@@ -205,18 +206,6 @@ typedef struct mrb_state {
mrb_int
atexit_stack_len
;
}
mrb_state
;
#if __STDC_VERSION__ >= 201112L
# define mrb_noreturn _Noreturn
#elif defined __GNUC__ && !defined __STRICT_ANSI__
# define mrb_noreturn __attribute__((noreturn))
# define mrb_deprecated __attribute__((deprecated))
#elif defined _MSC_VER
# define mrb_noreturn __declspec(noreturn)
# define mrb_deprecated __declspec(deprecated)
#else
# define mrb_noreturn
# define mrb_deprecated
#endif
typedef
mrb_value
(
*
mrb_func_t
)(
mrb_state
*
mrb
,
mrb_value
);
...
...
@@ -278,8 +267,29 @@ MRB_API void mrb_define_module_function(mrb_state*, struct RClass*, const char*,
MRB_API
void
mrb_define_const
(
mrb_state
*
,
struct
RClass
*
,
const
char
*
name
,
mrb_value
);
MRB_API
void
mrb_undef_method
(
mrb_state
*
,
struct
RClass
*
,
const
char
*
);
MRB_API
void
mrb_undef_class_method
(
mrb_state
*
,
struct
RClass
*
,
const
char
*
);
/**
* Initialize a new object instace of c class.
*
* @param mrb
* The current mruby state.
* @param c
* Reference to the class of the new object.
* @param argc
* Number of arguments in argv
* @param argv
* Array of @ref mrb_value "mrb_values" to initialize the object
* @returns
* The newly initialized object
*/
MRB_API
mrb_value
mrb_obj_new
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_int
argc
,
const
mrb_value
*
argv
);
#define mrb_class_new_instance(mrb,argc,argv,c) mrb_obj_new(mrb,c,argc,argv)
/** See @ref mrb_obj_new */
MRB_INLINE
mrb_value
mrb_class_new_instance
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
mrb_int
argc
,
const
mrb_value
*
argv
)
{
return
mrb_obj_new
(
mrb
,
c
,
argc
,
argv
);
}
MRB_API
mrb_value
mrb_instance_new
(
mrb_state
*
mrb
,
mrb_value
cv
);
MRB_API
struct
RClass
*
mrb_class_new
(
mrb_state
*
mrb
,
struct
RClass
*
super
);
MRB_API
struct
RClass
*
mrb_module_new
(
mrb_state
*
mrb
);
...
...
@@ -464,19 +474,32 @@ char* mrb_locale_from_utf8(const char *p, size_t len);
*/
MRB_API
mrb_state
*
mrb_open
(
void
);
/**
* Create new mrb_state with custom allocator.
* Create new mrb_state with custom allocator
s
.
*
* @param f
* Reference to the allocation function.
* @param ud
* will be passed to custom allocator f. If user data isn't required just
* pass NULL. Function pointer f must satisfy requirements of its type.
* User data will be passed to custom allocator f.
* If user data isn't required just pass NULL.
* @returns
* Pointer to the newly created mrb_state.
*/
MRB_API
mrb_state
*
mrb_open_allocf
(
mrb_allocf
f
,
void
*
ud
);
/**
* Create new mrb_state with just the MRuby core
*
* @param f
* Reference to the allocation function.
* Use mrb_default_allocf for the default
* @param ud
* User data will be passed to custom allocator f.
* If user data isn't required just pass NULL.
* @returns
* Pointer to the newly created mrb_state.
*/
MRB_API
mrb_state
*
mrb_open_allocf
(
mrb_allocf
,
void
*
ud
);
MRB_API
mrb_state
*
mrb_open_core
(
mrb_allocf
,
void
*
ud
);
MRB_API
mrb_state
*
mrb_open_core
(
mrb_allocf
f
,
void
*
ud
);
/**
* Closes and frees a mrb_state.
...
...
@@ -486,6 +509,11 @@ MRB_API mrb_state* mrb_open_core(mrb_allocf, void *ud);
*/
MRB_API
void
mrb_close
(
mrb_state
*
mrb
);
/**
* The default allocation function.
*
* @ref mrb_allocf
*/
MRB_API
void
*
mrb_default_allocf
(
mrb_state
*
,
void
*
,
size_t
,
void
*
);
MRB_API
mrb_value
mrb_top_self
(
mrb_state
*
);
...
...
include/mruby/common.h
View file @
dd925578
...
...
@@ -7,29 +7,62 @@
#ifndef MRUBY_COMMON_H
#define MRUBY_COMMON_H
/**
* @file mruby/common.h
* @defgroup mruby_common Shared compiler macros
* @ingroup mruby
* @{
*/
#ifdef __cplusplus
/** Start declarations in C++ mode */
#define MRB_BEGIN_DECL extern "C" {
/** End declarations in C++ mode */
#define MRB_END_DECL }
# define MRB_BEGIN_DECL extern "C" {
# define MRB_END_DECL }
#else
/** Start declarations in C mode */
#
define MRB_BEGIN_DECL
/* empty */
#
define MRB_BEGIN_DECL
/** End declarations in C mode */
#define MRB_END_DECL
/* empty */
# define MRB_END_DECL
#endif
/** Declare a function that never returns. */
#if __STDC_VERSION__ >= 201112L
# define mrb_noreturn _Noreturn
#elif defined __GNUC__ && !defined __STRICT_ANSI__
# define mrb_noreturn __attribute__((noreturn))
#elif defined _MSC_VER
# define mrb_noreturn __declspec(noreturn)
#else
# define mrb_noreturn
#endif
/** Mark a function as deprecated. */
#if defined __GNUC__ && !defined __STRICT_ANSI__
# define mrb_deprecated __attribute__((deprecated))
#elif defined _MSC_VER
# define mrb_deprecated __declspec(deprecated)
#else
# define mrb_deprecated
#endif
/** Declare a function as always inlined. */
#if defined(_MSC_VER)
# define MRB_INLINE static __inline
#else
# define MRB_INLINE static inline
#endif
/** Declare a public MRuby API function. */
#if defined(MRB_BUILD_AS_DLL)
#if defined(MRB_CORE) || defined(MRB_LIB)
#define MRB_API __declspec(dllexport)
#
define MRB_API __declspec(dllexport)
#else
#define MRB_API __declspec(dllimport)
#
define MRB_API __declspec(dllimport)
#endif
#else
#define MRB_API extern
#
define MRB_API extern
#endif
MRB_END_DECL
/** @} */
#endif
/* MRUBY_COMMON_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment