1 .. Copyright (C) 2014-2024 Free Software Foundation, Inc.
2 Originally contributed by David Malcolm <dmalcolm@redhat.com>
4 This is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see
16 <https://www.gnu.org/licenses/>.
23 .. type:: gcc_jit_object
25 Almost every entity in the API (with the exception of
26 :c:expr:`gcc_jit_context *` and :c:expr:`gcc_jit_result *`) is a
27 "contextual" object, a :c:expr:`gcc_jit_object *`
31 * is associated with a :c:expr:`gcc_jit_context *`.
33 * is automatically cleaned up for you when its context is released so
34 you don't need to manually track and cleanup all objects, just the
37 Although the API is C-based, there is a form of class hierarchy, which
51 +- gcc_jit_extended_asm
53 There are casting methods for upcasting from subclasses to parent classes.
54 For example, :c:func:`gcc_jit_type_as_object`:
58 gcc_jit_object *obj = gcc_jit_type_as_object (int_type);
60 The object "base class" has the following operations:
62 .. function:: gcc_jit_context *gcc_jit_object_get_context (gcc_jit_object *obj)
64 Which context is "obj" within?
67 .. function:: const char *gcc_jit_object_get_debug_string (gcc_jit_object *obj)
69 Generate a human-readable description for the given object.
75 printf ("obj: %s\n", gcc_jit_object_get_debug_string (obj));
77 might give this text on stdout:
85 If you call this on an object, the `const char *` buffer is allocated
86 and generated on the first call for that object, and the buffer will
87 have the same lifetime as the object i.e. it will exist until the
88 object's context is released.