|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /proc/21572/root/usr/share/gtk-doc/html/gobject/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <title>Background</title> <meta name="generator" content="DocBook XSL Stylesheets V1.69.1"> <link rel="start" href="index.html" title="GObject Reference Manual"> <link rel="up" href="pt01.html" title="Part I. Concepts"> <link rel="prev" href="pt01.html" title="Part I. Concepts"> <link rel="next" href="ch01s02.html" title="Exporting a C API"> <meta name="generator" content="GTK-Doc V1.6 (XML mode)"> <link rel="stylesheet" href="style.css" type="text/css"> <link rel="preface" href="pr01.html" title="Introduction"> <link rel="part" href="pt01.html" title="Part I. Concepts"> <link rel="chapter" href="ch01.html" title="Background"> <link rel="chapter" href="ch02.html" title="The Glib Dynamic Type System"> <link rel="chapter" href="chapter-gobject.html" title="The GObject base class"> <link rel="chapter" href="chapter-signal.html" title="The GObject messaging system"> <link rel="reference" href="rn01.html" title="API Reference"> <link rel="reference" href="rn02.html" title="Tools Reference"> <link rel="part" href="pt02.html" title="Part IV. Tutorial"> <link rel="chapter" href="howto-gobject.html" title="How To define and implement a new GObject?"> <link rel="chapter" href="howto-interface.html" title="How To define and implement Interfaces?"> <link rel="chapter" href="howto-signals.html" title="Howto create and use signals"> <link rel="part" href="pt03.html" title="Part V. Related Tools"> <link rel="chapter" href="tools-gob.html" title="GObject builder"> <link rel="chapter" href="tools-ginspector.html" title="Graphical inspection of Gobjects"> <link rel="chapter" href="tools-refdb.html" title="Debugging reference count problems"> <link rel="chapter" href="tools-gtkdoc.html" title="Writing API docs"> <link rel="index" href="ix01.html" title="Index"> <link rel="index" href="ix02.html" title="Index of deprecated symbols"> <link rel="index" href="ix03.html" title="Index of new symbols in 2.2"> <link rel="index" href="ix04.html" title="Index of new symbols in 2.4"> <link rel="index" href="ix05.html" title="Index of new symbols in 2.6"> <link rel="index" href="ix06.html" title="Index of new symbols in 2.8"> <link rel="index" href="ix07.html" title="Index of new symbols in 2.10"> <link rel="index" href="ix08.html" title="Index of new symbols in 2.12"> </head> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"> <td><a accesskey="p" href="pt01.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> <td><a accesskey="u" href="pt01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> <th width="100%" align="center">GObject Reference Manual</th> <td><a accesskey="n" href="ch01s02.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> </tr></table> <div class="chapter" lang="en"> <div class="titlepage"><div><div><h2 class="title"> <a name="id2605368"></a>Background</h2></div></div></div> <div class="toc"><dl> <dt><span class="sect1"><a href="ch01.html#id2605356">Data types and programming</a></span></dt> <dt><span class="sect1"><a href="ch01s02.html">Exporting a C API</a></span></dt> </dl></div> <p> GObject, and its lower-level type system, GType, are used by GTK+ and most Gnome libraries to provide: </p> <div class="itemizedlist"><ul type="disc"> <li><p>object-oriented C-based APIs and</p></li> <li><p>automatic transparent API bindings to other compiled or interpreted languages.</p></li> </ul></div> <p> </p> <p>A lot of programmers are used to work with compiled-only or dynamically interpreted-only languages and do not understand the challenges associated with cross-language interoperability. This introduction tries to provide an insight into these challenges. describes briefly the solution choosen by GLib. </p> <p>The following chapters go into greater detail into how GType and GObject work and how you can use them as a C programmer. It is useful to keep in mind that allowing access to C objects from other interpreted languages was one of the major design goals: this can often explain the sometimes rather convoluted APIs and features present in this library. </p> <div class="sect1" lang="en"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> <a name="id2605356"></a>Data types and programming</h2></div></div></div> <p> One could say (I have seen such definitions used in some textbooks on programming language theory) that a programming language is merely a way to create data types and manipulate them. Most languages provide a number of language-native types and a few primitives to create more complex types based on these primitive types. </p> <p> In C, the language provides types such as <span class="emphasis"><em>char</em></span>, <span class="emphasis"><em>long</em></span>, <span class="emphasis"><em>pointer</em></span>. During compilation of C code, the compiler maps these language types to the compiler's target architecture machine types. If you are using a C interpreter (I have never seen one myself but it is possible :), the interpreter (the program which interprets the source code and executes it) maps the language types to the machine types of the target machine at runtime, during the program execution (or just before execution if it uses a Just In Time compiler engine). </p> <p>Perl and Python which are interpreted languages do not really provide type definitions similar to those used by C. Perl and Python programmers manipulate variables and the type of the variables is decided only upon the first assignment or upon the first use which forces a type on the variable. The interpreter also often provides a lot of automatic conversions from one type to the other. For example, in Perl, a variable which holds an integer can be automatically converted to a string given the required context: </p> <pre class="programlisting"> my $tmp = 10; print "this is an integer converted to a string:" . $tmp . "\n"; </pre> <p> Of course, it is also often possible to explicitely specify conversions when the default conversions provided by the language are not intuitive. </p> </div> </div> </body> </html>