Alien-LibJIT
view release on metacpan or search on metacpan
libjit/jit/jit-objmodel.c view on Meta::CPAN
/*
* jit-objmodel.c - Interfaces for pluggable object models.
*
* Copyright (C) 2004 Southern Storm Software, Pty Ltd.
*
* This file is part of the libjit library.
*
* The libjit library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 2.1 of
* the License, or (at your option) any later version.
*
* The libjit library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the libjit library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <jit/jit.h>
#include <jit/jit-objmodel-private.h>
/*@
The @code{libjit} library does not implement a particular object model
of its own, so that it is generic across bytecode formats and front end
languages. However, it does provide support for plugging object models
into the JIT process, and for transparently proxying to external libraries
that may use a foreign object model.
There may be more than one object model active in the system at any
one time. For example, a JVM implementation might have a primary
object model for its own use, and a secondary object model for
calling methods in an imported Objective C library.
The functions in this section support pluggable object models. There is
no requirement that you use them: you can ignore them and use the rest
of @code{libjit} directly if you wish.
To create a new object model, you would include the file
@code{<jit/jit-objmodel-private.h>} and create an instance of
the @code{struct jit_objmodel} type. This instance should be
populated with pointers to your object model's handler routines.
You then use functions from the list below to access the
object model.
Some standard object models are distributed with @code{libjit}
for invoking methods in external C++, Objective C, GCJ, and JNI
based libraries.
@*/
/*@
* @deftypefun void jitom_destroy_model (jit_objmodel_t @var{model})
* Destroy an object model handler that is no longer required.
* It is undefined what will happen to the objects and classes
* that were being managed by the object model: they may still persist,
* or they may now be invalid.
* @end deftypefun
@*/
void jitom_destroy_model(jit_objmodel_t model)
{
if(model)
{
(*(model->destroy_model))(model);
}
}
/*@
* @deftypefun jitom_class_t jitom_get_class_by_name (jit_objmodel_t @var{model}, const char *@var{name})
* Get the class descriptor from the object model for a class
* called @var{name}. Returns NULL if the class was not found.
* If the name includes namespace or nested scope qualifiers,
* they must be separated by periods (@code{.}).
* @end deftypefun
@*/
jitom_class_t jitom_get_class_by_name(jit_objmodel_t model, const char *name)
{
return (*(model->get_class_by_name))(model, name);
}
/*@
* @deftypefun {char *} jitom_class_get_name (jit_objmodel_t @var{model}, jitom_class_t @var{klass})
* Get the name of a particular class. The return value must be freed
* with @code{jit_free}.
* @end deftypefun
@*/
char *jitom_class_get_name(jit_objmodel_t model, jitom_class_t klass)
( run in 0.672 second using v1.01-cache-2.11-cpan-4991d5b9bd9 )