From RTSC-Pedia
revision tip
LANDSCAPE orientationC Language Binding
Compile-time & run-time elements introduced by RTSC
Common public functions
The following functions are part of the public interface provided by all modules.
In addition, modules that support instance objects also provide the following functions.
Modules that inherit from interfaces provide the following type-safe conversion operations.
Internal functions
The following functions are "internal functions" implemented by modules in order to support module instance object creation and deletion (if necessary) as well as the common public functions listed above.
Module-specific functions
Module-wide functions
Module-wide functions. The RTSC IDL allows you to specify "module-wide" functions; functions that are not associated with any particular instance that may be managed by the module. For example, the LoggerBuf_flushAll() function is declared in LoggerBuf.xdc and implemented in LoggerBuf.c as follows:
| LoggerBuf.xdc |
| module LoggerBuf {
Void flushAll();
:
} |
| | LoggerBuf.c |
| #include "package/internal/LoggerBuf.xdc.h"
Void LoggerBuf_flushAll(Void)
{
:
} |
|
Clients of LoggerBuf_flushAll simply include the LoggerBuf module's public header and call LoggerBuf_flushAll() using the arguments specified in LoggerBuf.xdc.
| client.c |
| #include <xdc/runtime/LoggerBuf.h>
:
LoggerBuf_flushAll(); |
Instance functions
Instance functions. The RTSC IDL allows you to specify module functions which operate on an instance type managed by the module. For example, the HeapMin_alloc() function is declared in HeapMin.xdc and implemented in HeapMin.c as follows:
| HeapMin.xdc |
| module HeapMin {
instance:
Void free(Ptr block, SizeT size);
:
} |
| | HeapMin.c |
| #include "package/internal/HeapMin.xdc.h"
Void HeapMin_free(HeapMin_Object *obj, Ptr block, SizeT size)
{
:
} |
|
Clients of HeapMin_free simply include the HeapMin module's public header and call HeapMin_free() using the arguments specified in HeapMin.xdc after passing an instance handle as the first argument.
| client.c |
| #include <xdc/runtime/HeapMin.h>
:
HeapMin_Handle heap;
HeapMin_free(heap, buf, size); |
Variable arguments support
Variable arguments support. The RTSC IDL allows you to specify functions which, like printf(), accept a variable number of arguments. The syntax used in the IDL is essentially the same as that specified by ANSI C. For example, the System_printf() function is declared in System.xdc and implemented in System.c as follows:
| System.xdc |
| module System {
Int printf(String fmt, ...);
:
} |
| | System.c |
| #include "package/internal/System.xdc.h"
Int System_printf_va(String fmt, VaList va)
{
:
} |
|
Clients of System_printf simply include the System module's public header and call System_printf() using the arguments specified in System.xdc.
| client.c |
| #include <xdc/runtime/System.h>
:
System_printf("x = %d, y = %d\n", 1, 2); |
Module Binary Contract
The following topics describe the binary data structures and symbols created to support the bindings described above. To maintain compatibility with packages created using different versions of XDCtools, these data structures and their names must not change. It's important to note, however, that while the data structures defined in a module's headers can not change, the data structures defined in the generated configuration files can (and often do) change from release to release of XDCtools.
Copyright © 2008 The Eclipse Foundation. All Rights Reserved