use `extern class` and dotted notation for extern call and casts.
Signed-off-by: Jean Privat <jean@pryen.org>
# Returns null on success
fun file_rename_to(dest: String): nullable String import String.to_cstring,
- NativeString.to_s, String as nullable `{
+ NativeString.to_s, String.as nullable `{
int res = rename(String_to_cstring(recv), String_to_cstring(dest));
if (res == 0) return null_String();
return String_as_nullable(NativeString_to_s(strerror(errno)));
end
# Defining my object type Monkey, which is, in a low level, a pointer to a C struct (CMonkey)
-extern Monkey `{ CMonkey * `}
+extern class Monkey `{ CMonkey * `}
new `{
CMonkey *monkey = malloc( sizeof(CMonkey) );
`}
# CURL Extern Type, reproduce CURL low level behaviors
-extern CCurl `{ CURL * `}
+extern class CCurl `{ CURL * `}
# Constructor, CURL low level initializer
new easy_init `{ return curl_easy_init(); `}
# Check for correct initialization
end
# FILE Extern type, reproduce basic FILE I/O
-extern OFile `{ FILE* `}
+extern class OFile `{ FILE* `}
# Open / Create a file from given name
new open(str: NativeString) `{ return fopen(str, "wb"); `}
# Check for File validity
end
# Extern Type to reproduce Enum of available Callback type
-extern CURLCallbackType `{ CURLcallbackType `}
+extern class CURLCallbackType `{ CURLcallbackType `}
new header `{ return CURLcallbackTypeHeader; `}
new body `{ return CURLcallbackTypeBody; `}
new stream `{ return CURLcallbackTypeStream; `}
end
# CURL Code binding and helpers
-extern CURLCode `{ CURLcode `}
+extern class CURLCode `{ CURLcode `}
new unknown_option `{ return CURLE_UNKNOWN_OPTION; `}
new unsupported_protocol `{ return CURLE_UNSUPPORTED_PROTOCOL; `}
new ok `{ return CURLE_OK; `}
end
# Extern Type of the Linked list type of CURL
-extern CURLSList `{ struct curl_slist * `}
+extern class CURLSList `{ struct curl_slist * `}
# Empty constructor which allow us to avoid the use of Nit NULLABLE type
private new `{ return NULL; `}
# Constructor allow us to get list instancied by appending an element inside.
end
# Reproduce Enum of available CURL SList information, used for CCurl.easy_getinfo
-extern CURLInfoSList `{ CURLINFO `}
+extern class CURLInfoSList `{ CURLINFO `}
new ssl_engines `{ return CURLINFO_SSL_ENGINES; `}
new cookielist `{ return CURLINFO_COOKIELIST; `}
end
# Reproduce Enum of available CURL Long information, used for CCurl.easy_getinfo
-extern CURLInfoLong `{ CURLINFO `}
+extern class CURLInfoLong `{ CURLINFO `}
new response_code `{ return CURLINFO_RESPONSE_CODE; `}
new header_size `{ return CURLINFO_HEADER_SIZE; `}
new http_connectcode `{ return CURLINFO_HTTP_CONNECTCODE; `}
end
# Reproduce Enum of available CURL Double information, used for CCurl.easy_getinfo
-extern CURLInfoDouble `{ CURLINFO `}
+extern class CURLInfoDouble `{ CURLINFO `}
new total_time `{ return CURLINFO_TOTAL_TIME; `}
new namelookup_time `{ return CURLINFO_NAMELOOKUP_TIME; `}
new connect_time `{ return CURLINFO_CONNECT_TIME; `}
end
# Reproduce Enum of available CURL Chars information, used for CCurl.easy_getinfo
-extern CURLInfoChars `{ CURLINFO `}
+extern class CURLInfoChars `{ CURLINFO `}
new content_type `{ return CURLINFO_CONTENT_TYPE; `}
new effective_url `{ return CURLINFO_EFFECTIVE_URL; `}
new redirect_url `{ return CURLINFO_REDIRECT_URL; `}
end
# Reproduce Enum of HTTP Status Code
-extern CURLStatusCode `{ int `}
+extern class CURLStatusCode `{ int `}
new proceed `{ return 100; `}
new switching_protocols `{ return 101; `}
new ok `{ return 200; `}
end
# Reproduce Enum of CURL Options usable, used for CCurl.easy_setopt
-extern CURLOption `{ CURLoption `}
+extern class CURLOption `{ CURLoption `}
new write_function `{ return CURLOPT_WRITEFUNCTION; `}
new write_data `{ return CURLOPT_WRITEDATA; `}
# new `{ return CURLOPT_FILE; `}
`}
# A curse windows
-extern Window `{WINDOW *`}
+extern class Window `{WINDOW *`}
# Initialize the screen
new `{
WINDOW *res;
#fun get_configs: nullable Array[EGLConfig] import Array[EGLConfig].with_native `{
# Returns some configs compatible with the specified `attributes`
- fun choose_configs(attribs: Array[Int]): nullable Array[EGLConfig] import Array[Int].length, Array[Int].[], Array[EGLConfig], Array[EGLConfig].add, Array[EGLConfig] as nullable, report_egl_error `{
+ fun choose_configs(attribs: Array[Int]): nullable Array[EGLConfig] import Array[Int].length, Array[Int].[], Array[EGLConfig], Array[EGLConfig].add, Array[EGLConfig].as nullable, report_egl_error `{
EGLConfig *configs;
int n_configs;
int n_attribs = Array_of_Int_length(attribs);
#enum GdkGravity
#Defines the reference point of a window and the meaning of coordinates passed to gtk_window_move().
#@https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#GdkGravity
-extern GdkGravity `{GdkGravity`}
+extern class GdkGravity `{GdkGravity`}
#The reference point is at the top left corner.
new north_west `{ return GDK_GRAVITY_NORTH_WEST; `}
#enum GdkGWindowEdge
#Determines a window edge or corner.
#@https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#GdkWindowEdge
-extern GdkWindowEdge `{GdkWindowEdge`}
+extern class GdkWindowEdge `{GdkWindowEdge`}
#The top left corner.
new north_west `{ return GDK_WINDOW_EDGE_NORTH_WEST; `}
#A widget used to guide users through multi-step operations
#@https://developer.gnome.org/gtk3/stable/GtkAssistant.html
-extern GtkAssistant `{GtkAssistant *`}
+extern class GtkAssistant `{GtkAssistant *`}
super GtkWindow
new is extern `{
#enum GtkAssistantPageType
#An enum for determining the page role inside the GtkAssistant. It's used to handle buttons sensitivity and visibility.
#@https://developer.gnome.org/gtk3/stable/GtkAssistant.html#GtkAssistantPageType
-extern GtkAssistantPageType `{GtkAssistantPageType`}
+extern class GtkAssistantPageType `{GtkAssistantPageType`}
#The page has regular contents. Both the Back and forward buttons will be shown.
new content `{ return GTK_ASSISTANT_PAGE_CONTENT; `}
fun signal( sender : GtkWidget, user_data : nullable Object ) is abstract
end
-extern GdkEvent `{GdkEvent *`}
+extern class GdkEvent `{GdkEvent *`}
end
#Base class for all widgets
#@https://developer.gnome.org/gtk3/stable/GtkWidget.html
-extern GtkWidget `{GtkWidget *`}
+extern class GtkWidget `{GtkWidget *`}
fun show_all is extern `{ gtk_widget_show_all( recv ); `}
- fun signal_connect( signal_name : String, to_call : GtkCallable, user_data : nullable Object ) is extern import String.to_cstring, GtkCallable.signal, Object as not nullable `{
+ fun signal_connect( signal_name : String, to_call : GtkCallable, user_data : nullable Object ) is extern import String.to_cstring, GtkCallable.signal, Object.as not nullable `{
NitGtkSignal *data = malloc( sizeof(NitGtkSignal) );
GtkCallable_incr_ref( to_call );
#Base class for widgets which contain other widgets
#@https://developer.gnome.org/gtk3/stable/GtkContainer.html
-extern GtkContainer `{GtkContainer *`}
+extern class GtkContainer `{GtkContainer *`}
super GtkWidget
# Add a widget to the container
#A container with just one child
#@https://developer.gnome.org/gtk3/stable/GtkBin.html
-extern GtkBin `{GtkBin *`}
+extern class GtkBin `{GtkBin *`}
super GtkContainer
fun child : GtkWidget is extern `{
#Toplevel which can contain other widgets
#@https://developer.gnome.org/gtk3/stable/GtkWindow.html
-extern GtkWindow `{GtkWindow *`}
+extern class GtkWindow `{GtkWindow *`}
super GtkBin
new ( flag : Int ) is extern `{
#A bin with a decorative frame and optional label
#https://developer.gnome.org/gtk3/stable/GtkFrame.html
-extern GtkFrame `{GtkFrame *`}
+extern class GtkFrame `{GtkFrame *`}
super GtkBin
new ( lbl : String ) is extern import String.to_cstring`{
#Pack widgets in a rows and columns
#@https://developer.gnome.org/gtk3/3.3/GtkGrid.html
-extern GtkGrid `{GtkGrid *`}
+extern class GtkGrid `{GtkGrid *`}
super GtkContainer
# Create a grid with a fixed number of rows and columns
#The tree interface used by GtkTreeView
#@https://developer.gnome.org/gtk3/stable/GtkTreeModel.html
-extern GtkTreeModel `{GtkTreeModel *`}
+extern class GtkTreeModel `{GtkTreeModel *`}
end
#An abstract class for laying out GtkCellRenderers
#@https://developer.gnome.org/gtk3/stable/GtkCellArea.html
-extern GtkCellArea `{GtkCellArea *`}
+extern class GtkCellArea `{GtkCellArea *`}
end
#Base class for widgets with alignments and padding
#@https://developer.gnome.org/gtk3/3.2/GtkMisc.html
-extern GtkMisc `{GtkMisc *`}
+extern class GtkMisc `{GtkMisc *`}
super GtkWidget
fun alignment : GtkAlignment is abstract
#A single line text entry field
#@https://developer.gnome.org/gtk3/3.2/GtkEntry.html
-extern GtkEntry `{GtkEntry *`}
+extern class GtkEntry `{GtkEntry *`}
super GtkWidget
new is extern `{
#Base class for widgets which visualize an adjustment
#@https://developer.gnome.org/gtk3/3.2/GtkRange.html
-extern GtkRange `{GtkRange *`}
+extern class GtkRange `{GtkRange *`}
super GtkWidget
#Gets the current position of the fill level indicator.
#A slider widget for selecting a value from a range
#@https://developer.gnome.org/gtk3/3.2/GtkScale.html
-extern GtkScale `{GtkScale *`}
+extern class GtkScale `{GtkScale *`}
super GtkRange
new ( orientation : GtkOrientation, adjustment : GtkAdjustment ) is extern `{
#A scrollbar
#@https://developer.gnome.org/gtk3/3.2/GtkScrollbar.html
-extern GtkScrollbar `{GtkScrollbar *`}
+extern class GtkScrollbar `{GtkScrollbar *`}
super GtkRange
new ( orientation : GtkOrientation, adjustment : GtkAdjustment ) is extern `{
#A widget that displays a small to medium amount of text
#@https://developer.gnome.org/gtk3/3.2/GtkLabel.html
-extern GtkLabel `{GtkLabel *`}
+extern class GtkLabel `{GtkLabel *`}
super GtkMisc
# Create a GtkLabel with text
#A widget displaying an image
#@https://developer.gnome.org/gtk3/3.2/GtkImage.html
-extern GtkImage `{GtkImage *`}
+extern class GtkImage `{GtkImage *`}
super GtkMisc
# Create a GtkImage
#enum GtkImageType
#Describes the image data representation used by a GtkImage.
#@https://developer.gnome.org/gtk3/3.2/GtkImage.html#GtkImageType
-extern GtkImageType `{GtkImageType`}
+extern class GtkImageType `{GtkImageType`}
# There is no image displayed by the widget.
new empty `{ return GTK_IMAGE_EMPTY; `}
#Displays an arrow
#@https://developer.gnome.org/gtk3/3.2/GtkArrow.html
-extern GtkArrow `{GtkArrow *`}
+extern class GtkArrow `{GtkArrow *`}
super GtkMisc
new ( arrow_type : GtkArrowType, shadow_type : GtkShadowType ) is extern `{
#A widget that emits a signal when clicked on
#@https://developer.gnome.org/gtk3/stable/GtkButton.html
-extern GtkButton `{GtkButton *`}
+extern class GtkButton `{GtkButton *`}
super GtkBin
new is extern `{
#A button which pops up a scale
#@https://developer.gnome.org/gtk3/stable/GtkScaleButton.html
-extern GtkScaleButton `{GtkScaleButton *`}
+extern class GtkScaleButton `{GtkScaleButton *`}
super GtkButton
#const gchar **icons
#Create buttons bound to a URL
#@https://developer.gnome.org/gtk3/stable/GtkLinkButton.html
-extern GtkLinkButton `{GtkLinkButton *`}
+extern class GtkLinkButton `{GtkLinkButton *`}
super GtkButton
new( uri: String ) is extern import String.to_cstring `{
#A container which can hide its child
#https://developer.gnome.org/gtk3/stable/GtkExpander.html
-extern GtkExpander `{GtkExpander *`}
+extern class GtkExpander `{GtkExpander *`}
super GtkBin
new( lbl : String) is extern import String.to_cstring`{
#An abstract class for laying out GtkCellRenderers
#@https://developer.gnome.org/gtk3/stable/GtkCellArea.html
-extern GtkComboBox `{GtkComboBox *`}
+extern class GtkComboBox `{GtkComboBox *`}
super GtkBin
new is extern `{
#Show a spinner animation
#@https://developer.gnome.org/gtk3/3.2/GtkSpinner.html
-extern GtkSpinner `{GtkSpinner *`}
+extern class GtkSpinner `{GtkSpinner *`}
super GtkWidget
new is extern `{
#A "light switch" style toggle
#@https://developer.gnome.org/gtk3/3.2/GtkSwitch.html
-extern GtkSwitch `{GtkSwitch *`}
+extern class GtkSwitch `{GtkSwitch *`}
super GtkWidget
new is extern `{
#A widget which controls the alignment and size of its child
#https://developer.gnome.org/gtk3/stable/GtkAlignment.html
-extern GtkAlignment `{GtkAlignment *`}
+extern class GtkAlignment `{GtkAlignment *`}
super GtkBin
new ( xalign : Float, yalign : Float, xscale : Float, yscale : Float ) is extern `{
#A representation of an adjustable bounded value
#@https://developer.gnome.org/gtk3/stable/GtkAdjustment.html#GtkAdjustment.description
-extern GtkAdjustment `{GtkAdjustment *`}
+extern class GtkAdjustment `{GtkAdjustment *`}
end
-extern GdkColor `{GdkColor*`}
+extern class GdkColor `{GdkColor*`}
new is extern `{
GdkColor * col = malloc(sizeof(GdkColor));
/*gdk_color_parse( "red", recv );*/
`}
end
-extern GdkRGBA `{GdkRGBA*`}
+extern class GdkRGBA `{GdkRGBA*`}
new is extern `{
`}
end
#Create popup windows
#@https://developer.gnome.org/gtk3/stable/GtkDialog.html
-extern GtkDialog `{GtkDialog *`}
+extern class GtkDialog `{GtkDialog *`}
super GtkWindow
new is extern `{
#Display information about an application
#@https://developer.gnome.org/gtk3/stable/GtkAboutDialog.html
-extern GtkAboutDialog `{GtkAboutDialog *`}
+extern class GtkAboutDialog `{GtkAboutDialog *`}
super GtkDialog
new is extern `{
#An application chooser dialog
#@https://developer.gnome.org/gtk3/stable/GtkAppChooserDialog.html
-extern GtkAppChooserDialog `{GtkAppChooserDialog *`}
+extern class GtkAppChooserDialog `{GtkAppChooserDialog *`}
super GtkDialog
#TODO - GFile
#A dialog for choosing colors
#@https://developer.gnome.org/gtk3/stable/GtkColorChooserDialog.html
-extern GtkColorChooserDialog `{GtkColorChooserDialog *`}
+extern class GtkColorChooserDialog `{GtkColorChooserDialog *`}
super GtkDialog
new ( title : String, parent : GtkWindow ) is extern import String.to_cstring `{
#A file chooser dialog, suitable for "File/Open" or "File/Save" commands
#@https://developer.gnome.org/gtk3/stable/GtkFileChooserDialog.html
-extern GtkFileChooserDialog `{GtkFileChooserDialog *`}
+extern class GtkFileChooserDialog `{GtkFileChooserDialog *`}
super GtkDialog
new ( title : String, parent : GtkWindow, action : GtkFileChooserAction ) is extern import String.to_cstring `{
#enum GtkFileChooserAction
#Describes whether a GtkFileChooser is being used to open existing files or to save to a possibly new file.
#@https://developer.gnome.org/gtk3/stable/GtkFileChooser.html#GtkFileChooserAction
-extern GtkFileChooserAction `{GtkFileChooserAction`}
+extern class GtkFileChooserAction `{GtkFileChooserAction`}
#Indicates open mode. The file chooser will only let the user pick an existing file.
new open `{ return GTK_FILE_CHOOSER_ACTION_OPEN; `}
#A dialog for selecting fonts
#@https://developer.gnome.org/gtk3/stable/GtkFontChooserDialog.html
-extern GtkFontChooserDialog `{GtkFontChooserDialog *`}
+extern class GtkFontChooserDialog `{GtkFontChooserDialog *`}
super GtkDialog
new ( title : String, parent : GtkWindow ) is extern `{
#A convenient message window
#@https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html
-extern GtkMessageDialog `{GtkMessageDialog *`}
+extern class GtkMessageDialog `{GtkMessageDialog *`}
super GtkDialog
new ( parent : GtkWindow, flags : GtkDialogFlags, msg_type : GtkMessageType, btn_type : GtkButtonsType, format : String ) is extern import String.to_cstring `{
#enum GtkButtonsType
#Prebuilt sets of buttons for the dialog. If none of these choices are appropriate, simply use GTK_BUTTONS_NONE then call gtk_dialog_add_buttons().
#@https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html#GtkButtonsType
-extern GtkButtonsType `{GtkButtonsType`}
+extern class GtkButtonsType `{GtkButtonsType`}
#No buttons at all
new none `{ return GTK_BUTTONS_NONE; `}
#enum GtkMessageType
#The type of message being displayed in the dialog.
#@https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html#GtkMessageType
-extern GtkMessageType `{GtkMessageType`}
+extern class GtkMessageType `{GtkMessageType`}
#Informational message
new info `{ return GTK_MESSAGE_INFO; `}
#A page setup dialog
#@https://developer.gnome.org/gtk3/stable/GtkPageSetupUnixDialog.html
-#extern GtkPageSetupUnixDialog `{GtkPageSetupUnixDialog *`}
+#extern class GtkPageSetupUnixDialog `{GtkPageSetupUnixDialog *`}
# super GtkDialog
#
#end
#A print dialog
#@https://developer.gnome.org/gtk3/stable/GtkPrintUnixDialog.html
-#extern GtkPrintUnixDialog `{GtkPrintUnixDialog *`}
+#extern class GtkPrintUnixDialog `{GtkPrintUnixDialog *`}
# super GtkDialog
#
#end
#Displays recently used files in a dialog
#@https://developer.gnome.org/gtk3/stable/GtkRecentChooserDialog.html
-extern GtkRecentChooserDialog `{GtkRecentChooserDialog *`}
+extern class GtkRecentChooserDialog `{GtkRecentChooserDialog *`}
super GtkDialog
end
#enum GtkDialogFlags
#Flags used to influence dialog construction.
#@https://developer.gnome.org/gtk3/stable/GtkDialog.html#GtkDialogFlags
-extern GtkDialogFlags `{GtkDialogFlags`}
+extern class GtkDialogFlags `{GtkDialogFlags`}
#Make the constructed dialog modal.
new modal `{ return GTK_DIALOG_MODAL; `}
#enum GtkResponseType
#Predefined values for use as response ids in gtk_dialog_add_button().
#@https://developer.gnome.org/gtk3/stable/GtkDialog.html#GtkResponseType
-extern GtkResponseType `{GtkResponseType`}
+extern class GtkResponseType `{GtkResponseType`}
#Returned if an action widget has no response id, or if the dialog gets programmatically hidden or destroyed.
new none `{ return GTK_RESPONSE_NONE; `}
#enum GtkArrowPlacement
#Used to specify the placement of scroll arrows in scrolling menus.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkArrowPlacement
-extern GtkArrowPlacement `{GtkArrowPlacement`}
+extern class GtkArrowPlacement `{GtkArrowPlacement`}
#Place one arrow on each end of the menu.
new both `{ return GTK_ARROWS_BOTH; `}
#enum GtkArrowType
#Used to indicate the direction in which a GtkArrow should point.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkArrowType
-extern GtkArrowType `{GtkArrowType`}
+extern class GtkArrowType `{GtkArrowType`}
#Represents an upward pointing arrow.
new up `{ return GTK_ARROW_UP; `}
#enum GtkAttachOptions
#Denotes the expansion properties that a widget will have when it (or its parent) is resized.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkAttachOptions
-extern GtkAttachOptions `{GtkAttachOptions`}
+extern class GtkAttachOptions `{GtkAttachOptions`}
#The widget should expand to take up any extra space in its container that has been allocated.
new expan `{ return GTK_EXPAND; `}
#enum GtkButtonBoxStyle
#Used to dictate the style that a GtkButtonBox uses to layout the buttons it contains.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkButtonBoxStyle
-extern GtkButtonBoxStyle `{GtkButtonBoxStyle`}
+extern class GtkButtonBoxStyle `{GtkButtonBoxStyle`}
#Buttons are evenly spread across the box.
new spread `{ return GTK_BUTTONBOX_SPREAD; `}
#enum GtkCornerType
#Specifies which corner a child widget should be placed in when packed into a GtkScrolledWindow. This is effectively the opposite of where the scroll bars are placed.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkCornerType
-extern GtkCornerType `{GtkCornerType`}
+extern class GtkCornerType `{GtkCornerType`}
#Place the scrollbars on the right and bottom of the widget (default behaviour).
new top_left `{ return GTK_CORNER_TOP_LEFT; `}
#enum GtkExpanderStyle
#Used to specify the style of the expanders drawn by a GtkTreeView.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkExpanderStyle
-extern GtkExpanderStyle `{GtkExpanderStyle`}
+extern class GtkExpanderStyle `{GtkExpanderStyle`}
#The style used for a collapsed subtree.
new collapsed `{ return GTK_EXPANDER_COLLAPSED; `}
#enum GtkJustification
#Used for justifying the text inside a GtkLabel widget.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkJustification
-extern GtkJustification `{GtkJustification`}
+extern class GtkJustification `{GtkJustification`}
#The text is placed at the left edge of the label.
new left `{ return GTK_JUSTIFY_LEFT; `}
#enum GtkOrientation
#Represents the orientation of widgets.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkOrientation
-extern GtkOrientation `{GtkOrientation`}
+extern class GtkOrientation `{GtkOrientation`}
#The widget is in horizontal orientation.
new horizontal `{ return GTK_ORIENTATION_HORIZONTAL; `}
#enum GtkPackType
#Represents the packing location GtkBox children.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkPackType
-extern GtkPackType `{GtkPackType`}
+extern class GtkPackType `{GtkPackType`}
#The child is packed into the start of the box.
new start `{ return GTK_PACK_START; `}
#enum GtkPolicyType
#Determines when a scroll bar will be visible.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkPolicyType
-extern GtkPolicyType `{GtkPolicyType`}
+extern class GtkPolicyType `{GtkPolicyType`}
#The scrollbar is always visible.
new always `{ return GTK_POLICY_ALWAYS; `}
#enum GtkPositionType
#Describes which edge of a widget a certain feature is positioned.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkPositionType
-extern GtkPositionType `{GtkPositionType`}
+extern class GtkPositionType `{GtkPositionType`}
#The feature is at the left edge.
new left `{ return GTK_POS_LEFT; `}
#enum GtkReliefStyle
#Indicates the relief to be drawn around a GtkButton.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkReliefStyle
-extern GtkReliefStyle `{GtkReliefStyle`}
+extern class GtkReliefStyle `{GtkReliefStyle`}
#Draw a normal relief.
new normal `{ return GTK_RELIEF_NORMAL; `}
#enum GtkResizeMode
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkResizeMode
-extern GtkResizeMode `{GtkResizeMode`}
+extern class GtkResizeMode `{GtkResizeMode`}
#Pass resize request to the parent.
new parent `{ return GTK_RESIZE_PARENT; `}
#enum GtkSelectionMode
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkSelectionMode
-extern GtkSelectionMode `{GtkResizeMode`}
+extern class GtkSelectionMode `{GtkResizeMode`}
#No selection is possible.
new none `{ return GTK_SELECTION_NONE; `}
#enum GtkShadowType
#Used to change the appearance of an outline typically provided by a GtkFrame.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkShadowType
-extern GtkShadowType `{GtkShadowType`}
+extern class GtkShadowType `{GtkShadowType`}
#No outline.
new none `{ return GTK_SHADOW_NONE; `}
#enum GtkStateType
#Indicates the current state of a widget; the state determines how the widget is drawn.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkStateType
-extern GtkStateType `{GtkStateType`}
+extern class GtkStateType `{GtkStateType`}
#State during normal operation.
new normal `{ return GTK_STATE_NORMAL; `}
#enum GtkStateFlags
#Describes a widget state.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkStateFlags
-extern GtkStateFlags `{GtkStateFlags`}
+extern class GtkStateFlags `{GtkStateFlags`}
#State during normal operation.
new normal `{ return GTK_STATE_FLAG_NORMAL; `}
#enum GtkToolbarStyle
#Used to customize the appearance of a GtkToolbar.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkToolbarStyle
-extern GtkToolbarStyle `{GtkToolbarStyle`}
+extern class GtkToolbarStyle `{GtkToolbarStyle`}
#Buttons display only icons in the toolbar.
new icons `{ return GTK_TOOLBAR_ICONS; `}
#enum GtkWindowPosition
#Window placement can be influenced using this enumeration.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkWindowPosition
-extern GtkWindowPosition `{GtkWindowPosition`}
+extern class GtkWindowPosition `{GtkWindowPosition`}
#No influence is made on placement.
new none `{ return GTK_WIN_POS_NONE; `}
#enum GtkWindowType
#A GtkWindow can be one of these types.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkWindowType
-extern GtkWindowType `{GtkWindowType`}
+extern class GtkWindowType `{GtkWindowType`}
#A regular window, such as a dialog
new toplevel `{ return GTK_WINDOW_TOPLEVEL; `}
#enum GtkSortType
#Determines the direction of a sort.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkSortType
-extern GtkSortType `{GtkSortType`}
+extern class GtkSortType `{GtkSortType`}
#Sorting is in ascending order.
new asc `{ return GTK_SORT_ASCENDING; `}
#enum GtkBorderStyle
#Describes how the border of a UI element should be rendered.
#@https://developer.gnome.org/gtk3/3.2/gtk3-Standard-Enumerations.html#GtkBorderStyle
-extern GtkBorderStyle `{GtkBorderStyle`}
+extern class GtkBorderStyle `{GtkBorderStyle`}
#No visible border.
new none `{ return GTK_BORDER_STYLE_NONE; `}
end
# Icon size enum
-extern GtkIconSize `{GtkIconSize`}
+extern class GtkIconSize `{GtkIconSize`}
new invalid `{ return GTK_ICON_SIZE_INVALID; `}
new menu `{ return GTK_ICON_SIZE_MENU; `}
new small_toolbar `{ return GTK_ICON_SIZE_SMALL_TOOLBAR; `}
#Displays a calendar and allows the user to select a date
#@https://developer.gnome.org/gtk3/3.2/GtkCalendar.html
-extern GtkCalendar `{GtkCalendar *`}
+extern class GtkCalendar `{GtkCalendar *`}
super GtkWidget
new is extern `{
#enum GtkCalendarDisplayOptions
#@https://developer.gnome.org/gtk3/3.2/GtkCalendar.html#GtkCalendarDisplayOptions
-extern GtkCalendarDisplayOptions `{GtkCalendarDisplayOptions`}
+extern class GtkCalendarDisplayOptions `{GtkCalendarDisplayOptions`}
new show_heading `{ return GTK_CALENDAR_SHOW_HEADING; `}
new show_day_names `{ return GTK_CALENDAR_SHOW_DAY_NAMES; `}
new no_month_change `{ return GTK_CALENDAR_NO_MONTH_CHANGE; `}
#A separator widget
#@https://developer.gnome.org/gtk3/stable/GtkSeparator.html
-extern GtkSeparator `{GtkSeparator *`}
+extern class GtkSeparator `{GtkSeparator *`}
super GtkWidget
new ( orientation : GtkOrientation ) is extern `{
#A widget which indicates progress visually
#@https://developer.gnome.org/gtk3/3.2/GtkProgressBar.html
-extern GtkProgressBar `{GtkProgressBar *`}
+extern class GtkProgressBar `{GtkProgressBar *`}
super GtkWidget
new is extern `{
end
-extern GtkColorSelectionDialog
+extern class GtkColorSelectionDialog
super GtkWidget
new ( title : String, parent : GtkWindow ) is extern import String.to_cstring `{
return gtk_color_chooser_dialog_new( String_to_cstring( title ), parent );
#Retrieve an integer or floating-point number from the user
#@https://developer.gnome.org/gtk3/3.2/GtkSpinButton.html
-extern GtkSpinButton `{GtkSpinButton *`}
+extern class GtkSpinButton `{GtkSpinButton *`}
super GtkEntry
new ( adjustment : GtkAdjustment, climb_rate : Float, digits : Int )is extern `{
#enum GtkSpinType
#The values of the GtkSpinType enumeration are used to specify the change to make in gtk_spin_button_spin().
#@https://developer.gnome.org/gtk3/stable/GtkSpinButton.html#GtkSpinType
-extern GtkSpinType `{GtkSpinType`}
+extern class GtkSpinType `{GtkSpinType`}
#Increment by the adjustments step increment.
new step_forward `{ return GTK_SPIN_STEP_FORWARD; `}
#A widget to unlock or lock privileged operations
#@https://developer.gnome.org/gtk3/stable/GtkLockButton.html
-extern GtkLockButton
+extern class GtkLockButton
super GtkButton
end
#A button to launch a color selection dialog
#@https://developer.gnome.org/gtk3/stable/GtkColorButton.html
-extern GtkColorButton `{GtkColorButton *`}
+extern class GtkColorButton `{GtkColorButton *`}
super GtkButton
new is extern `{
#An entry which shows a search icon
#@https://developer.gnome.org/gtk3/stable/GtkSearchEntry.html
-extern GtkSearchEntry `{GtkSearchEntry *`}
+extern class GtkSearchEntry `{GtkSearchEntry *`}
super GtkEntry
new is extern `{
import gtk3_6
-redef extern GtkWidget
+redef class GtkWidget
# Get the visibility of the widget, check if it's parents are visible too
fun visible: Bool is extern `{
return gtk_widget_is_visible(recv);
`}
end
-redef extern JsonObject
+redef extern class JsonObject
# Get this json object as a Map
private fun json_to_map : nullable Map[String, nullable Jsonable] import NativeString.to_s, String.to_cstring, HashMap[String,nullable Jsonable], HashMap[String,nullable Jsonable].[]=, json_cross, HashMap[String, nullable Jsonable].as(nullable Map[String, nullable Jsonable]) `{
HashMap_of_String_nullable_Jsonable map;
new `{ return json_object_new_object(); `}
# Add a key and value to the object
- fun add( key : String, val : nullable JsonObject ) import String.to_cstring, JsonObject as not nullable `{
+ fun add( key : String, val : nullable JsonObject ) import String.to_cstring, JsonObject.as not nullable `{
char* native_key;
native_key = String_to_cstring( key );
`}
end
-private extern JsonArray
+private extern class JsonArray
super JsonObject
new `{ return json_object_new_array(); `}
end
# Main object type used by C library
-private extern JsonObject `{ struct json_object* `}
+private extern class JsonObject `{ struct json_object* `}
# Give up ownership of this object and decrease the reference count.
fun put `{ json_object_put( recv ); `}
# Represents a jni JavaVM
extern class JavaVM `{JavaVM *`}
# Create the JVM, returns its handle and store the a pointer to JniEnv in `env_ref`
- new(args: JavaVMInitArgs, env_ref: JniEnvRef) import jni_error, JniEnvRef.jni_env=, JniEnv as nullable `{
+ new(args: JavaVMInitArgs, env_ref: JniEnvRef) import jni_error, JniEnvRef.jni_env=, JniEnv.as nullable `{
JavaVM *jvm;
JNIEnv *env;
jint res;
`}
# Call a method on `obj` designed by `method_id` with an array `args` of arguments
- fun call_void_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]) import Array[nullable Object] as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
+ fun call_void_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]) import Array[nullable Object].as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
jvalue * args_tab = convert_array_of_Object_to_c(args, recv);
(*recv)->CallVoidMethodA(recv, obj, method_id, args_tab);
free(args_tab);
`}
# Call a method on `obj` designed by `method_id` with an array `args` of argument returning a JObject
- fun call_object_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): JObject import Array[nullable Object] as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
+ fun call_object_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): JObject import Array[nullable Object].as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
jvalue * args_tab = convert_array_of_Object_to_c(args, recv);
(*recv)->CallObjectMethod(recv, obj, method_id, args_tab);
free(args_tab);
`}
# Call a method on `obj` designed by `method_id` with an array `args` of arguments returning a Bool
- fun call_boolean_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): Bool import Array[nullable Object] as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
+ fun call_boolean_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): Bool import Array[nullable Object].as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
jvalue * args_tab = convert_array_of_Object_to_c(args, recv);
return (*recv)->CallBooleanMethod(recv, obj, method_id, args_tab);
free(args_tab);
`}
# Call a method on `obj` designed by `method_id` with an array `args` of arguments returning a Char
- fun call_char_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): Char import Array[nullable Object] as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
+ fun call_char_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): Char import Array[nullable Object].as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
jvalue * args_tab = convert_array_of_Object_to_c(args, recv);
return (*recv)->CallCharMethod(recv, obj, method_id, args_tab);
free(args_tab);
`}
# Call a method on `obj` designed by `method_id` with an array `args` of arguments returning an Int
- fun call_int_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): Int import Array[nullable Object] as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
+ fun call_int_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): Int import Array[nullable Object].as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
jvalue * args_tab = convert_array_of_Object_to_c(args, recv);
return (*recv)->CallIntMethod(recv, obj, method_id, args_tab);
free(args_tab);
`}
# Call a method on `obj` designed by `method_id` with an array `args` of arguments returning a Float
- fun call_float_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): Float import Array[nullable Object] as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
+ fun call_float_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): Float import Array[nullable Object].as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring `{
jvalue * args_tab = convert_array_of_Object_to_c(args, recv);
return (*recv)->CallFloatMethod(recv, obj, method_id, args_tab);
free(args_tab);
`}
# Call a method on `obj` designed by `method_id` with an array `args` of arguments returning a NativeString
- fun call_string_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): NativeString import Array[nullable Object] as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring, String.length `{
+ fun call_string_method(obj: JObject, method_id: JMethodID, args: nullable Array[nullable Object]): NativeString import Array[nullable Object].as not nullable, Array[nullable Object].[], Array[nullable Object].length, nullable Object.as(Int), nullable Object.as(Char), nullable Object.as(Bool), nullable Object.as(Float), nullable Object.as(JObject), nullable Object.as(String), String.to_cstring, String.length `{
jvalue * args_tab = convert_array_of_Object_to_c(args, recv);
jobject jobj = (*recv)->CallObjectMethod(recv, obj, method_id, args_tab);
free(args_tab);
`}
end
-extern Opengles1Image in "C" `{struct mnit_opengles_Texture *`}
+extern class Opengles1Image in "C" `{struct mnit_opengles_Texture *`}
super Image
redef fun destroy is extern `{ free( recv ); `}
end
# FIXME this class is broken
-extern Opengles1DrawableImage in "C" `{struct mnit_opengles_DrawableTexture*`}
+extern class Opengles1DrawableImage in "C" `{struct mnit_opengles_DrawableTexture*`}
super DrawableImage
new ( w, h: Int ) is extern `{
struct mnit_opengles_DrawableTexture *image =
`}
-extern InnerAndroidMotionEvent in "C" `{AInputEvent *`}
+extern class InnerAndroidMotionEvent in "C" `{AInputEvent *`}
super Pointer
private fun pointers_count: Int is extern `{
return AMotionEvent_getPointerCount(recv);
redef fun depressed do return not pressed
end
-extern AndroidKeyEvent in "C" `{AInputEvent *`}
+extern class AndroidKeyEvent in "C" `{AInputEvent *`}
super KeyEvent
super AndroidInputEvent
}
`}
-extern AndroidAsset in "C" `{struct AAsset*`}
+extern class AndroidAsset in "C" `{struct AAsset*`}
- fun read(count: Int): nullable String is extern import String as nullable, NativeString.to_s `{
+ fun read(count: Int): nullable String is extern import String.as nullable, NativeString.to_s `{
char *buffer = malloc(sizeof(char) * (count+1));
int read = AAsset_read(recv, buffer, count);
if (read != count)
return null
end
- protected fun load_asset_from_apk(path: String): nullable AndroidAsset is extern import String.to_cstring, AndroidAsset as nullable `{
+ protected fun load_asset_from_apk(path: String): nullable AndroidAsset is extern import String.to_cstring, AndroidAsset.as nullable `{
struct AAsset* a = AAssetManager_open(mnit_java_app->activity->assetManager, String_to_cstring(path), AASSET_MODE_BUFFER);
if (a == NULL)
{
extern struct android_app *mnit_java_app;
`}
-extern ASensorType `{int`}
+extern class ASensorType `{int`}
new accelerometer: ASensorType `{return ASENSOR_TYPE_ACCELEROMETER;`}
fun is_accelerometer: Bool `{return recv == ASENSOR_TYPE_ACCELEROMETER;`}
new magnetic_field: ASensorType `{return ASENSOR_TYPE_MAGNETIC_FIELD;`}
end
end
-redef extern Opengles1Image
+redef extern class Opengles1Image
new from_sdl_image( sdl_image: SDLImage ) is extern `{
return mnit_opengles_load_image( sdl_image->pixels, sdl_image->w, sdl_image->h, sdl_image->format->Amask );
`}
#include <time.h>
`}
-extern Timespec `{struct timespec*`}
+extern class Timespec `{struct timespec*`}
new ( s, ns : Int ) `{
struct timespec* tv = malloc( sizeof(struct timespec) );
tv->tv_sec = s; tv->tv_nsec = ns;
`}
# Save the image into the specified file
- fun save_to_file(path: String) import String::to_cstring `{ `}
+ fun save_to_file(path: String) import String.to_cstring `{ `}
# Destroy the image and free the memory
redef fun destroy `{ SDL_FreeSurface(recv); `}
`}
# Return the family name of the font
- fun family_name: nullable String import String.to_cstring, String as nullable `{
+ fun family_name: nullable String import String.to_cstring, String.as nullable `{
char *fn = TTF_FontFaceFamilyName(recv);
if (fn == NULL)
`}
# Return the style name of the font
- fun style_name: nullable String import String.to_cstring, String as nullable `{
+ fun style_name: nullable String import String.to_cstring, String.as nullable `{
char *sn = TTF_FontFaceStyleName(recv);
if (sn == NULL)
end
# Data structure used by the poll function
-private extern FFSocketPollFD `{ struct pollfd `}
+private extern class FFSocketPollFD `{ struct pollfd `}
# File descriptor id
private fun fd: Int `{ return recv.fd; `}
# List of events to be watched
end
-extern FFSocket `{ S_DESCRIPTOR* `}
+extern class FFSocket `{ S_DESCRIPTOR* `}
new socket(domain: FFSocketAddressFamilies, socketType: FFSocketTypes, protocol: FFSocketProtocolFamilies) `{
S_DESCRIPTOR *d = NULL; d = (S_DESCRIPTOR*) malloc( sizeof(S_DESCRIPTOR) );
int ds = socket(domain, socketType, protocol);
end
end
-extern FFSocketAcceptResult `{ S_ACCEPT_RESULT* `}
+extern class FFSocketAcceptResult `{ S_ACCEPT_RESULT* `}
new (socket: FFSocket, addrIn: FFSocketAddrIn) `{
S_ACCEPT_RESULT *sar = NULL;
sar = malloc( sizeof(S_ACCEPT_RESULT) );
fun destroy `{ free(recv); `}
end
-extern FFSocketAddrIn `{ S_ADDR_IN* `}
+extern class FFSocketAddrIn `{ S_ADDR_IN* `}
new `{
S_ADDR_IN *sai = NULL;
sai = malloc( sizeof(S_ADDR_IN) );
fun destroy `{ free(recv); `}
end
-extern FFSocketHostent `{ S_HOSTENT* `}
+extern class FFSocketHostent `{ S_HOSTENT* `}
private fun i_h_aliases(i: Int): String import NativeString.to_s `{ return NativeString_to_s(recv->h_aliases[i]); `}
private fun i_h_aliases_reachable(i: Int): Bool `{ return (recv->h_aliases[i] != NULL); `}
fun h_aliases: Array[String]
fun h_name: String import NativeString.to_s `{ return NativeString_to_s(recv->h_name); `}
end
-extern FFTimeval `{ S_TIMEVAL* `}
+extern class FFTimeval `{ S_TIMEVAL* `}
new (seconds: Int, microseconds: Int) `{
S_TIMEVAL* tv = NULL;
tv = malloc( sizeof(S_TIMEVAL) );
fun destroy `{ free( recv ); `}
end
-extern FFSocketSet `{ S_FD_SET* `}
+extern class FFSocketSet `{ S_FD_SET* `}
new `{
S_FD_SET *f = NULL;
f = malloc( sizeof(S_FD_SET) );
`}
end
-extern FFSocketTypes `{ int `}
+extern class FFSocketTypes `{ int `}
new sock_stream `{ return SOCK_STREAM; `}
new sock_dgram `{ return SOCK_DGRAM; `}
new sock_raw `{ return SOCK_RAW; `}
new sock_seqpacket `{ return SOCK_SEQPACKET; `}
end
-extern FFSocketAddressFamilies `{ int `}
+extern class FFSocketAddressFamilies `{ int `}
new af_null `{ return 0; `}
new af_unspec `{ return AF_UNSPEC; `} # unspecified
new af_unix `{ return AF_UNIX; `} # local to host (pipes)
new af_inet6 `{ return AF_INET6; `} # IPv6
new af_max `{ return AF_MAX; `}
end
-extern FFSocketProtocolFamilies `{ int `}
+extern class FFSocketProtocolFamilies `{ int `}
new pf_null `{ return 0; `}
new pf_unspec `{ return PF_UNSPEC; `}
new pf_local `{ return PF_LOCAL; `}
new pf_max `{ return PF_MAX; `}
end
# Level on which to set options
-extern FFSocketOptLevels `{ int `}
+extern class FFSocketOptLevels `{ int `}
# Dummy for IP (As defined in C)
new ip `{ return IPPROTO_IP;`}
# Control message protocol
new socket `{ return SOL_SOCKET; `}
end
# Options for socket, use with setsockopt
-extern FFSocketOptNames `{ int `}
+extern class FFSocketOptNames `{ int `}
# Enables debugging information
new debug `{ return SO_DEBUG; `}
# Authorizes the broadcasting of messages
new keepalive `{ return SO_KEEPALIVE; `}
end
# Used for the poll function of a socket, mix several Poll values to check for events on more than one type of event
-extern FFSocketPollValues `{ int `}
+extern class FFSocketPollValues `{ int `}
new pollin `{ return POLLIN; `} # Data other than high-priority data may be read without blocking.
new pollrdnorm `{ return POLLRDNORM; `} # Normal data may be read without blocking.
new pollrdband `{ return POLLRDBAND; `} # Priority data may be read without blocking.
return sqlite3_exec(recv, String_to_cstring(sql), 0, 0, 0);
`}
- fun prepare(sql: String): nullable Statement import String.to_cstring, Statement as nullable `{
+ fun prepare(sql: String): nullable Statement import String.to_cstring, Statement.as nullable `{
sqlite3_stmt *stmt;
int res = sqlite3_prepare_v2(recv, String_to_cstring(sql), -1, &stmt, 0);
if (res == SQLITE_OK)
fun system: Int is extern "string_NativeString_NativeString_system_0"
end
-private extern NativeProcess
+private extern class NativeProcess
fun id: Int is extern "exec_NativeProcess_NativeProcess_id_0"
fun is_finished: Bool is extern "exec_NativeProcess_NativeProcess_is_finished_0"
fun status: Int is extern "exec_NativeProcess_NativeProcess_status_0"
end
# Instance of this class are standard FILE * pointers
-private extern NativeFile `{ FILE* `}
+private extern class NativeFile `{ FILE* `}
fun io_read(buf: NativeString, len: Int): Int is extern "file_NativeFile_NativeFile_io_read_2"
fun io_write(buf: NativeString, len: Int): Int is extern "file_NativeFile_NativeFile_io_write_2"
fun io_close: Int is extern "file_NativeFile_NativeFile_io_close_0"
end
# Pointer classes are used to manipulate extern C structures.
-extern Pointer
+extern class Pointer
# Is the address behind this Object at NULL?
fun address_is_null: Bool `{ return recv == NULL; `}
#include <stdio.h>
`}
-extern Test
+extern class Test
new create_me is extern `{
int* foobar = malloc(sizeof(int));
*foobar = 12345;
B_foo(bb);
`}
-fun callbacks_with_nullable_casts(a: A, b: nullable B) import B as not nullable, A as nullable, A.as(nullable B), B.foo `{
+fun callbacks_with_nullable_casts(a: A, b: nullable B) import B.as not nullable, A.as nullable, A.as(nullable B), B.foo `{
if (!nullable_B_is_a_B(b)) {
printf("Instance b is not a B (it is null)\n");
} else {
}
`}
-fun callbacks_with_failed_checks(a: A, b: nullable B) import B as not nullable, B as nullable, A.as(B), B.as(A) `{
+fun callbacks_with_failed_checks(a: A, b: nullable B) import B.as not nullable, B.as nullable, A.as(B), B.as(A) `{
if (!A_is_a_B(a)) {
printf("Instance of A is not a B.\n");
}
fun recover_unsafe( i : Int ) : ToBePreserved `{
return global_tbps[i];
`}
- fun recover( i : Int ) : nullable ToBePreserved import ToBePreserved as nullable `{
+ fun recover( i : Int ) : nullable ToBePreserved import ToBePreserved.as nullable `{
if ( global_tbps[i] != NULL ) {
return ToBePreserved_as_nullable( global_tbps[i] );
} else {
}
`}
-extern A
+extern class A
new is extern `{ return malloc(1); `}
new new_implicit `{ return malloc(1); `}
new new_in_language is extern in "C" `{ return malloc(1); `}
fun inline_implicit : Int `{ return 7; `}
end
-extern B
+extern class B
super A
end
-extern C `{int*`}
+extern class C `{int*`}
end
-extern D
+extern class D
super C
end
-extern E
+extern class E
super C
end
int dv = 1234;
`}
-extern A `{int *`}
+extern class A `{int *`}
super Pointer
new import p `{
};
`}
-extern A in "C" `{struct s_a*`}
+extern class A in "C" `{struct s_a*`}
new `{
struct s_a* v = malloc(sizeof(struct s_a));
v->x = 1;
`}
end
-extern B in "C" `{struct s_b*`}
+extern class B in "C" `{struct s_b*`}
super A
new `{
struct s_b* v = malloc(sizeof(struct s_b));
`}
end
-extern C
+extern class C
super A
new `{
struct s_a* v = malloc(sizeof(struct s_a));
import realtime
-redef extern Timespec
+redef extern class Timespec
fun simplify : Int
do
return sec*1000000 + nanosec/1000