Skip to content

Commit

Permalink
* eval.c: Add doxygen comments.
Browse files Browse the repository at this point in the history
* ruby.c: ditto.

* thread_pthread.c: ditto

* version.c: ditto.

* vm_core.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
yugui committed Jun 14, 2012
1 parent e9e6031 commit f8601bd
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
@@ -1,3 +1,15 @@
Thu Jun 14 10:39:48 2012 Yuki Yugui Sonoda <yugui@google.com>

* eval.c: Add doxygen comments.

* ruby.c: ditto.

* thread_pthread.c: ditto

* version.c: ditto.

* vm_core.h: ditto.

Thu Jun 14 10:16:07 2012 NARUSE, Yui <naruse@ruby-lang.org>

* configure.in: revert r36071 and add NetBSD to blacklist of -ansi.
Expand Down
45 changes: 45 additions & 0 deletions eval.c
Expand Up @@ -61,6 +61,16 @@ ruby_init(void)
GET_VM()->running = 1;
}

/*! Processes command line arguments and compiles the Ruby source to execute.
*
* This function does:
* \li Processses the given command line flags and arguments for ruby(1)
* \li compiles the source code from the given argument, -e or stdin, and
* \li returns the compiled source as an opaque pointer to an internal data structure
*
* @return an opaque pointer to the compiled source or an internal special value.
* @sa ruby_executable_node().
*/
void *
ruby_options(int argc, char **argv)
{
Expand Down Expand Up @@ -101,13 +111,30 @@ ruby_finalize_1(void)
rb_gc_call_finalizer_at_exit();
}

/** Runs the VM finalization processes.
*
* <code>END{}</code> and procs registered by <code>Kernel.#at_ext</code> are
* executed here. See the Ruby language spec for more details.
*
* @note This function is allowed to raise an exception if an error occurred.
*/
void
ruby_finalize(void)
{
ruby_finalize_0();
ruby_finalize_1();
}

/** Destructs the VM.
*
* Runs the VM finalization processes as well as ruby_finalize(), and frees
* resources used by the VM.
*
* @param ex Default value to the return value.
* @return If an error occured returns a non-zero. If otherwise, reurns the
* given ex.
* @note This function does not raise any exception.
*/
int
ruby_cleanup(volatile int ex)
{
Expand Down Expand Up @@ -210,12 +237,25 @@ ruby_exec_internal(void *n)
return state;
}

/*! Calls ruby_cleanup() and exits the process */
void
ruby_stop(int ex)
{
exit(ruby_cleanup(ex));
}

/*! Checks the return value of ruby_options().
* @param n return value of ruby_options().
* @param status pointer to the exit status of this process.
*
* ruby_options() sometimes returns a special value to indicate this process
* should immediately exit. This function checks if the case. Also stores the
* exit status that the caller have to pass to exit(3) into
* <code>*status</code>.
*
* @retval non-zero if the given opaque pointer is actually a compiled source.
* @retval 0 if the given value is such a special value.
*/
int
ruby_executable_node(void *n, int *status)
{
Expand All @@ -233,6 +273,10 @@ ruby_executable_node(void *n, int *status)
return FALSE;
}

/*! Runs the given compiled source and exits this process.
* @retval 0 if successfully run thhe source
* @retval non-zero if an error occurred.
*/
int
ruby_run_node(void *n)
{
Expand All @@ -244,6 +288,7 @@ ruby_run_node(void *n)
return ruby_cleanup(ruby_exec_node(n));
}

/*! Runs the given compiled source */
int
ruby_exec_node(void *n)
{
Expand Down
12 changes: 12 additions & 0 deletions ruby.c
Expand Up @@ -1706,6 +1706,11 @@ set_arg0(VALUE val, ID id)
rb_progname = rb_obj_freeze(rb_external_str_new(s, i));
}

/*! Sets the current script name to this value.
*
* This is similiar to <code>$0 = name</code> in Ruby level but also affects
* <code>Method#location</code> and others.
*/
void
ruby_script(const char *name)
{
Expand Down Expand Up @@ -1765,6 +1770,7 @@ opt_W_getter(ID id, void *data)
}
}

/*! Defines built-in variables */
void
ruby_prog_init(void)
{
Expand Down Expand Up @@ -1860,6 +1866,12 @@ fill_standard_fds(void)
}
}

/*! Initializes the process for ruby(1).
*
* This function assumes this process is ruby(1) and it has just started.
* Usually programs that embeds CRuby interpreter should not call this function,
* and should do their own initialization.
*/
void
ruby_sysinit(int *argc, char ***argv)
{
Expand Down
4 changes: 4 additions & 0 deletions thread_pthread.c
Expand Up @@ -581,6 +581,10 @@ extern void *STACK_END_ADDRESS;
#endif

#undef ruby_init_stack
/* Set stack bottom of Ruby implementation.
*
* You must call this function before any heap allocation by Ruby implementation.
* Or GC will break living objects */
void
ruby_init_stack(volatile VALUE *addr
#ifdef __ia64
Expand Down
5 changes: 5 additions & 0 deletions version.c
Expand Up @@ -96,6 +96,7 @@ const char ruby_initial_load_paths[] =
#endif
"";

/*! Defines platform-depended Ruby-level constants */
void
Init_version(void)
{
Expand Down Expand Up @@ -134,13 +135,17 @@ Init_version(void)
rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
}

/*! Prints the version information of the CRuby interpreter to stdout. */
void
ruby_show_version(void)
{
PRINT(description);
fflush(stdout);
}

/*! Prints the copyright notice of the CRuby interpreter to stdout and \em exits
* this process successfully.
*/
void
ruby_show_copyright(void)
{
Expand Down
11 changes: 11 additions & 0 deletions vm_core.h
Expand Up @@ -458,7 +458,18 @@ typedef struct rb_thread_struct {
struct rb_vm_tag *tag;
struct rb_vm_protect_tag *protect_tag;

/*! Thread-local state of evaluation context.
*
* If negative, this thread is evaluating the main program.
* If positive, this thread is evaluating a program under Kernel::eval
* family.
*/
int parse_in_eval;

/*! Thread-local state of compiling context.
*
* If non-zero, the parser does not automatically print error messages to
* stderr. */
int mild_compile_error;

/* storage */
Expand Down

0 comments on commit f8601bd

Please sign in to comment.