further development of new wrappers

This commit is contained in:
Andreas Rumpf 2010-01-08 00:29:58 +01:00
commit 868f8f8af7
20 changed files with 1381 additions and 1962 deletions

View file

@ -115,7 +115,7 @@ type
SVG_VERSION_1_1, SVG_VERSION_1_2 SVG_VERSION_1_1, SVG_VERSION_1_2
PSurface* = ptr TSurface PSurface* = ptr TSurface
PPCairoSurface* = ptr PSurface PPCairoSurface* = ptr PSurface
P* = ptr T PCairo* = ptr TCario
PPattern* = ptr TPattern PPattern* = ptr TPattern
PFontOptions* = ptr TFontOptions PFontOptions* = ptr TFontOptions
PFontFace* = ptr TFontFace PFontFace* = ptr TFontFace
@ -135,7 +135,7 @@ type
TDestroyFunc* = proc (data: Pointer){.cdecl.} TDestroyFunc* = proc (data: Pointer){.cdecl.}
TWriteFunc* = proc (closure: Pointer, data: PByte, len: int32): TStatus{.cdecl.} TWriteFunc* = proc (closure: Pointer, data: PByte, len: int32): TStatus{.cdecl.}
TReadFunc* = proc (closure: Pointer, data: PByte, len: int32): TStatus{.cdecl.} TReadFunc* = proc (closure: Pointer, data: PByte, len: int32): TStatus{.cdecl.}
T*{.final.} = object #OPAQUE TCario*{.final.} = object #OPAQUE
TSurface*{.final.} = object #OPAQUE TSurface*{.final.} = object #OPAQUE
TPattern*{.final.} = object #OPAQUE TPattern*{.final.} = object #OPAQUE
TScaledFont*{.final.} = object #OPAQUE TScaledFont*{.final.} = object #OPAQUE
@ -198,130 +198,130 @@ proc version_string*(): cstring{.cdecl, importc: "cairo_version_string",
#Helper function to retrieve decoded version #Helper function to retrieve decoded version
proc version*(major, minor, micro: var int32) proc version*(major, minor, micro: var int32)
#* Functions for manipulating state objects #* Functions for manipulating state objects
proc create*(target: PSurface): P{.cdecl, importc: "cairo_create", proc create*(target: PSurface): PCairo{.cdecl, importc: "cairo_create",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc reference*(cr: P): P{.cdecl, importc: "cairo_reference", dynlib: LIB_CAIRO.} proc reference*(cr: PCairo): PCairo{.cdecl, importc: "cairo_reference", dynlib: LIB_CAIRO.}
proc destroy*(cr: P){.cdecl, importc: "cairo_destroy", dynlib: LIB_CAIRO.} proc destroy*(cr: PCairo){.cdecl, importc: "cairo_destroy", dynlib: LIB_CAIRO.}
proc get_reference_count*(cr: P): int32{.cdecl, proc get_reference_count*(cr: PCairo): int32{.cdecl,
importc: "cairo_get_reference_count", dynlib: LIB_CAIRO.} importc: "cairo_get_reference_count", dynlib: LIB_CAIRO.}
proc get_user_data*(cr: P, key: PUserDataKey): pointer{.cdecl, proc get_user_data*(cr: PCairo, key: PUserDataKey): pointer{.cdecl,
importc: "cairo_get_user_data", dynlib: LIB_CAIRO.} importc: "cairo_get_user_data", dynlib: LIB_CAIRO.}
proc set_user_data*(cr: P, key: PUserDataKey, user_data: Pointer, proc set_user_data*(cr: PCairo, key: PUserDataKey, user_data: Pointer,
destroy: TDestroyFunc): TStatus{.cdecl, destroy: TDestroyFunc): TStatus{.cdecl,
importc: "cairo_set_user_data", dynlib: LIB_CAIRO.} importc: "cairo_set_user_data", dynlib: LIB_CAIRO.}
proc save*(cr: P){.cdecl, importc: "cairo_save", dynlib: LIB_CAIRO.} proc save*(cr: PCairo){.cdecl, importc: "cairo_save", dynlib: LIB_CAIRO.}
proc restore*(cr: P){.cdecl, importc: "cairo_restore", dynlib: LIB_CAIRO.} proc restore*(cr: PCairo){.cdecl, importc: "cairo_restore", dynlib: LIB_CAIRO.}
proc push_group*(cr: P){.cdecl, importc: "cairo_push_group", dynlib: LIB_CAIRO.} proc push_group*(cr: PCairo){.cdecl, importc: "cairo_push_group", dynlib: LIB_CAIRO.}
proc push_group_with_content*(cr: P, content: TContent){.cdecl, proc push_group_with_content*(cr: PCairo, content: TContent){.cdecl,
importc: "cairo_push_group_with_content", dynlib: LIB_CAIRO.} importc: "cairo_push_group_with_content", dynlib: LIB_CAIRO.}
proc pop_group*(cr: P): PPattern{.cdecl, importc: "cairo_pop_group", proc pop_group*(cr: PCairo): PPattern{.cdecl, importc: "cairo_pop_group",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc pop_group_to_source*(cr: P){.cdecl, importc: "cairo_pop_group_to_source", proc pop_group_to_source*(cr: PCairo){.cdecl, importc: "cairo_pop_group_to_source",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
#* Modify state #* Modify state
proc set_operator*(cr: P, op: TOperator){.cdecl, importc: "cairo_set_operator", proc set_operator*(cr: PCairo, op: TOperator){.cdecl, importc: "cairo_set_operator",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc set_source*(cr: P, source: PPattern){.cdecl, importc: "cairo_set_source", proc set_source*(cr: PCairo, source: PPattern){.cdecl, importc: "cairo_set_source",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc set_source_rgb*(cr: P, red, green, blue: float64){.cdecl, proc set_source_rgb*(cr: PCairo, red, green, blue: float64){.cdecl,
importc: "cairo_set_source_rgb", dynlib: LIB_CAIRO.} importc: "cairo_set_source_rgb", dynlib: LIB_CAIRO.}
proc set_source_rgba*(cr: P, red, green, blue, alpha: float64){.cdecl, proc set_source_rgba*(cr: PCairo, red, green, blue, alpha: float64){.cdecl,
importc: "cairo_set_source_rgba", dynlib: LIB_CAIRO.} importc: "cairo_set_source_rgba", dynlib: LIB_CAIRO.}
proc set_source_surface*(cr: P, surface: PSurface, x, y: float64){.cdecl, proc set_source_surface*(cr: PCairo, surface: PSurface, x, y: float64){.cdecl,
importc: "cairo_set_source_surface", dynlib: LIB_CAIRO.} importc: "cairo_set_source_surface", dynlib: LIB_CAIRO.}
proc set_tolerance*(cr: P, tolerance: float64){.cdecl, proc set_tolerance*(cr: PCairo, tolerance: float64){.cdecl,
importc: "cairo_set_tolerance", dynlib: LIB_CAIRO.} importc: "cairo_set_tolerance", dynlib: LIB_CAIRO.}
proc set_antialias*(cr: P, antialias: TAntialias){.cdecl, proc set_antialias*(cr: PCairo, antialias: TAntialias){.cdecl,
importc: "cairo_set_antialias", dynlib: LIB_CAIRO.} importc: "cairo_set_antialias", dynlib: LIB_CAIRO.}
proc set_fill_rule*(cr: P, fill_rule: TFillRule){.cdecl, proc set_fill_rule*(cr: PCairo, fill_rule: TFillRule){.cdecl,
importc: "cairo_set_fill_rule", dynlib: LIB_CAIRO.} importc: "cairo_set_fill_rule", dynlib: LIB_CAIRO.}
proc set_line_width*(cr: P, width: float64){.cdecl, proc set_line_width*(cr: PCairo, width: float64){.cdecl,
importc: "cairo_set_line_width", dynlib: LIB_CAIRO.} importc: "cairo_set_line_width", dynlib: LIB_CAIRO.}
proc set_line_cap*(cr: P, line_cap: TLineCap){.cdecl, proc set_line_cap*(cr: PCairo, line_cap: TLineCap){.cdecl,
importc: "cairo_set_line_cap", dynlib: LIB_CAIRO.} importc: "cairo_set_line_cap", dynlib: LIB_CAIRO.}
proc set_line_join*(cr: P, line_join: TLineJoin){.cdecl, proc set_line_join*(cr: PCairo, line_join: TLineJoin){.cdecl,
importc: "cairo_set_line_join", dynlib: LIB_CAIRO.} importc: "cairo_set_line_join", dynlib: LIB_CAIRO.}
proc set_dash*(cr: P, dashes: openarray[float64], offset: float64){.cdecl, proc set_dash*(cr: PCairo, dashes: openarray[float64], offset: float64){.cdecl,
importc: "cairo_set_dash", dynlib: LIB_CAIRO.} importc: "cairo_set_dash", dynlib: LIB_CAIRO.}
proc set_miter_limit*(cr: P, limit: float64){.cdecl, proc set_miter_limit*(cr: PCairo, limit: float64){.cdecl,
importc: "cairo_set_miter_limit", dynlib: LIB_CAIRO.} importc: "cairo_set_miter_limit", dynlib: LIB_CAIRO.}
proc translate*(cr: P, tx, ty: float64){.cdecl, importc: "cairo_translate", proc translate*(cr: PCairo, tx, ty: float64){.cdecl, importc: "cairo_translate",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc scale*(cr: P, sx, sy: float64){.cdecl, importc: "cairo_scale", proc scale*(cr: PCairo, sx, sy: float64){.cdecl, importc: "cairo_scale",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc rotate*(cr: P, angle: float64){.cdecl, importc: "cairo_rotate", proc rotate*(cr: PCairo, angle: float64){.cdecl, importc: "cairo_rotate",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc transform*(cr: P, matrix: PMatrix){.cdecl, importc: "cairo_transform", proc transform*(cr: PCairo, matrix: PMatrix){.cdecl, importc: "cairo_transform",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc set_matrix*(cr: P, matrix: PMatrix){.cdecl, importc: "cairo_set_matrix", proc set_matrix*(cr: PCairo, matrix: PMatrix){.cdecl, importc: "cairo_set_matrix",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc identity_matrix*(cr: P){.cdecl, importc: "cairo_identity_matrix", proc identity_matrix*(cr: PCairo){.cdecl, importc: "cairo_identity_matrix",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc user_to_device*(cr: P, x, y: var float64){.cdecl, proc user_to_device*(cr: PCairo, x, y: var float64){.cdecl,
importc: "cairo_user_to_device", dynlib: LIB_CAIRO.} importc: "cairo_user_to_device", dynlib: LIB_CAIRO.}
proc user_to_device_distance*(cr: P, dx, dy: var float64){.cdecl, proc user_to_device_distance*(cr: PCairo, dx, dy: var float64){.cdecl,
importc: "cairo_user_to_device_distance", dynlib: LIB_CAIRO.} importc: "cairo_user_to_device_distance", dynlib: LIB_CAIRO.}
proc device_to_user*(cr: P, x, y: var float64){.cdecl, proc device_to_user*(cr: PCairo, x, y: var float64){.cdecl,
importc: "cairo_device_to_user", dynlib: LIB_CAIRO.} importc: "cairo_device_to_user", dynlib: LIB_CAIRO.}
proc device_to_user_distance*(cr: P, dx, dy: var float64){.cdecl, proc device_to_user_distance*(cr: PCairo, dx, dy: var float64){.cdecl,
importc: "cairo_device_to_user_distance", dynlib: LIB_CAIRO.} importc: "cairo_device_to_user_distance", dynlib: LIB_CAIRO.}
#* Path creation functions #* Path creation functions
proc new_path*(cr: P){.cdecl, importc: "cairo_new_path", dynlib: LIB_CAIRO.} proc new_path*(cr: PCairo){.cdecl, importc: "cairo_new_path", dynlib: LIB_CAIRO.}
proc move_to*(cr: P, x, y: float64){.cdecl, importc: "cairo_move_to", proc move_to*(cr: PCairo, x, y: float64){.cdecl, importc: "cairo_move_to",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc new_sub_path*(cr: P){.cdecl, importc: "cairo_new_sub_path", proc new_sub_path*(cr: PCairo){.cdecl, importc: "cairo_new_sub_path",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc line_to*(cr: P, x, y: float64){.cdecl, importc: "cairo_line_to", proc line_to*(cr: PCairo, x, y: float64){.cdecl, importc: "cairo_line_to",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc curve_to*(cr: P, x1, y1, x2, y2, x3, y3: float64){.cdecl, proc curve_to*(cr: PCairo, x1, y1, x2, y2, x3, y3: float64){.cdecl,
importc: "cairo_curve_to", dynlib: LIB_CAIRO.} importc: "cairo_curve_to", dynlib: LIB_CAIRO.}
proc arc*(cr: P, xc, yc, radius, angle1, angle2: float64){.cdecl, proc arc*(cr: PCairo, xc, yc, radius, angle1, angle2: float64){.cdecl,
importc: "cairo_arc", dynlib: LIB_CAIRO.} importc: "cairo_arc", dynlib: LIB_CAIRO.}
proc arc_negative*(cr: P, xc, yc, radius, angle1, angle2: float64){.cdecl, proc arc_negative*(cr: PCairo, xc, yc, radius, angle1, angle2: float64){.cdecl,
importc: "cairo_arc_negative", dynlib: LIB_CAIRO.} importc: "cairo_arc_negative", dynlib: LIB_CAIRO.}
proc rel_move_to*(cr: P, dx, dy: float64){.cdecl, importc: "cairo_rel_move_to", proc rel_move_to*(cr: PCairo, dx, dy: float64){.cdecl, importc: "cairo_rel_move_to",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc rel_line_to*(cr: P, dx, dy: float64){.cdecl, importc: "cairo_rel_line_to", proc rel_line_to*(cr: PCairo, dx, dy: float64){.cdecl, importc: "cairo_rel_line_to",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc rel_curve_to*(cr: P, dx1, dy1, dx2, dy2, dx3, dy3: float64){.cdecl, proc rel_curve_to*(cr: PCairo, dx1, dy1, dx2, dy2, dx3, dy3: float64){.cdecl,
importc: "cairo_rel_curve_to", dynlib: LIB_CAIRO.} importc: "cairo_rel_curve_to", dynlib: LIB_CAIRO.}
proc rectangle*(cr: P, x, y, width, height: float64){.cdecl, proc rectangle*(cr: PCairo, x, y, width, height: float64){.cdecl,
importc: "cairo_rectangle", dynlib: LIB_CAIRO.} importc: "cairo_rectangle", dynlib: LIB_CAIRO.}
proc close_path*(cr: P){.cdecl, importc: "cairo_close_path", dynlib: LIB_CAIRO.} proc close_path*(cr: PCairo){.cdecl, importc: "cairo_close_path", dynlib: LIB_CAIRO.}
#* Painting functions #* Painting functions
proc paint*(cr: P){.cdecl, importc: "cairo_paint", dynlib: LIB_CAIRO.} proc paint*(cr: PCairo){.cdecl, importc: "cairo_paint", dynlib: LIB_CAIRO.}
proc paint_with_alpha*(cr: P, alpha: float64){.cdecl, proc paint_with_alpha*(cr: PCairo, alpha: float64){.cdecl,
importc: "cairo_paint_with_alpha", dynlib: LIB_CAIRO.} importc: "cairo_paint_with_alpha", dynlib: LIB_CAIRO.}
proc mask*(cr: P, pattern: PPattern){.cdecl, importc: "cairo_mask", proc mask*(cr: PCairo, pattern: PPattern){.cdecl, importc: "cairo_mask",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc mask_surface*(cr: P, surface: PSurface, surface_x, surface_y: float64){. proc mask_surface*(cr: PCairo, surface: PSurface, surface_x, surface_y: float64){.
cdecl, importc: "cairo_mask_surface", dynlib: LIB_CAIRO.} cdecl, importc: "cairo_mask_surface", dynlib: LIB_CAIRO.}
proc stroke*(cr: P){.cdecl, importc: "cairo_stroke", dynlib: LIB_CAIRO.} proc stroke*(cr: PCairo){.cdecl, importc: "cairo_stroke", dynlib: LIB_CAIRO.}
proc stroke_preserve*(cr: P){.cdecl, importc: "cairo_stroke_preserve", proc stroke_preserve*(cr: PCairo){.cdecl, importc: "cairo_stroke_preserve",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc fill*(cr: P){.cdecl, importc: "cairo_fill", dynlib: LIB_CAIRO.} proc fill*(cr: PCairo){.cdecl, importc: "cairo_fill", dynlib: LIB_CAIRO.}
proc fill_preserve*(cr: P){.cdecl, importc: "cairo_fill_preserve", proc fill_preserve*(cr: PCairo){.cdecl, importc: "cairo_fill_preserve",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc copy_page*(cr: P){.cdecl, importc: "cairo_copy_page", dynlib: LIB_CAIRO.} proc copy_page*(cr: PCairo){.cdecl, importc: "cairo_copy_page", dynlib: LIB_CAIRO.}
proc show_page*(cr: P){.cdecl, importc: "cairo_show_page", dynlib: LIB_CAIRO.} proc show_page*(cr: PCairo){.cdecl, importc: "cairo_show_page", dynlib: LIB_CAIRO.}
#* Insideness testing #* Insideness testing
proc in_stroke*(cr: P, x, y: float64): TBool{.cdecl, importc: "cairo_in_stroke", proc in_stroke*(cr: PCairo, x, y: float64): TBool{.cdecl, importc: "cairo_in_stroke",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc in_fill*(cr: P, x, y: float64): TBool{.cdecl, importc: "cairo_in_fill", proc in_fill*(cr: PCairo, x, y: float64): TBool{.cdecl, importc: "cairo_in_fill",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
#* Rectangular extents #* Rectangular extents
proc stroke_extents*(cr: P, x1, y1, x2, y2: var float64){.cdecl, proc stroke_extents*(cr: PCairo, x1, y1, x2, y2: var float64){.cdecl,
importc: "cairo_stroke_extents", dynlib: LIB_CAIRO.} importc: "cairo_stroke_extents", dynlib: LIB_CAIRO.}
proc fill_extents*(cr: P, x1, y1, x2, y2: var float64){.cdecl, proc fill_extents*(cr: PCairo, x1, y1, x2, y2: var float64){.cdecl,
importc: "cairo_fill_extents", dynlib: LIB_CAIRO.} importc: "cairo_fill_extents", dynlib: LIB_CAIRO.}
#* Clipping #* Clipping
proc reset_clip*(cr: P){.cdecl, importc: "cairo_reset_clip", dynlib: LIB_CAIRO.} proc reset_clip*(cr: PCairo){.cdecl, importc: "cairo_reset_clip", dynlib: LIB_CAIRO.}
proc clip*(cr: P){.cdecl, importc: "cairo_clip", dynlib: LIB_CAIRO.} proc clip*(cr: PCairo){.cdecl, importc: "cairo_clip", dynlib: LIB_CAIRO.}
proc clip_preserve*(cr: P){.cdecl, importc: "cairo_clip_preserve", proc clip_preserve*(cr: PCairo){.cdecl, importc: "cairo_clip_preserve",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc clip_extents*(cr: P, x1, y1, x2, y2: var float64){.cdecl, proc clip_extents*(cr: PCairo, x1, y1, x2, y2: var float64){.cdecl,
importc: "cairo_clip_extents", dynlib: LIB_CAIRO.} importc: "cairo_clip_extents", dynlib: LIB_CAIRO.}
proc copy_clip_rectangle_list*(cr: P): PRectangleList{.cdecl, proc copy_clip_rectangle_list*(cr: PCairo): PRectangleList{.cdecl,
importc: "cairo_copy_clip_rectangle_list", dynlib: LIB_CAIRO.} importc: "cairo_copy_clip_rectangle_list", dynlib: LIB_CAIRO.}
proc rectangle_list_destroy*(rectangle_list: PRectangleList){.cdecl, proc rectangle_list_destroy*(rectangle_list: PRectangleList){.cdecl,
importc: "cairo_rectangle_list_destroy", dynlib: LIB_CAIRO.} importc: "cairo_rectangle_list_destroy", dynlib: LIB_CAIRO.}
@ -360,41 +360,41 @@ proc font_options_get_hint_metrics*(options: PFontOptions): THintMetrics{.cdecl,
importc: "cairo_font_options_get_hint_metrics", dynlib: LIB_CAIRO.} importc: "cairo_font_options_get_hint_metrics", dynlib: LIB_CAIRO.}
#* This interface is for dealing with text as text, not caring about the #* This interface is for dealing with text as text, not caring about the
# font object inside the the TCairo. # font object inside the the TCairo.
proc select_font_face*(cr: P, family: cstring, slant: TFontSlant, proc select_font_face*(cr: PCairo, family: cstring, slant: TFontSlant,
weight: TFontWeight){.cdecl, weight: TFontWeight){.cdecl,
importc: "cairo_select_font_face", dynlib: LIB_CAIRO.} importc: "cairo_select_font_face", dynlib: LIB_CAIRO.}
proc set_font_size*(cr: P, size: float64){.cdecl, proc set_font_size*(cr: PCairo, size: float64){.cdecl,
importc: "cairo_set_font_size", dynlib: LIB_CAIRO.} importc: "cairo_set_font_size", dynlib: LIB_CAIRO.}
proc set_font_matrix*(cr: P, matrix: PMatrix){.cdecl, proc set_font_matrix*(cr: PCairo, matrix: PMatrix){.cdecl,
importc: "cairo_set_font_matrix", dynlib: LIB_CAIRO.} importc: "cairo_set_font_matrix", dynlib: LIB_CAIRO.}
proc get_font_matrix*(cr: P, matrix: PMatrix){.cdecl, proc get_font_matrix*(cr: PCairo, matrix: PMatrix){.cdecl,
importc: "cairo_get_font_matrix", dynlib: LIB_CAIRO.} importc: "cairo_get_font_matrix", dynlib: LIB_CAIRO.}
proc set_font_options*(cr: P, options: PFontOptions){.cdecl, proc set_font_options*(cr: PCairo, options: PFontOptions){.cdecl,
importc: "cairo_set_font_options", dynlib: LIB_CAIRO.} importc: "cairo_set_font_options", dynlib: LIB_CAIRO.}
proc get_font_options*(cr: P, options: PFontOptions){.cdecl, proc get_font_options*(cr: PCairo, options: PFontOptions){.cdecl,
importc: "cairo_get_font_options", dynlib: LIB_CAIRO.} importc: "cairo_get_font_options", dynlib: LIB_CAIRO.}
proc set_font_face*(cr: P, font_face: PFontFace){.cdecl, proc set_font_face*(cr: PCairo, font_face: PFontFace){.cdecl,
importc: "cairo_set_font_face", dynlib: LIB_CAIRO.} importc: "cairo_set_font_face", dynlib: LIB_CAIRO.}
proc get_font_face*(cr: P): PFontFace{.cdecl, importc: "cairo_get_font_face", proc get_font_face*(cr: PCairo): PFontFace{.cdecl, importc: "cairo_get_font_face",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc set_scaled_font*(cr: P, scaled_font: PScaledFont){.cdecl, proc set_scaled_font*(cr: PCairo, scaled_font: PScaledFont){.cdecl,
importc: "cairo_set_scaled_font", dynlib: LIB_CAIRO.} importc: "cairo_set_scaled_font", dynlib: LIB_CAIRO.}
proc get_scaled_font*(cr: P): PScaledFont{.cdecl, proc get_scaled_font*(cr: PCairo): PScaledFont{.cdecl,
importc: "cairo_get_scaled_font", dynlib: LIB_CAIRO.} importc: "cairo_get_scaled_font", dynlib: LIB_CAIRO.}
proc show_text*(cr: P, utf8: cstring){.cdecl, importc: "cairo_show_text", proc show_text*(cr: PCairo, utf8: cstring){.cdecl, importc: "cairo_show_text",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc show_glyphs*(cr: P, glyphs: PGlyph, num_glyphs: int32){.cdecl, proc show_glyphs*(cr: PCairo, glyphs: PGlyph, num_glyphs: int32){.cdecl,
importc: "cairo_show_glyphs", dynlib: LIB_CAIRO.} importc: "cairo_show_glyphs", dynlib: LIB_CAIRO.}
proc text_path*(cr: P, utf8: cstring){.cdecl, importc: "cairo_text_path", proc text_path*(cr: PCairo, utf8: cstring){.cdecl, importc: "cairo_text_path",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc glyph_path*(cr: P, glyphs: PGlyph, num_glyphs: int32){.cdecl, proc glyph_path*(cr: PCairo, glyphs: PGlyph, num_glyphs: int32){.cdecl,
importc: "cairo_glyph_path", dynlib: LIB_CAIRO.} importc: "cairo_glyph_path", dynlib: LIB_CAIRO.}
proc text_extents*(cr: P, utf8: cstring, extents: PTextExtents){.cdecl, proc text_extents*(cr: PCairo, utf8: cstring, extents: PTextExtents){.cdecl,
importc: "cairo_text_extents", dynlib: LIB_CAIRO.} importc: "cairo_text_extents", dynlib: LIB_CAIRO.}
proc glyph_extents*(cr: P, glyphs: PGlyph, num_glyphs: int32, proc glyph_extents*(cr: PCairo, glyphs: PGlyph, num_glyphs: int32,
extents: PTextExtents){.cdecl, extents: PTextExtents){.cdecl,
importc: "cairo_glyph_extents", dynlib: LIB_CAIRO.} importc: "cairo_glyph_extents", dynlib: LIB_CAIRO.}
proc font_extents*(cr: P, extents: PFontExtents){.cdecl, proc font_extents*(cr: PCairo, extents: PFontExtents){.cdecl,
importc: "cairo_font_extents", dynlib: LIB_CAIRO.} importc: "cairo_font_extents", dynlib: LIB_CAIRO.}
#* Generic identifier for a font style #* Generic identifier for a font style
proc font_face_reference*(font_face: PFontFace): PFontFace{.cdecl, proc font_face_reference*(font_face: PFontFace): PFontFace{.cdecl,
@ -449,46 +449,46 @@ proc scaled_font_get_font_options*(scaled_font: PScaledFont,
options: PFontOptions){.cdecl, options: PFontOptions){.cdecl,
importc: "cairo_scaled_font_get_font_options", dynlib: LIB_CAIRO.} importc: "cairo_scaled_font_get_font_options", dynlib: LIB_CAIRO.}
#* Query functions #* Query functions
proc get_operator*(cr: P): TOperator{.cdecl, importc: "cairo_get_operator", proc get_operator*(cr: PCairo): TOperator{.cdecl, importc: "cairo_get_operator",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_source*(cr: P): PPattern{.cdecl, importc: "cairo_get_source", proc get_source*(cr: PCairo): PPattern{.cdecl, importc: "cairo_get_source",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_tolerance*(cr: P): float64{.cdecl, importc: "cairo_get_tolerance", proc get_tolerance*(cr: PCairo): float64{.cdecl, importc: "cairo_get_tolerance",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_antialias*(cr: P): TAntialias{.cdecl, importc: "cairo_get_antialias", proc get_antialias*(cr: PCairo): TAntialias{.cdecl, importc: "cairo_get_antialias",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_current_point*(cr: P, x, y: var float64){.cdecl, proc get_current_point*(cr: PCairo, x, y: var float64){.cdecl,
importc: "cairo_get_current_point", dynlib: LIB_CAIRO.} importc: "cairo_get_current_point", dynlib: LIB_CAIRO.}
proc get_fill_rule*(cr: P): TFillRule{.cdecl, importc: "cairo_get_fill_rule", proc get_fill_rule*(cr: PCairo): TFillRule{.cdecl, importc: "cairo_get_fill_rule",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_line_width*(cr: P): float64{.cdecl, importc: "cairo_get_line_width", proc get_line_width*(cr: PCairo): float64{.cdecl, importc: "cairo_get_line_width",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_line_cap*(cr: P): TLineCap{.cdecl, importc: "cairo_get_line_cap", proc get_line_cap*(cr: PCairo): TLineCap{.cdecl, importc: "cairo_get_line_cap",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_line_join*(cr: P): TLineJoin{.cdecl, importc: "cairo_get_line_join", proc get_line_join*(cr: PCairo): TLineJoin{.cdecl, importc: "cairo_get_line_join",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_miter_limit*(cr: P): float64{.cdecl, importc: "cairo_get_miter_limit", proc get_miter_limit*(cr: PCairo): float64{.cdecl, importc: "cairo_get_miter_limit",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_dash_count*(cr: P): int32{.cdecl, importc: "cairo_get_dash_count", proc get_dash_count*(cr: PCairo): int32{.cdecl, importc: "cairo_get_dash_count",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_dash*(cr: P, dashes, offset: var float64){.cdecl, proc get_dash*(cr: PCairo, dashes, offset: var float64){.cdecl,
importc: "cairo_get_dash", dynlib: LIB_CAIRO.} importc: "cairo_get_dash", dynlib: LIB_CAIRO.}
proc get_matrix*(cr: P, matrix: PMatrix){.cdecl, importc: "cairo_get_matrix", proc get_matrix*(cr: PCairo, matrix: PMatrix){.cdecl, importc: "cairo_get_matrix",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_target*(cr: P): PSurface{.cdecl, importc: "cairo_get_target", proc get_target*(cr: PCairo): PSurface{.cdecl, importc: "cairo_get_target",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc get_group_target*(cr: P): PSurface{.cdecl, proc get_group_target*(cr: PCairo): PSurface{.cdecl,
importc: "cairo_get_group_target", dynlib: LIB_CAIRO.} importc: "cairo_get_group_target", dynlib: LIB_CAIRO.}
proc copy_path*(cr: P): PPath{.cdecl, importc: "cairo_copy_path", proc copy_path*(cr: PCairo): PPath{.cdecl, importc: "cairo_copy_path",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc copy_path_flat*(cr: P): PPath{.cdecl, importc: "cairo_copy_path_flat", proc copy_path_flat*(cr: PCairo): PPath{.cdecl, importc: "cairo_copy_path_flat",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc append_path*(cr: P, path: PPath){.cdecl, importc: "cairo_append_path", proc append_path*(cr: PCairo, path: PPath){.cdecl, importc: "cairo_append_path",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
proc path_destroy*(path: PPath){.cdecl, importc: "cairo_path_destroy", proc path_destroy*(path: PPath){.cdecl, importc: "cairo_path_destroy",
dynlib: LIB_CAIRO.} dynlib: LIB_CAIRO.}
#* Error status queries #* Error status queries
proc status*(cr: P): TStatus{.cdecl, importc: "cairo_status", dynlib: LIB_CAIRO.} proc status*(cr: PCairo): TStatus{.cdecl, importc: "cairo_status", dynlib: LIB_CAIRO.}
proc status_to_string*(status: TStatus): cstring{.cdecl, proc status_to_string*(status: TStatus): cstring{.cdecl,
importc: "cairo_status_to_string", dynlib: LIB_CAIRO.} importc: "cairo_status_to_string", dynlib: LIB_CAIRO.}
#* Surface manipulation #* Surface manipulation

View file

@ -5,7 +5,7 @@
# #
import import
, freetypeh cairo, freetypeh
#todo: properly define FcPattern: #todo: properly define FcPattern:
#It will require translate FontConfig header #It will require translate FontConfig header

View file

@ -4,7 +4,7 @@
# #
import import
, windows cairo, windows
proc win32_surface_create*(hdc: HDC): PSurface{.cdecl, proc win32_surface_create*(hdc: HDC): PSurface{.cdecl,
importc: "cairo_win32_surface_create", dynlib: LIB_CAIRO.} importc: "cairo_win32_surface_create", dynlib: LIB_CAIRO.}

View file

@ -5,7 +5,7 @@
# #
import import
, x, xlib, xrender cairo, x, xlib, xrender
proc xlib_surface_create*(dpy: PDisplay, drawable: TDrawable, visual: PVisual, proc xlib_surface_create*(dpy: PDisplay, drawable: TDrawable, visual: PVisual,
width, height: int32): PSurface{.cdecl, width, height: int32): PSurface{.cdecl,

View file

@ -462,7 +462,7 @@ proc role_register*(name: cstring): TRole{.cdecl, dynlib: lib,
proc object_get_type*(): GType{.cdecl, dynlib: lib, proc object_get_type*(): GType{.cdecl, dynlib: lib,
importc: "atk_object_get_type".} importc: "atk_object_get_type".}
proc TYPE_OBJECT*(): GType proc TYPE_OBJECT*(): GType
proc OBJECT*(obj: pointer): PObject proc `OBJECT`*(obj: pointer): PObject
proc OBJECT_CLASS*(klass: pointer): PObjectClass proc OBJECT_CLASS*(klass: pointer): PObjectClass
proc IS_OBJECT*(obj: pointer): bool proc IS_OBJECT*(obj: pointer): bool
proc IS_OBJECT_CLASS*(klass: pointer): bool proc IS_OBJECT_CLASS*(klass: pointer): bool
@ -983,7 +983,7 @@ proc value_set_current_value*(obj: PValue, value: PGValue): gboolean{.cdecl,
proc TYPE_OBJECT*(): GType = proc TYPE_OBJECT*(): GType =
result = object_get_type() result = object_get_type()
proc OBJECT*(obj: pointer): PObject = proc `OBJECT`*(obj: pointer): PObject =
result = cast[PObject](G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_OBJECT())) result = cast[PObject](G_TYPE_CHECK_INSTANCE_CAST(obj, TYPE_OBJECT()))
proc OBJECT_CLASS*(klass: pointer): PObjectClass = proc OBJECT_CLASS*(klass: pointer): PObjectClass =

View file

@ -1,6 +1,6 @@
{.deadCodeElim: on.} {.deadCodeElim: on.}
import import
glib2, 2pixbuf, pango glib2, gdk2pixbuf, pango
when defined(win32): when defined(win32):
const const
@ -56,8 +56,9 @@ type
PFunction* = ptr TFunction PFunction* = ptr TFunction
TFunction* = enum TFunction* = enum
COPY, INVERT, XOR, CLEAR, AND, AND_REVERSE, AND_INVERT, NOOP, OR, EQUIV, funcCOPY, funcINVERT, funcXOR, funcCLEAR, funcAND,
OR_REVERSE, COPY_INVERT, OR_INVERT, NAND, NOR, SET funcAND_REVERSE, funcAND_INVERT, funcNOOP, funcOR, funcEQUIV,
funcOR_REVERSE, funcCOPY_INVERT, funcOR_INVERT, funcNAND, funcNOR, funcSET
PCapStyle* = ptr TCapStyle PCapStyle* = ptr TCapStyle
TCapStyle* = enum TCapStyle* = enum
CAP_NOT_LAST, CAP_BUTT, CAP_ROUND, CAP_PROJECTING CAP_NOT_LAST, CAP_BUTT, CAP_ROUND, CAP_PROJECTING
@ -109,7 +110,7 @@ type
PImage* = ptr TImage PImage* = ptr TImage
PDevice* = ptr TDevice PDevice* = ptr TDevice
PTimeCoord* = ptr TTimeCoord PTimeCoord* = ptr TTimeCoord
PPGdkTimeCoord* = ptr PTimeCoord PPTimeCoord* = ptr PTimeCoord
PRgbDither* = ptr TRgbDither PRgbDither* = ptr TRgbDither
TRgbDither* = enum TRgbDither* = enum
RGB_DITHER_NONE, RGB_DITHER_NORMAL, RGB_DITHER_MAX RGB_DITHER_NONE, RGB_DITHER_NORMAL, RGB_DITHER_MAX
@ -125,7 +126,7 @@ type
y*: gint y*: gint
PPoint* = ptr TPoint PPoint* = ptr TPoint
PPGdkPoint* = ptr PPoint PPPoint* = ptr PPoint
PSpan* = ptr TSpan PSpan* = ptr TSpan
PWChar* = ptr TWChar PWChar* = ptr TWChar
TWChar* = guint32 TWChar* = guint32
@ -247,8 +248,8 @@ type
nsegs: gint){.cdecl.} nsegs: gint){.cdecl.}
draw_lines*: proc (drawable: PDrawable, gc: PGC, points: PPoint, draw_lines*: proc (drawable: PDrawable, gc: PGC, points: PPoint,
npoints: gint){.cdecl.} npoints: gint){.cdecl.}
draw_glyphs*: proc (drawable: PDrawable, gc: PGC, font: PPangoFont, x: gint, draw_glyphs*: proc (drawable: PDrawable, gc: PGC, font: PFont, x: gint,
y: gint, glyphs: PPangoGlyphString){.cdecl.} y: gint, glyphs: PGlyphString){.cdecl.}
draw_image*: proc (drawable: PDrawable, gc: PGC, image: PImage, xsrc: gint, draw_image*: proc (drawable: PDrawable, gc: PGC, image: PImage, xsrc: gint,
ysrc: gint, xdest: gint, ydest: gint, width: gint, ysrc: gint, xdest: gint, ydest: gint, width: gint,
height: gint){.cdecl.} height: gint){.cdecl.}
@ -509,25 +510,25 @@ type
TEvent*{.final, pure.} = object TEvent*{.final, pure.} = object
data*: array[0..255, char] # union of data*: array[0..255, char] # union of
# `type`: TGdkEventType # `type`: TEventType
# any: TGdkEventAny # any: TEventAny
# expose: TGdkEventExpose # expose: TEventExpose
# no_expose: TGdkEventNoExpose # no_expose: TEventNoExpose
# visibility: TGdkEventVisibility # visibility: TEventVisibility
# motion: TGdkEventMotion # motion: TEventMotion
# button: TGdkEventButton # button: TEventButton
# scroll: TGdkEventScroll # scroll: TEventScroll
# key: TGdkEventKey # key: TEventKey
# crossing: TGdkEventCrossing # crossing: TEventCrossing
# focus_change: TGdkEventFocus # focus_change: TEventFocus
# configure: TGdkEventConfigure # configure: TEventConfigure
# `property`: TGdkEventProperty # `property`: TEventProperty
# selection: TGdkEventSelection # selection: TEventSelection
# proximity: TGdkEventProximity # proximity: TEventProximity
# client: TGdkEventClient # client: TEventClient
# dnd: TGdkEventDND # dnd: TEventDND
# window_state: TGdkEventWindowState # window_state: TEventWindowState
# setting: TGdkEventSetting # setting: TEventSetting
PGCClass* = ptr TGCClass PGCClass* = ptr TGCClass
TGCClass* = object of TGObjectClass TGCClass* = object of TGObjectClass
@ -606,14 +607,14 @@ type
TKeymapClass* = object of TGObjectClass TKeymapClass* = object of TGObjectClass
direction_changed*: proc (keymap: PKeymap){.cdecl.} direction_changed*: proc (keymap: PKeymap){.cdecl.}
PPangoAttrStipple* = ptr TPangoAttrStipple PAttrStipple* = ptr TAttrStipple
TPangoAttrStipple*{.final, pure.} = object TAttrStipple*{.final, pure.} = object
attr*: TPangoAttribute attr*: TAttribute
stipple*: PBitmap stipple*: PBitmap
PPangoAttrEmbossed* = ptr TPangoAttrEmbossed PAttrEmbossed* = ptr TAttrEmbossed
TPangoAttrEmbossed*{.final, pure.} = object TAttrEmbossed*{.final, pure.} = object
attr*: TPangoAttribute attr*: TAttribute
embossed*: gboolean embossed*: gboolean
PPixmapObject* = ptr TPixmapObject PPixmapObject* = ptr TPixmapObject
@ -1004,21 +1005,21 @@ proc draw_segments*(drawable: PDrawable, gc: PGC, segs: PSegment, nsegs: gint){.
cdecl, dynlib: lib, importc: "gdk_draw_segments".} cdecl, dynlib: lib, importc: "gdk_draw_segments".}
proc draw_lines*(drawable: PDrawable, gc: PGC, points: PPoint, npoints: gint){. proc draw_lines*(drawable: PDrawable, gc: PGC, points: PPoint, npoints: gint){.
cdecl, dynlib: lib, importc: "gdk_draw_lines".} cdecl, dynlib: lib, importc: "gdk_draw_lines".}
proc draw_glyphs*(drawable: PDrawable, gc: PGC, font: PPangoFont, x: gint, proc draw_glyphs*(drawable: PDrawable, gc: PGC, font: PFont, x: gint,
y: gint, glyphs: PPangoGlyphString){.cdecl, dynlib: lib, y: gint, glyphs: PGlyphString){.cdecl, dynlib: lib,
importc: "gdk_draw_glyphs".} importc: "gdk_draw_glyphs".}
proc draw_layout_line*(drawable: PDrawable, gc: PGC, x: gint, y: gint, proc draw_layout_line*(drawable: PDrawable, gc: PGC, x: gint, y: gint,
line: PPangoLayoutLine){.cdecl, dynlib: lib, line: PLayoutLine){.cdecl, dynlib: lib,
importc: "gdk_draw_layout_line".} importc: "gdk_draw_layout_line".}
proc draw_layout*(drawable: PDrawable, gc: PGC, x: gint, y: gint, proc draw_layout*(drawable: PDrawable, gc: PGC, x: gint, y: gint,
layout: PPangoLayout){.cdecl, dynlib: lib, layout: PLayout){.cdecl, dynlib: lib,
importc: "gdk_draw_layout".} importc: "gdk_draw_layout".}
proc draw_layout_line_with_colors*(drawable: PDrawable, gc: PGC, x: gint, proc draw_layout_line_with_colors*(drawable: PDrawable, gc: PGC, x: gint,
y: gint, line: PPangoLayoutLine, y: gint, line: PLayoutLine,
foreground: PColor, background: PColor){. foreground: PColor, background: PColor){.
cdecl, dynlib: lib, importc: "gdk_draw_layout_line_with_colors".} cdecl, dynlib: lib, importc: "gdk_draw_layout_line_with_colors".}
proc draw_layout_with_colors*(drawable: PDrawable, gc: PGC, x: gint, y: gint, proc draw_layout_with_colors*(drawable: PDrawable, gc: PGC, x: gint, y: gint,
layout: PPangoLayout, foreground: PColor, layout: PLayout, foreground: PColor,
background: PColor){.cdecl, dynlib: lib, background: PColor){.cdecl, dynlib: lib,
importc: "gdk_draw_layout_with_colors".} importc: "gdk_draw_layout_with_colors".}
proc drawable_get_image*(drawable: PDrawable, x: gint, y: gint, width: gint, proc drawable_get_image*(drawable: PDrawable, x: gint, y: gint, width: gint,
@ -1035,8 +1036,8 @@ const
EXPOSE* = 2 EXPOSE* = 2
MOTION_NOTIFY* = 3 MOTION_NOTIFY* = 3
BUTTON_PRESS* = 4 BUTTON_PRESS* = 4
2BUTTON_PRESS* = 5 BUTTON2_PRESS* = 5
3BUTTON_PRESS* = 6 BUTTON3_PRESS* = 6
BUTTON_RELEASE* = 7 BUTTON_RELEASE* = 7
KEY_PRESS* = 8 KEY_PRESS* = 8
KEY_RELEASE* = 9 KEY_RELEASE* = 9
@ -1137,7 +1138,7 @@ proc font_load_for_display*(display: PDisplay, font_name: cstring): PFont{.
proc fontset_load_for_display*(display: PDisplay, fontset_name: cstring): PFont{. proc fontset_load_for_display*(display: PDisplay, fontset_name: cstring): PFont{.
cdecl, dynlib: lib, importc: "gdk_fontset_load_for_display".} cdecl, dynlib: lib, importc: "gdk_fontset_load_for_display".}
proc font_from_description_for_display*(display: PDisplay, proc font_from_description_for_display*(display: PDisplay,
font_desc: PPangoFontDescription): PFont{. font_desc: PFontDescription): PFont{.
cdecl, dynlib: lib, importc: "gdk_font_from_description_for_display".} cdecl, dynlib: lib, importc: "gdk_font_from_description_for_display".}
proc font_ref*(font: PFont): PFont{.cdecl, dynlib: lib, importc: "gdk_font_ref".} proc font_ref*(font: PFont): PFont{.cdecl, dynlib: lib, importc: "gdk_font_ref".}
proc font_unref*(font: PFont){.cdecl, dynlib: lib, importc: "gdk_font_unref".} proc font_unref*(font: PFont){.cdecl, dynlib: lib, importc: "gdk_font_unref".}
@ -1311,9 +1312,9 @@ proc device_get_state*(device: PDevice, window: PWindow, axes: Pgdouble,
mask: PModifierType){.cdecl, dynlib: lib, mask: PModifierType){.cdecl, dynlib: lib,
importc: "gdk_device_get_state".} importc: "gdk_device_get_state".}
proc device_get_history*(device: PDevice, window: PWindow, start: guint32, proc device_get_history*(device: PDevice, window: PWindow, start: guint32,
stop: guint32, s: var PPGdkTimeCoord, n_events: Pgint): gboolean{. stop: guint32, s: var PPTimeCoord, n_events: Pgint): gboolean{.
cdecl, dynlib: lib, importc: "gdk_device_get_history".} cdecl, dynlib: lib, importc: "gdk_device_get_history".}
proc device_free_history*(events: PPGdkTimeCoord, n_events: gint){.cdecl, proc device_free_history*(events: PPTimeCoord, n_events: gint){.cdecl,
dynlib: lib, importc: "gdk_device_free_history".} dynlib: lib, importc: "gdk_device_free_history".}
proc device_get_axis*(device: PDevice, axes: Pgdouble, use: TAxisUse, proc device_get_axis*(device: PDevice, axes: Pgdouble, use: TAxisUse,
value: Pgdouble): gboolean{.cdecl, dynlib: lib, value: Pgdouble): gboolean{.cdecl, dynlib: lib,
@ -1348,7 +1349,7 @@ proc keymap_get_entries_for_keycode*(keymap: PKeymap, hardware_keycode: guint,
s: var PKeymapKey, sasdf: var Pguint, s: var PKeymapKey, sasdf: var Pguint,
n_entries: Pgint): gboolean{.cdecl, n_entries: Pgint): gboolean{.cdecl,
dynlib: lib, importc: "gdk_keymap_get_entries_for_keycode".} dynlib: lib, importc: "gdk_keymap_get_entries_for_keycode".}
proc keymap_get_direction*(keymap: PKeymap): TPangoDirection{.cdecl, proc keymap_get_direction*(keymap: PKeymap): TDirection{.cdecl,
dynlib: lib, importc: "gdk_keymap_get_direction".} dynlib: lib, importc: "gdk_keymap_get_direction".}
proc keyval_name*(keyval: guint): cstring{.cdecl, dynlib: lib, proc keyval_name*(keyval: guint): cstring{.cdecl, dynlib: lib,
importc: "gdk_keyval_name".} importc: "gdk_keyval_name".}
@ -2703,21 +2704,21 @@ const
KEY_DongSign* = 0x000020AB KEY_DongSign* = 0x000020AB
KEY_EuroSign* = 0x000020AC KEY_EuroSign* = 0x000020AC
proc pango_context_get_for_screen*(screen: PScreen): PPangoContext{.cdecl, proc pango_context_get_for_screen*(screen: PScreen): PContext{.cdecl,
dynlib: lib, importc: "gdk_pango_context_get_for_screen".} dynlib: lib, importc: "gdk_pango_context_get_for_screen".}
proc pango_context_set_colormap*(context: PPangoContext, colormap: PColormap){. proc pango_context_set_colormap*(context: PContext, colormap: PColormap){.
cdecl, dynlib: lib, importc: "gdk_pango_context_set_colormap".} cdecl, dynlib: lib, importc: "gdk_pango_context_set_colormap".}
proc pango_layout_line_get_clip_region*(line: PPangoLayoutLine, x_origin: gint, proc pango_layout_line_get_clip_region*(line: PLayoutLine, x_origin: gint,
y_origin: gint, index_ranges: Pgint, y_origin: gint, index_ranges: Pgint,
n_ranges: gint): PRegion{.cdecl, n_ranges: gint): PRegion{.cdecl,
dynlib: lib, importc: "gdk_pango_layout_line_get_clip_region".} dynlib: lib, importc: "gdk_pango_layout_line_get_clip_region".}
proc pango_layout_get_clip_region*(layout: PPangoLayout, x_origin: gint, proc pango_layout_get_clip_region*(layout: PLayout, x_origin: gint,
y_origin: gint, index_ranges: Pgint, y_origin: gint, index_ranges: Pgint,
n_ranges: gint): PRegion{.cdecl, dynlib: lib, n_ranges: gint): PRegion{.cdecl, dynlib: lib,
importc: "gdk_pango_layout_get_clip_region".} importc: "gdk_pango_layout_get_clip_region".}
proc pango_attr_stipple_new*(stipple: PBitmap): PPangoAttribute{.cdecl, proc pango_attr_stipple_new*(stipple: PBitmap): PAttribute{.cdecl,
dynlib: lib, importc: "gdk_pango_attr_stipple_new".} dynlib: lib, importc: "gdk_pango_attr_stipple_new".}
proc pango_attr_embossed_new*(embossed: gboolean): PPangoAttribute{.cdecl, proc pango_attr_embossed_new*(embossed: gboolean): PAttribute{.cdecl,
dynlib: lib, importc: "gdk_pango_attr_embossed_new".} dynlib: lib, importc: "gdk_pango_attr_embossed_new".}
proc pixbuf_render_threshold_alpha*(pixbuf: PPixbuf, bitmap: PBitmap, proc pixbuf_render_threshold_alpha*(pixbuf: PPixbuf, bitmap: PBitmap,
src_x: int32, src_y: int32, dest_x: int32, src_x: int32, src_y: int32, dest_x: int32,
@ -3125,14 +3126,14 @@ proc IS_WINDOW_CLASS*(klass: Pointer): bool
proc WINDOW_GET_CLASS*(obj: Pointer): PWindowObjectClass proc WINDOW_GET_CLASS*(obj: Pointer): PWindowObjectClass
proc WINDOW_OBJECT*(anObject: Pointer): PWindowObject proc WINDOW_OBJECT*(anObject: Pointer): PWindowObject
const const
bm_TGdkWindowObject_guffaw_gravity* = 0x0001'i16 bm_TWindowObject_guffaw_gravity* = 0x0001'i16
bp_TGdkWindowObject_guffaw_gravity* = 0'i16 bp_TWindowObject_guffaw_gravity* = 0'i16
bm_TGdkWindowObject_input_only* = 0x0002'i16 bm_TWindowObject_input_only* = 0x0002'i16
bp_TGdkWindowObject_input_only* = 1'i16 bp_TWindowObject_input_only* = 1'i16
bm_TGdkWindowObject_modal_hint* = 0x0004'i16 bm_TWindowObject_modal_hint* = 0x0004'i16
bp_TGdkWindowObject_modal_hint* = 2'i16 bp_TWindowObject_modal_hint* = 2'i16
bm_TGdkWindowObject_destroyed* = 0x0018'i16 bm_TWindowObject_destroyed* = 0x0018'i16
bp_TGdkWindowObject_destroyed* = 3'i16 bp_TWindowObject_destroyed* = 3'i16
proc WindowObject_guffaw_gravity*(a: var TWindowObject): guint proc WindowObject_guffaw_gravity*(a: var TWindowObject): guint
proc WindowObject_set_guffaw_gravity*(a: var TWindowObject, proc WindowObject_set_guffaw_gravity*(a: var TWindowObject,
@ -3802,41 +3803,41 @@ proc WINDOW_OBJECT*(anObject: Pointer): PWindowObject =
result = cast[PWindowObject](WINDOW(anObject)) result = cast[PWindowObject](WINDOW(anObject))
proc WindowObject_guffaw_gravity*(a: var TWindowObject): guint = proc WindowObject_guffaw_gravity*(a: var TWindowObject): guint =
result = (a.flag0 and bm_TGdkWindowObject_guffaw_gravity) shr result = (a.flag0 and bm_TWindowObject_guffaw_gravity) shr
bp_TGdkWindowObject_guffaw_gravity bp_TWindowObject_guffaw_gravity
proc WindowObject_set_guffaw_gravity*(a: var TWindowObject, proc WindowObject_set_guffaw_gravity*(a: var TWindowObject,
`guffaw_gravity`: guint) = `guffaw_gravity`: guint) =
a.flag0 = a.flag0 or a.flag0 = a.flag0 or
(int16(`guffaw_gravity` shl bp_TGdkWindowObject_guffaw_gravity) and (int16(`guffaw_gravity` shl bp_TWindowObject_guffaw_gravity) and
bm_TGdkWindowObject_guffaw_gravity) bm_TWindowObject_guffaw_gravity)
proc WindowObject_input_only*(a: var TWindowObject): guint = proc WindowObject_input_only*(a: var TWindowObject): guint =
result = (a.flag0 and bm_TGdkWindowObject_input_only) shr result = (a.flag0 and bm_TWindowObject_input_only) shr
bp_TGdkWindowObject_input_only bp_TWindowObject_input_only
proc WindowObject_set_input_only*(a: var TWindowObject, `input_only`: guint) = proc WindowObject_set_input_only*(a: var TWindowObject, `input_only`: guint) =
a.flag0 = a.flag0 or a.flag0 = a.flag0 or
(int16(`input_only` shl bp_TGdkWindowObject_input_only) and (int16(`input_only` shl bp_TWindowObject_input_only) and
bm_TGdkWindowObject_input_only) bm_TWindowObject_input_only)
proc WindowObject_modal_hint*(a: var TWindowObject): guint = proc WindowObject_modal_hint*(a: var TWindowObject): guint =
result = (a.flag0 and bm_TGdkWindowObject_modal_hint) shr result = (a.flag0 and bm_TWindowObject_modal_hint) shr
bp_TGdkWindowObject_modal_hint bp_TWindowObject_modal_hint
proc WindowObject_set_modal_hint*(a: var TWindowObject, `modal_hint`: guint) = proc WindowObject_set_modal_hint*(a: var TWindowObject, `modal_hint`: guint) =
a.flag0 = a.flag0 or a.flag0 = a.flag0 or
(int16(`modal_hint` shl bp_TGdkWindowObject_modal_hint) and (int16(`modal_hint` shl bp_TWindowObject_modal_hint) and
bm_TGdkWindowObject_modal_hint) bm_TWindowObject_modal_hint)
proc WindowObject_destroyed*(a: var TWindowObject): guint = proc WindowObject_destroyed*(a: var TWindowObject): guint =
result = (a.flag0 and bm_TGdkWindowObject_destroyed) shr result = (a.flag0 and bm_TWindowObject_destroyed) shr
bp_TGdkWindowObject_destroyed bp_TWindowObject_destroyed
proc WindowObject_set_destroyed*(a: var TWindowObject, `destroyed`: guint) = proc WindowObject_set_destroyed*(a: var TWindowObject, `destroyed`: guint) =
a.flag0 = a.flag0 or a.flag0 = a.flag0 or
(int16(`destroyed` shl bp_TGdkWindowObject_destroyed) and (int16(`destroyed` shl bp_TWindowObject_destroyed) and
bm_TGdkWindowObject_destroyed) bm_TWindowObject_destroyed)
proc ROOT_PARENT*(): PWindow = proc ROOT_PARENT*(): PWindow =
result = get_default_root_window() result = get_default_root_window()

File diff suppressed because it is too large Load diff

View file

@ -67,8 +67,8 @@ type
PSHoption* = ptr TSHoption PSHoption* = ptr TSHoption
Pversion* = ptr Tversion Pversion* = ptr Tversion
Pfd_set* = pointer Pfd_set* = pointer
P* = ptr T PCurl* = ptr TCurl
T* = pointer TCurl* = pointer
Thttppost*{.final, pure.} = object Thttppost*{.final, pure.} = object
next*: Phttppost next*: Phttppost
name*: cstring name*: cstring
@ -84,8 +84,8 @@ type
showfilename*: cstring showfilename*: cstring
Tprogress_callback* = proc (clientp: pointer, dltotal: float64, Tprogress_callback* = proc (clientp: pointer, dltotal: float64,
dlnow: float64, ultotal: float64, ulnow: float64): int32{. dlnow: float64, ultotal: float64,
cdecl.} ulnow: float64): int32 {.cdecl.}
Twrite_callback* = proc (buffer: cstring, size: int, nitems: int, Twrite_callback* = proc (buffer: cstring, size: int, nitems: int,
outstream: pointer): int{.cdecl.} outstream: pointer): int{.cdecl.}
Tread_callback* = proc (buffer: cstring, size: int, nitems: int, Tread_callback* = proc (buffer: cstring, size: int, nitems: int,
@ -96,7 +96,7 @@ type
IOE_OK, IOE_UNKNOWNCMD, IOE_FAILRESTART, IOE_LAST IOE_OK, IOE_UNKNOWNCMD, IOE_FAILRESTART, IOE_LAST
Tiocmd* = enum Tiocmd* = enum
IOCMD_NOP, IOCMD_RESTARTREAD, IOCMD_LAST IOCMD_NOP, IOCMD_RESTARTREAD, IOCMD_LAST
Tioctl_callback* = proc (handle: P, cmd: int32, clientp: pointer): Tioerr{. Tioctl_callback* = proc (handle: PCurl, cmd: int32, clientp: pointer): Tioerr{.
cdecl.} cdecl.}
Tmalloc_callback* = proc (size: int): pointer{.cdecl.} Tmalloc_callback* = proc (size: int): pointer{.cdecl.}
Tfree_callback* = proc (p: pointer){.cdecl.} Tfree_callback* = proc (p: pointer){.cdecl.}
@ -106,7 +106,7 @@ type
Tinfotype* = enum Tinfotype* = enum
INFO_TEXT = 0, INFO_HEADER_IN, INFO_HEADER_OUT, INFO_DATA_IN, INFO_DATA_OUT, INFO_TEXT = 0, INFO_HEADER_IN, INFO_HEADER_OUT, INFO_DATA_IN, INFO_DATA_OUT,
INFO_SSL_DATA_IN, INFO_SSL_DATA_OUT, INFO_END INFO_SSL_DATA_IN, INFO_SSL_DATA_OUT, INFO_END
Tdebug_callback* = proc (handle: P, theType: Tinfotype, data: cstring, Tdebug_callback* = proc (handle: PCurl, theType: Tinfotype, data: cstring,
size: int, userptr: pointer): int32{.cdecl.} size: int, userptr: pointer): int32{.cdecl.}
Tcode* = enum Tcode* = enum
E_OK = 0, E_UNSUPPORTED_PROTOCOL, E_FAILED_INIT, E_URL_MALFORMAT, E_OK = 0, E_UNSUPPORTED_PROTOCOL, E_FAILED_INIT, E_URL_MALFORMAT,
@ -134,7 +134,7 @@ type
E_TFTP_ILLEGAL, E_TFTP_UNKNOWNID, E_TFTP_EXISTS, E_TFTP_NOSUCHUSER, E_TFTP_ILLEGAL, E_TFTP_UNKNOWNID, E_TFTP_EXISTS, E_TFTP_NOSUCHUSER,
E_CONV_FAILED, E_CONV_REQD, LAST E_CONV_FAILED, E_CONV_REQD, LAST
Tconv_callback* = proc (buffer: cstring, len: int): Tcode{.cdecl.} Tconv_callback* = proc (buffer: cstring, len: int): Tcode{.cdecl.}
Tssl_ctx_callback* = proc (: P, ssl_ctx, userptr: pointer): Tcode{.cdecl.} Tssl_ctx_callback* = proc (curl: PCurl, ssl_ctx, userptr: pointer): Tcode{.cdecl.}
Tproxytype* = enum Tproxytype* = enum
PROXY_HTTP = 0, PROXY_SOCKS4 = 4, PROXY_SOCKS5 = 5 PROXY_HTTP = 0, PROXY_SOCKS4 = 4, PROXY_SOCKS5 = 5
Tftpssl* = enum Tftpssl* = enum
@ -269,9 +269,10 @@ type
Tlock_access* = enum Tlock_access* = enum
LOCK_ACCESS_NONE = 0, LOCK_ACCESS_SHARED = 1, LOCK_ACCESS_SINGLE = 2, LOCK_ACCESS_NONE = 0, LOCK_ACCESS_SHARED = 1, LOCK_ACCESS_SINGLE = 2,
LOCK_ACCESS_LAST LOCK_ACCESS_LAST
Tlock_function* = proc (handle: P, data: Tlock_data, locktype: Tlock_access, Tlock_function* = proc (handle: PCurl, data: Tlock_data,
locktype: Tlock_access,
userptr: pointer){.cdecl.} userptr: pointer){.cdecl.}
Tunlock_function* = proc (handle: P, data: Tlock_data, userptr: pointer){. Tunlock_function* = proc (handle: PCurl, data: Tlock_data, userptr: pointer){.
cdecl.} cdecl.}
TSH* = pointer TSH* = pointer
TSHcode* = enum TSHcode* = enum
@ -305,14 +306,14 @@ type
MSG_NONE, MSG_DONE, MSG_LAST MSG_NONE, MSG_DONE, MSG_LAST
TMsg*{.pure, final.} = object TMsg*{.pure, final.} = object
msg*: TMSGEnum msg*: TMSGEnum
easy_handle*: P easy_handle*: PCurl
whatever*: Pointer #data : record whatever*: Pointer #data : record
# case longint of # case longint of
# 0 : ( whatever : pointer ); # 0 : ( whatever : pointer );
# 1 : ( result : CURLcode ); # 1 : ( result : CURLcode );
# end; # end;
Tsocket_callback* = proc (easy: P, s: Tsocket, what: int32, Tsocket_callback* = proc (easy: PCurl, s: Tsocket, what: int32,
userp, socketp: pointer): int32{.cdecl.} userp, socketp: pointer): int32{.cdecl.}
TMoption* = enum TMoption* = enum
MOPT_SOCKETDATA = 10000 + 2, MOPT_LASTENTRY = 10000 + 3, MOPT_SOCKETDATA = 10000 + 2, MOPT_LASTENTRY = 10000 + 3,
@ -419,11 +420,11 @@ proc formfree*(form: Phttppost){.cdecl, dynlib: libname,
proc getenv*(variable: cstring): cstring{.cdecl, dynlib: libname, proc getenv*(variable: cstring): cstring{.cdecl, dynlib: libname,
importc: "curl_getenv".} importc: "curl_getenv".}
proc version*(): cstring{.cdecl, dynlib: libname, importc: "curl_version".} proc version*(): cstring{.cdecl, dynlib: libname, importc: "curl_version".}
proc easy_escape*(handle: P, str: cstring, len: int32): cstring{.cdecl, proc easy_escape*(handle: PCurl, str: cstring, len: int32): cstring{.cdecl,
dynlib: libname, importc: "curl_easy_escape".} dynlib: libname, importc: "curl_easy_escape".}
proc escape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname, proc escape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname,
importc: "curl_escape".} importc: "curl_escape".}
proc easy_unescape*(handle: P, str: cstring, len: int32, outlength: var int32): cstring{. proc easy_unescape*(handle: PCurl, str: cstring, len: int32, outlength: var int32): cstring{.
cdecl, dynlib: libname, importc: "curl_easy_unescape".} cdecl, dynlib: libname, importc: "curl_easy_unescape".}
proc unescape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname, proc unescape*(str: cstring, len: int32): cstring{.cdecl, dynlib: libname,
importc: "curl_unescape".} importc: "curl_unescape".}
@ -435,7 +436,7 @@ proc global_init_mem*(flags: int32, m: Tmalloc_callback, f: Tfree_callback,
c: Tcalloc_callback): Tcode{.cdecl, dynlib: libname, c: Tcalloc_callback): Tcode{.cdecl, dynlib: libname,
importc: "curl_global_init_mem".} importc: "curl_global_init_mem".}
proc global_cleanup*(){.cdecl, dynlib: libname, importc: "curl_global_cleanup".} proc global_cleanup*(){.cdecl, dynlib: libname, importc: "curl_global_cleanup".}
proc slist_append*(slist: Pslist, P: cstring): Pslist{.cdecl, dynlib: libname, proc slist_append*(slist: Pslist, p: cstring): Pslist{.cdecl, dynlib: libname,
importc: "curl_slist_append".} importc: "curl_slist_append".}
proc slist_free_all*(para1: Pslist){.cdecl, dynlib: libname, proc slist_free_all*(para1: Pslist){.cdecl, dynlib: libname,
importc: "curl_slist_free_all".} importc: "curl_slist_free_all".}
@ -452,21 +453,21 @@ proc easy_strerror*(para1: Tcode): cstring{.cdecl, dynlib: libname,
importc: "curl_easy_strerror".} importc: "curl_easy_strerror".}
proc share_strerror*(para1: TSHcode): cstring{.cdecl, dynlib: libname, proc share_strerror*(para1: TSHcode): cstring{.cdecl, dynlib: libname,
importc: "curl_share_strerror".} importc: "curl_share_strerror".}
proc easy_init*(): P{.cdecl, dynlib: libname, importc: "curl_easy_init".} proc easy_init*(): PCurl{.cdecl, dynlib: libname, importc: "curl_easy_init".}
proc easy_setopt*(: P, option: Toption): Tcode{.cdecl, varargs, dynlib: libname, proc easy_setopt*(curl: PCurl, option: Toption): Tcode{.cdecl, varargs, dynlib: libname,
importc: "curl_easy_setopt".} importc: "curl_easy_setopt".}
proc easy_perform*(: P): Tcode{.cdecl, dynlib: libname, proc easy_perform*(curl: PCurl): Tcode{.cdecl, dynlib: libname,
importc: "curl_easy_perform".} importc: "curl_easy_perform".}
proc easy_cleanup*(: P){.cdecl, dynlib: libname, importc: "curl_easy_cleanup".} proc easy_cleanup*(curl: PCurl){.cdecl, dynlib: libname, importc: "curl_easy_cleanup".}
proc easy_getinfo*(: P, info: TINFO): Tcode{.cdecl, varargs, dynlib: libname, proc easy_getinfo*(curl: PCurl, info: TINFO): Tcode{.cdecl, varargs, dynlib: libname,
importc: "curl_easy_getinfo".} importc: "curl_easy_getinfo".}
proc easy_duphandle*(: P): P{.cdecl, dynlib: libname, proc easy_duphandle*(curl: PCurl): PCurl{.cdecl, dynlib: libname,
importc: "curl_easy_duphandle".} importc: "curl_easy_duphandle".}
proc easy_reset*(: P){.cdecl, dynlib: libname, importc: "curl_easy_reset".} proc easy_reset*(curl: PCurl){.cdecl, dynlib: libname, importc: "curl_easy_reset".}
proc multi_init*(): PM{.cdecl, dynlib: libname, importc: "curl_multi_init".} proc multi_init*(): PM{.cdecl, dynlib: libname, importc: "curl_multi_init".}
proc multi_add_handle*(multi_handle: PM, handle: P): TMcode{.cdecl, proc multi_add_handle*(multi_handle: PM, handle: PCurl): TMcode{.cdecl,
dynlib: libname, importc: "curl_multi_add_handle".} dynlib: libname, importc: "curl_multi_add_handle".}
proc multi_remove_handle*(multi_handle: PM, handle: P): TMcode{.cdecl, proc multi_remove_handle*(multi_handle: PM, handle: PCurl): TMcode{.cdecl,
dynlib: libname, importc: "curl_multi_remove_handle".} dynlib: libname, importc: "curl_multi_remove_handle".}
proc multi_fdset*(multi_handle: PM, read_fd_set: Pfd_set, write_fd_set: Pfd_set, proc multi_fdset*(multi_handle: PM, read_fd_set: Pfd_set, write_fd_set: Pfd_set,
exc_fd_set: Pfd_set, max_fd: var int32): TMcode{.cdecl, exc_fd_set: Pfd_set, max_fd: var int32): TMcode{.cdecl,

View file

@ -24,89 +24,89 @@
import import
lua lua
proc lua_pushstring*(L: Plua_State, s: string) proc pushstring*(L: PState, s: string)
# compatibilty macros # compatibilty macros
proc getn*(L: Plua_State, n: int): int proc getn*(L: PState, n: int): int
# calls lua_objlen # calls lua_objlen
proc setn*(L: Plua_State, t, n: int) proc setn*(L: PState, t, n: int)
# does nothing! # does nothing!
type type
Treg*{.final.} = object Treg*{.final.} = object
name*: cstring name*: cstring
func*: lua_CFunction func*: CFunction
Preg* = ptr Treg Preg* = ptr Treg
proc openlib*(L: Plua_State, libname: cstring, lr: Preg, nup: int){.cdecl, proc openlib*(L: PState, libname: cstring, lr: Preg, nup: int){.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_openlib".} dynlib: LIB_NAME, importc: "luaL_openlib".}
proc register*(L: Plua_State, libname: cstring, lr: Preg){.cdecl, proc register*(L: PState, libname: cstring, lr: Preg){.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_register".} dynlib: LIB_NAME, importc: "luaL_register".}
proc getmetafield*(L: Plua_State, obj: int, e: cstring): int{.cdecl, proc getmetafield*(L: PState, obj: int, e: cstring): int{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_getmetafield".} dynlib: LIB_NAME, importc: "luaL_getmetafield".}
proc callmeta*(L: Plua_State, obj: int, e: cstring): int{.cdecl, proc callmeta*(L: PState, obj: int, e: cstring): int{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_callmeta".} dynlib: LIB_NAME, importc: "luaL_callmeta".}
proc typerror*(L: Plua_State, narg: int, tname: cstring): int{.cdecl, proc typerror*(L: PState, narg: int, tname: cstring): int{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_typerror".} dynlib: LIB_NAME, importc: "luaL_typerror".}
proc argerror*(L: Plua_State, numarg: int, extramsg: cstring): int{.cdecl, proc argerror*(L: PState, numarg: int, extramsg: cstring): int{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_argerror".} dynlib: LIB_NAME, importc: "luaL_argerror".}
proc checklstring*(L: Plua_State, numArg: int, l_: Psize_t): cstring{.cdecl, proc checklstring*(L: PState, numArg: int, l_: Psize_t): cstring{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_checklstring".} dynlib: LIB_NAME, importc: "luaL_checklstring".}
proc optlstring*(L: Plua_State, numArg: int, def: cstring, l_: Psize_t): cstring{. proc optlstring*(L: PState, numArg: int, def: cstring, l_: Psize_t): cstring{.
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_optlstring".} cdecl, dynlib: LIB_NAME, importc: "luaL_optlstring".}
proc checknumber*(L: Plua_State, numArg: int): lua_Number{.cdecl, proc checknumber*(L: PState, numArg: int): lua_Number{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_checknumber".} dynlib: LIB_NAME, importc: "luaL_checknumber".}
proc optnumber*(L: Plua_State, nArg: int, def: lua_Number): lua_Number{.cdecl, proc optnumber*(L: PState, nArg: int, def: lua_Number): lua_Number{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_optnumber".} dynlib: LIB_NAME, importc: "luaL_optnumber".}
proc checkinteger*(L: Plua_State, numArg: int): lua_Integer{.cdecl, proc checkinteger*(L: PState, numArg: int): lua_Integer{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_checkinteger".} dynlib: LIB_NAME, importc: "luaL_checkinteger".}
proc optinteger*(L: Plua_State, nArg: int, def: lua_Integer): lua_Integer{. proc optinteger*(L: PState, nArg: int, def: lua_Integer): lua_Integer{.
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_optinteger".} cdecl, dynlib: LIB_NAME, importc: "luaL_optinteger".}
proc checkstack*(L: Plua_State, sz: int, msg: cstring){.cdecl, proc checkstack*(L: PState, sz: int, msg: cstring){.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_checkstack".} dynlib: LIB_NAME, importc: "luaL_checkstack".}
proc checktype*(L: Plua_State, narg, t: int){.cdecl, dynlib: LUA_LIB_NAME, proc checktype*(L: PState, narg, t: int){.cdecl, dynlib: LIB_NAME,
importc: "luaL_checktype".} importc: "luaL_checktype".}
proc checkany*(L: Plua_State, narg: int){.cdecl, dynlib: LUA_LIB_NAME, proc checkany*(L: PState, narg: int){.cdecl, dynlib: LIB_NAME,
importc: "luaL_checkany".} importc: "luaL_checkany".}
proc newmetatable*(L: Plua_State, tname: cstring): int{.cdecl, proc newmetatable*(L: PState, tname: cstring): int{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_newmetatable".} dynlib: LIB_NAME, importc: "luaL_newmetatable".}
proc checkudata*(L: Plua_State, ud: int, tname: cstring): Pointer{.cdecl, proc checkudata*(L: PState, ud: int, tname: cstring): Pointer{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_checkudata".} dynlib: LIB_NAME, importc: "luaL_checkudata".}
proc where*(L: Plua_State, lvl: int){.cdecl, dynlib: LUA_LIB_NAME, proc where*(L: PState, lvl: int){.cdecl, dynlib: LIB_NAME,
importc: "luaL_where".} importc: "luaL_where".}
proc error*(L: Plua_State, fmt: cstring): int{.cdecl, varargs, proc error*(L: PState, fmt: cstring): int{.cdecl, varargs,
dynlib: LUA_LIB_NAME, importc: "luaL_error".} dynlib: LIB_NAME, importc: "luaL_error".}
proc checkoption*(L: Plua_State, narg: int, def: cstring, lst: cstringArray): int{. proc checkoption*(L: PState, narg: int, def: cstring, lst: cstringArray): int{.
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_checkoption".} cdecl, dynlib: LIB_NAME, importc: "luaL_checkoption".}
proc ref*(L: Plua_State, t: int): int{.cdecl, dynlib: LUA_LIB_NAME, proc ref*(L: PState, t: int): int{.cdecl, dynlib: LIB_NAME,
importc: "luaL_ref".} importc: "luaL_ref".}
proc unref*(L: Plua_State, t, theref: int){.cdecl, dynlib: LUA_LIB_NAME, proc unref*(L: PState, t, theref: int){.cdecl, dynlib: LIB_NAME,
importc: "luaL_unref".} importc: "luaL_unref".}
proc loadfile*(L: Plua_State, filename: cstring): int{.cdecl, proc loadfile*(L: PState, filename: cstring): int{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_loadfile".} dynlib: LIB_NAME, importc: "luaL_loadfile".}
proc loadbuffer*(L: Plua_State, buff: cstring, size: size_t, name: cstring): int{. proc loadbuffer*(L: PState, buff: cstring, size: size_t, name: cstring): int{.
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_loadbuffer".} cdecl, dynlib: LIB_NAME, importc: "luaL_loadbuffer".}
proc loadstring*(L: Plua_State, s: cstring): int{.cdecl, dynlib: LUA_LIB_NAME, proc loadstring*(L: PState, s: cstring): int{.cdecl, dynlib: LIB_NAME,
importc: "luaL_loadstring".} importc: "luaL_loadstring".}
proc newstate*(): Plua_State{.cdecl, dynlib: LUA_LIB_NAME, proc newstate*(): PState{.cdecl, dynlib: LIB_NAME,
importc: "luaL_newstate".} importc: "luaL_newstate".}
proc lua_open*(): Plua_State proc lua_open*(): PState
# compatibility; moved from unit lua to lauxlib because it needs luaL_newstate # compatibility; moved from unit lua to lauxlib because it needs luaL_newstate
# #
#** =============================================================== #** ===============================================================
#** some useful macros #** some useful macros
#** =============================================================== #** ===============================================================
# #
proc argcheck*(L: Plua_State, cond: bool, numarg: int, extramsg: cstring) proc argcheck*(L: PState, cond: bool, numarg: int, extramsg: cstring)
proc checkstring*(L: Plua_State, n: int): cstring proc checkstring*(L: PState, n: int): cstring
proc optstring*(L: Plua_State, n: int, d: cstring): cstring proc optstring*(L: PState, n: int, d: cstring): cstring
proc checkint*(L: Plua_State, n: int): int proc checkint*(L: PState, n: int): int
proc checklong*(L: Plua_State, n: int): int32 proc checklong*(L: PState, n: int): int32
proc optint*(L: Plua_State, n: int, d: float64): int proc optint*(L: PState, n: int, d: float64): int
proc optlong*(L: Plua_State, n: int, d: float64): int32 proc optlong*(L: PState, n: int, d: float64): int32
proc typename*(L: Plua_State, i: int): cstring proc typename*(L: PState, i: int): cstring
proc lua_dofile*(L: Plua_State, filename: cstring): int proc lua_dofile*(L: PState, filename: cstring): int
proc lua_dostring*(L: Plua_State, str: cstring): int proc lua_dostring*(L: PState, str: cstring): int
proc lua_Lgetmetatable*(L: Plua_State, tname: cstring) proc lua_Lgetmetatable*(L: PState, tname: cstring)
# not translated: # not translated:
# #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) # #define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
# #
@ -121,7 +121,7 @@ type
Buffer*{.final.} = object Buffer*{.final.} = object
p*: cstring # current position in buffer p*: cstring # current position in buffer
lvl*: int # number of strings in the stack (level) lvl*: int # number of strings in the stack (level)
L*: Plua_State L*: PState
buffer*: array[0..BUFFERSIZE - 1, Char] # warning: see note above about LUAL_BUFFERSIZE buffer*: array[0..BUFFERSIZE - 1, Char] # warning: see note above about LUAL_BUFFERSIZE
PBuffer* = ptr Buffer PBuffer* = ptr Buffer
@ -132,82 +132,82 @@ proc addchar*(B: PBuffer, c: Char)
proc putchar*(B: PBuffer, c: Char) proc putchar*(B: PBuffer, c: Char)
# warning: see note above about LUAL_BUFFERSIZE # warning: see note above about LUAL_BUFFERSIZE
proc addsize*(B: PBuffer, n: int) proc addsize*(B: PBuffer, n: int)
proc buffinit*(L: Plua_State, B: PBuffer){.cdecl, dynlib: LUA_LIB_NAME, proc buffinit*(L: PState, B: PBuffer){.cdecl, dynlib: LIB_NAME,
importc: "luaL_buffinit".} importc: "luaL_buffinit".}
proc prepbuffer*(B: PBuffer): cstring{.cdecl, dynlib: LUA_LIB_NAME, proc prepbuffer*(B: PBuffer): cstring{.cdecl, dynlib: LIB_NAME,
importc: "luaL_prepbuffer".} importc: "luaL_prepbuffer".}
proc addlstring*(B: PBuffer, s: cstring, L: size_t){.cdecl, proc addlstring*(B: PBuffer, s: cstring, L: size_t){.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_addlstring".} dynlib: LIB_NAME, importc: "luaL_addlstring".}
proc addstring*(B: PBuffer, s: cstring){.cdecl, dynlib: LUA_LIB_NAME, proc addstring*(B: PBuffer, s: cstring){.cdecl, dynlib: LIB_NAME,
importc: "luaL_addstring".} importc: "luaL_addstring".}
proc addvalue*(B: PBuffer){.cdecl, dynlib: LUA_LIB_NAME, proc addvalue*(B: PBuffer){.cdecl, dynlib: LIB_NAME,
importc: "luaL_addvalue".} importc: "luaL_addvalue".}
proc pushresult*(B: PBuffer){.cdecl, dynlib: LUA_LIB_NAME, proc pushresult*(B: PBuffer){.cdecl, dynlib: LIB_NAME,
importc: "luaL_pushresult".} importc: "luaL_pushresult".}
proc gsub*(L: Plua_State, s, p, r: cstring): cstring{.cdecl, proc gsub*(L: PState, s, p, r: cstring): cstring{.cdecl,
dynlib: LUA_LIB_NAME, importc: "luaL_gsub".} dynlib: LIB_NAME, importc: "luaL_gsub".}
proc findtable*(L: Plua_State, idx: int, fname: cstring, szhint: int): cstring{. proc findtable*(L: PState, idx: int, fname: cstring, szhint: int): cstring{.
cdecl, dynlib: LUA_LIB_NAME, importc: "luaL_findtable".} cdecl, dynlib: LIB_NAME, importc: "luaL_findtable".}
# compatibility with ref system # compatibility with ref system
# pre-defined references # pre-defined references
const const
LUA_NOREF* = - 2 LUA_NOREF* = - 2
LUA_REFNIL* = - 1 LUA_REFNIL* = - 1
proc lua_unref*(L: Plua_State, theref: int) proc lua_unref*(L: PState, theref: int)
proc lua_getref*(L: Plua_State, theref: int) proc lua_getref*(L: PState, theref: int)
# #
#** Compatibility macros and functions #** Compatibility macros and functions
# #
# implementation # implementation
proc lua_pushstring(L: Plua_State, s: string) = proc lua_pushstring(L: PState, s: string) =
lua_pushlstring(L, cstring(s), len(s)) lua_pushlstring(L, cstring(s), len(s))
proc getn(L: Plua_State, n: int): int = proc getn(L: PState, n: int): int =
Result = lua_objlen(L, n) Result = lua_objlen(L, n)
proc setn(L: Plua_State, t, n: int) = proc setn(L: PState, t, n: int) =
# does nothing as this operation is deprecated # does nothing as this operation is deprecated
nil nil
proc lua_open(): Plua_State = proc lua_open(): PState =
Result = newstate() Result = newstate()
proc typename(L: Plua_State, i: int): cstring = proc typename(L: PState, i: int): cstring =
Result = lua_typename(L, lua_type(L, i)) Result = lua_typename(L, lua_type(L, i))
proc lua_dofile(L: Plua_State, filename: cstring): int = proc lua_dofile(L: PState, filename: cstring): int =
Result = loadfile(L, filename) Result = loadfile(L, filename)
if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0) if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0)
proc lua_dostring(L: Plua_State, str: cstring): int = proc lua_dostring(L: PState, str: cstring): int =
Result = loadstring(L, str) Result = loadstring(L, str)
if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0) if Result == 0: Result = lua_pcall(L, 0, LUA_MULTRET, 0)
proc lua_Lgetmetatable(L: Plua_State, tname: cstring) = proc lua_Lgetmetatable(L: PState, tname: cstring) =
lua_getfield(L, LUA_REGISTRYINDEX, tname) lua_getfield(L, LUA_REGISTRYINDEX, tname)
proc argcheck(L: Plua_State, cond: bool, numarg: int, extramsg: cstring) = proc argcheck(L: PState, cond: bool, numarg: int, extramsg: cstring) =
if not cond: if not cond:
discard argerror(L, numarg, extramsg) discard argerror(L, numarg, extramsg)
proc checkstring(L: Plua_State, n: int): cstring = proc checkstring(L: PState, n: int): cstring =
Result = checklstring(L, n, nil) Result = checklstring(L, n, nil)
proc optstring(L: Plua_State, n: int, d: cstring): cstring = proc optstring(L: PState, n: int, d: cstring): cstring =
Result = optlstring(L, n, d, nil) Result = optlstring(L, n, d, nil)
proc checkint(L: Plua_State, n: int): int = proc checkint(L: PState, n: int): int =
Result = toInt(checknumber(L, n)) Result = toInt(checknumber(L, n))
proc checklong(L: Plua_State, n: int): int32 = proc checklong(L: PState, n: int): int32 =
Result = int32(ToInt(checknumber(L, n))) Result = int32(ToInt(checknumber(L, n)))
proc optint(L: Plua_State, n: int, d: float64): int = proc optint(L: PState, n: int, d: float64): int =
Result = int(ToInt(optnumber(L, n, d))) Result = int(ToInt(optnumber(L, n, d)))
proc optlong(L: Plua_State, n: int, d: float64): int32 = proc optlong(L: PState, n: int, d: float64): int32 =
Result = int32(ToInt(optnumber(L, n, d))) Result = int32(ToInt(optnumber(L, n, d)))
proc addchar(B: PBuffer, c: Char) = proc addchar(B: PBuffer, c: Char) =
@ -222,8 +222,8 @@ proc putchar(B: PBuffer, c: Char) =
proc addsize(B: PBuffer, n: int) = proc addsize(B: PBuffer, n: int) =
B.p = cast[cstring](cast[int](B.p) + n) B.p = cast[cstring](cast[int](B.p) + n)
proc lua_unref(L: Plua_State, theref: int) = proc lua_unref(L: PState, theref: int) =
unref(L, LUA_REGISTRYINDEX, theref) unref(L, LUA_REGISTRYINDEX, theref)
proc lua_getref(L: Plua_State, theref: int) = proc lua_getref(L: PState, theref: int) =
lua_rawgeti(L, LUA_REGISTRYINDEX, theref) lua_rawgeti(L, LUA_REGISTRYINDEX, theref)

View file

@ -47,9 +47,7 @@ else:
const const
NAME* = "lua(|5.2|5.1|5.0).dll" NAME* = "lua(|5.2|5.1|5.0).dll"
LIB_NAME* = "lua(|5.2|5.1|5.0).dll" LIB_NAME* = "lua(|5.2|5.1|5.0).dll"
type
size_t* = int
Psize_t* = ptr size_t
const const
VERSION* = "Lua 5.1" VERSION* = "Lua 5.1"
@ -67,7 +65,7 @@ const
proc upvalueindex*(I: int): int proc upvalueindex*(I: int): int
const # thread status; 0 is OK const # thread status; 0 is OK
YIELD_* = 1 constYIELD* = 1
ERRRUN* = 2 ERRRUN* = 2
ERRSYNTAX* = 3 ERRSYNTAX* = 3
ERRMEM* = 4 ERRMEM* = 4
@ -82,9 +80,9 @@ type
# #
type type
Reader* = proc (L: PState, ud: Pointer, sz: Psize_t): cstring{.cdecl.} Reader* = proc (L: PState, ud: Pointer, sz: ptr int): cstring{.cdecl.}
Writer* = proc (L: PState, p: Pointer, sz: size_t, ud: Pointer): int{.cdecl.} Writer* = proc (L: PState, p: Pointer, sz: int, ud: Pointer): int{.cdecl.}
Alloc* = proc (ud, theptr: Pointer, osize, nsize: size_t){.cdecl.} Alloc* = proc (ud, theptr: Pointer, osize, nsize: int){.cdecl.}
const const
TNONE* = - 1 TNONE* = - 1
@ -129,7 +127,7 @@ proc iscfunction*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
importc: "lua_iscfunction".} importc: "lua_iscfunction".}
proc isuserdata*(L: PState, idx: int): cint{.cdecl, dynlib: NAME, proc isuserdata*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
importc: "lua_isuserdata".} importc: "lua_isuserdata".}
proc type*(L: PState, idx: int): int{.cdecl, dynlib: NAME, importc: "lua_type".} proc luatype*(L: PState, idx: int): int{.cdecl, dynlib: NAME, importc: "lua_type".}
proc typename*(L: PState, tp: int): cstring{.cdecl, dynlib: NAME, proc typename*(L: PState, tp: int): cstring{.cdecl, dynlib: NAME,
importc: "lua_typename".} importc: "lua_typename".}
proc equal*(L: PState, idx1, idx2: int): cint{.cdecl, dynlib: NAME, proc equal*(L: PState, idx1, idx2: int): cint{.cdecl, dynlib: NAME,
@ -144,9 +142,9 @@ proc tointeger*(L: PState, idx: int): Integer{.cdecl, dynlib: NAME,
importc: "lua_tointeger".} importc: "lua_tointeger".}
proc toboolean*(L: PState, idx: int): cint{.cdecl, dynlib: NAME, proc toboolean*(L: PState, idx: int): cint{.cdecl, dynlib: NAME,
importc: "lua_toboolean".} importc: "lua_toboolean".}
proc tolstring*(L: PState, idx: int, length: Psize_t): cstring{.cdecl, proc tolstring*(L: PState, idx: int, length: ptr int): cstring{.cdecl,
dynlib: NAME, importc: "lua_tolstring".} dynlib: NAME, importc: "lua_tolstring".}
proc objlen*(L: PState, idx: int): size_t{.cdecl, dynlib: NAME, proc objlen*(L: PState, idx: int): int{.cdecl, dynlib: NAME,
importc: "lua_objlen".} importc: "lua_objlen".}
proc tocfunction*(L: PState, idx: int): CFunction{.cdecl, dynlib: NAME, proc tocfunction*(L: PState, idx: int): CFunction{.cdecl, dynlib: NAME,
importc: "lua_tocfunction".} importc: "lua_tocfunction".}
@ -161,7 +159,7 @@ proc pushnumber*(L: PState, n: Number){.cdecl, dynlib: NAME,
importc: "lua_pushnumber".} importc: "lua_pushnumber".}
proc pushinteger*(L: PState, n: Integer){.cdecl, dynlib: NAME, proc pushinteger*(L: PState, n: Integer){.cdecl, dynlib: NAME,
importc: "lua_pushinteger".} importc: "lua_pushinteger".}
proc pushlstring*(L: PState, s: cstring, l_: size_t){.cdecl, dynlib: NAME, proc pushlstring*(L: PState, s: cstring, l_: int){.cdecl, dynlib: NAME,
importc: "lua_pushlstring".} importc: "lua_pushlstring".}
proc pushstring*(L: PState, s: cstring){.cdecl, dynlib: NAME, proc pushstring*(L: PState, s: cstring){.cdecl, dynlib: NAME,
importc: "lua_pushstring".} importc: "lua_pushstring".}
@ -185,7 +183,7 @@ proc rawgeti*(L: PState, idx, n: int){.cdecl, dynlib: NAME,
importc: "lua_rawgeti".} importc: "lua_rawgeti".}
proc createtable*(L: PState, narr, nrec: int){.cdecl, dynlib: NAME, proc createtable*(L: PState, narr, nrec: int){.cdecl, dynlib: NAME,
importc: "lua_createtable".} importc: "lua_createtable".}
proc newuserdata*(L: PState, sz: size_t): Pointer{.cdecl, dynlib: NAME, proc newuserdata*(L: PState, sz: int): Pointer{.cdecl, dynlib: NAME,
importc: "lua_newuserdata".} importc: "lua_newuserdata".}
proc getmetatable*(L: PState, objindex: int): int{.cdecl, dynlib: NAME, proc getmetatable*(L: PState, objindex: int): int{.cdecl, dynlib: NAME,
importc: "lua_getmetatable".} importc: "lua_getmetatable".}
@ -211,7 +209,7 @@ proc load*(L: PState, reader: Reader, dt: Pointer, chunkname: cstring): int{.
cdecl, dynlib: NAME, importc: "lua_load".} cdecl, dynlib: NAME, importc: "lua_load".}
proc dump*(L: PState, writer: Writer, data: Pointer): int{.cdecl, dynlib: NAME, proc dump*(L: PState, writer: Writer, data: Pointer): int{.cdecl, dynlib: NAME,
importc: "lua_dump".} importc: "lua_dump".}
proc yield*(L: PState, nresults: int): int{.cdecl, dynlib: NAME, proc luayield*(L: PState, nresults: int): int{.cdecl, dynlib: NAME,
importc: "lua_yield".} importc: "lua_yield".}
proc resume*(L: PState, narg: int): int{.cdecl, dynlib: NAME, proc resume*(L: PState, narg: int): int{.cdecl, dynlib: NAME,
importc: "lua_resume".} importc: "lua_resume".}
@ -249,7 +247,7 @@ proc pop*(L: PState, n: int)
proc newtable*(L: Pstate) proc newtable*(L: Pstate)
proc register*(L: PState, n: cstring, f: CFunction) proc register*(L: PState, n: cstring, f: CFunction)
proc pushcfunction*(L: PState, f: CFunction) proc pushcfunction*(L: PState, f: CFunction)
proc strlen*(L: Pstate, i: int): size_t proc strlen*(L: Pstate, i: int): int
proc isfunction*(L: PState, n: int): bool proc isfunction*(L: PState, n: int): bool
proc istable*(L: PState, n: int): bool proc istable*(L: PState, n: int): bool
proc islightuserdata*(L: PState, n: int): bool proc islightuserdata*(L: PState, n: int): bool
@ -295,7 +293,7 @@ const
IDSIZE* = 60 IDSIZE* = 60
type type
Debug*{.final.} = object # activation record TDebug*{.final.} = object # activation record
event*: int event*: int
name*: cstring # (n) name*: cstring # (n)
namewhat*: cstring # (n) `global', `local', `field', `method' namewhat*: cstring # (n) `global', `local', `field', `method'
@ -309,7 +307,7 @@ type
# private part # private part
i_ci*: int # active function i_ci*: int # active function
PDebug* = ptr Debug PDebug* = ptr TDebug
Hook* = proc (L: PState, ar: PDebug){.cdecl.} Hook* = proc (L: PState, ar: PDebug){.cdecl.}
# #
@ -355,32 +353,32 @@ proc register(L: PState, n: cstring, f: CFunction) =
proc pushcfunction(L: PState, f: CFunction) = proc pushcfunction(L: PState, f: CFunction) =
pushcclosure(L, f, 0) pushcclosure(L, f, 0)
proc strlen(L: PState, i: int): size_t = proc strlen(L: PState, i: int): int =
Result = objlen(L, i) Result = objlen(L, i)
proc isfunction(L: PState, n: int): bool = proc isfunction(L: PState, n: int): bool =
Result = type(L, n) == TFUNCTION Result = luatype(L, n) == TFUNCTION
proc istable(L: PState, n: int): bool = proc istable(L: PState, n: int): bool =
Result = type(L, n) == TTABLE Result = luatype(L, n) == TTABLE
proc islightuserdata(L: PState, n: int): bool = proc islightuserdata(L: PState, n: int): bool =
Result = type(L, n) == TLIGHTUSERDATA Result = luatype(L, n) == TLIGHTUSERDATA
proc isnil(L: PState, n: int): bool = proc isnil(L: PState, n: int): bool =
Result = type(L, n) == TNIL Result = luatype(L, n) == TNIL
proc isboolean(L: PState, n: int): bool = proc isboolean(L: PState, n: int): bool =
Result = type(L, n) == TBOOLEAN Result = luatype(L, n) == TBOOLEAN
proc isthread(L: PState, n: int): bool = proc isthread(L: PState, n: int): bool =
Result = type(L, n) == TTHREAD Result = luatype(L, n) == TTHREAD
proc isnone(L: PState, n: int): bool = proc isnone(L: PState, n: int): bool =
Result = type(L, n) == TNONE Result = luatype(L, n) == TNONE
proc isnoneornil(L: PState, n: int): bool = proc isnoneornil(L: PState, n: int): bool =
Result = type(L, n) <= 0 Result = luatype(L, n) <= 0
proc pushliteral(L: PState, s: cstring) = proc pushliteral(L: PState, s: cstring) =
pushlstring(L, s, len(s)) pushlstring(L, s, len(s))

View file

@ -20,7 +20,7 @@
# #
import import
lua
const const
COLIBNAME* = "coroutine" COLIBNAME* = "coroutine"
@ -45,30 +45,22 @@ proc open_debug*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
importc: "luaopen_debug".} importc: "luaopen_debug".}
proc open_package*(L: PState): cint{.cdecl, dynlib: LIB_NAME, proc open_package*(L: PState): cint{.cdecl, dynlib: LIB_NAME,
importc: "luaopen_package".} importc: "luaopen_package".}
proc L_openlibs*(L: PState){.cdecl, dynlib: LIB_NAME, importc: "luaL_openlibs".} proc openlibs*(L: PState){.cdecl, dynlib: LIB_NAME, importc: "luaL_openlibs".}
# compatibility code
proc baselibopen*(L: PState): Bool
proc tablibopen*(L: PState): Bool
proc iolibopen*(L: PState): Bool
proc strlibopen*(L: PState): Bool
proc mathlibopen*(L: PState): Bool
proc dblibopen*(L: PState): Bool
# implementation
proc baselibopen(L: PState): Bool = proc baselibopen*(L: PState): Bool =
Result = open_base(L) != 0'i32 Result = open_base(L) != 0'i32
proc tablibopen(L: PState): Bool = proc tablibopen*(L: PState): Bool =
Result = open_table(L) != 0'i32 Result = open_table(L) != 0'i32
proc iolibopen(L: PState): Bool = proc iolibopen*(L: PState): Bool =
Result = open_io(L) != 0'i32 Result = open_io(L) != 0'i32
proc strlibopen(L: PState): Bool = proc strlibopen*(L: PState): Bool =
Result = open_string(L) != 0'i32 Result = open_string(L) != 0'i32
proc mathlibopen(L: PState): Bool = proc mathlibopen*(L: PState): Bool =
Result = open_math(L) != 0'i32 Result = open_math(L) != 0'i32
proc dblibopen(L: PState): Bool = proc dblibopen*(L: PState): Bool =
Result = open_debug(L) != 0'i32 Result = open_debug(L) != 0'i32

View file

@ -752,7 +752,7 @@ type
THandle* = int #SDL_types.h types THandle* = int #SDL_types.h types
# Basic data types # Basic data types
TBool* = enum TBool* = enum
FALSE, TRUE sdlFALSE, sdlTRUE
PUInt8Array* = ptr TUInt8Array PUInt8Array* = ptr TUInt8Array
PUInt8* = ptr UInt8 PUInt8* = ptr UInt8
PPUInt8* = ptr PUInt8 PPUInt8* = ptr PUInt8

View file

@ -18,7 +18,7 @@
# #
import import
sdl
when defined(windows): when defined(windows):
const const

View file

@ -129,7 +129,7 @@
#****************************************************************************** #******************************************************************************
import import
sdl
when defined(windows): when defined(windows):
const const
@ -224,19 +224,9 @@ proc IMG_LoadXV_RW*(src: PRWops): PSurface{.cdecl, importc: "IMG_LoadXV_RW",
dynlib: ImageLibName.} dynlib: ImageLibName.}
proc IMG_ReadXPMFromArray*(xpm: cstringArray): PSurface{.cdecl, proc IMG_ReadXPMFromArray*(xpm: cstringArray): PSurface{.cdecl,
importc: "IMG_ReadXPMFromArray", dynlib: ImageLibName.} importc: "IMG_ReadXPMFromArray", dynlib: ImageLibName.}
# Error Macros
# We'll use SDL for reporting errors
proc IMG_SetError*(fmt: cstring)
proc IMG_GetError*(): cstring
# implementation
proc IMAGE_VERSION(X: var TVersion) = proc IMAGE_VERSION(X: var TVersion) =
X.major = IMAGE_MAJOR_VERSION X.major = IMAGE_MAJOR_VERSION
X.minor = IMAGE_MINOR_VERSION X.minor = IMAGE_MINOR_VERSION
X.patch = IMAGE_PATCHLEVEL X.patch = IMAGE_PATCHLEVEL
proc IMG_SetError(fmt: cstring) =
SetError(fmt)
proc IMG_GetError(): cstring =
result = GetError()

View file

@ -149,7 +149,7 @@
#****************************************************************************** #******************************************************************************
import import
, smpeg sdl, smpeg
when defined(windows): when defined(windows):
const const
@ -161,25 +161,22 @@ else:
const const
MixerLibName = "libSDL_mixer.so" MixerLibName = "libSDL_mixer.so"
const const
MIXER_MAJOR_VERSION* = 1'i8 MAJOR_VERSION* = 1'i8
MIXER_MINOR_VERSION* = 2'i8 MINOR_VERSION* = 2'i8
MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility PATCHLEVEL* = 7'i8 # Backwards compatibility
MIX_MAJOR_VERSION* = MIXER_MAJOR_VERSION
MIX_MINOR_VERSION* = MIXER_MINOR_VERSION CHANNELS* = 8 # Good default values for a PC soundcard
MIX_PATCHLEVEL* = MIXER_PATCHLEVEL # SDL_Mixer.h constants DEFAULT_FREQUENCY* = 22050
# The default mixer has 8 simultaneous mixing channels
MIX_CHANNELS* = 8 # Good default values for a PC soundcard
MIX_DEFAULT_FREQUENCY* = 22050
when defined(IA32): when defined(IA32):
const const
MIX_DEFAULT_FORMAT* = AUDIO_S16LSB DEFAULT_FORMAT* = AUDIO_S16LSB
else: else:
const const
MIX_DEFAULT_FORMAT* = AUDIO_S16MSB DEFAULT_FORMAT* = AUDIO_S16MSB
const const
MIX_DEFAULT_CHANNELS* = 2 DEFAULT_CHANNELS* = 2
MIX_MAX_VOLUME* = 128 # Volume of a chunk MAX_VOLUME* = 128 # Volume of a chunk
PATH_MAX* = 255 # mikmod.h constants PATH_MAX* = 255 # mikmod.h constants
#* #*
# * Library version # * Library version
@ -254,34 +251,20 @@ type #music_cmd.h types
PUNIMOD* = ptr TUNIMOD PUNIMOD* = ptr TUNIMOD
TUNIMOD* = TMODULE #SDL_mixer.h types TUNIMOD* = TMODULE #SDL_mixer.h types
# The internal format for an audio chunk # The internal format for an audio chunk
PMix_Chunk* = ptr TMix_Chunk PChunk* = ptr TChunk
TMix_Chunk*{.final.} = object TChunk*{.final.} = object
allocated*: int allocated*: int
abuf*: PUint8 abuf*: PUint8
alen*: Uint32 alen*: Uint32
volume*: Uint8 # Per-sample volume, 0-128 volume*: Uint8 # Per-sample volume, 0-128
Mix_Chunk* = TMix_Chunk # The different fading types supported TFading* = enum
TMix_Fading* = enum
MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
Mix_Fading* = TMix_Fading TMusicType* = enum
TMix_MusicType* = enum
MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3 MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3
Mix_MusicType* = TMix_MusicType # PMusic* = ptr TMusic
# TMusicUnion = record TMusic*{.final.} = object # The internal format for a music chunk interpreted via mikmod
# case XXX: Byte of mixtype*: TMusicType # other fields are not aviable
# 0 : ( cmd : PMusicCMD );
# 1 : ( wave : PWAVStream );
# 2 : ( module : PUNIMOD );
# 3 : ( midi : TMidiSong );
# 4 : ( ogg : POGG_music );
# {$IFNDEF DARWIN}
# 5 : ( mp3 : PSMPEG );
# {$ENDIF}
# end;
PMix_Music* = ptr TMix_Music
TMix_Music*{.final.} = object # The internal format for a music chunk interpreted via mikmod
type_*: TMix_MusicType # other fields are not aviable
# data : TMusicUnion; # data : TMusicUnion;
# fading : TMix_Fading; # fading : TMix_Fading;
# fade_volume : integer; # fade_volume : integer;
@ -293,14 +276,14 @@ type #music_cmd.h types
cdecl.} # This macro can be used to fill a version structure with the compile-time cdecl.} # This macro can be used to fill a version structure with the compile-time
# version of the SDL_mixer library. # version of the SDL_mixer library.
proc MIXER_VERSION*(X: var TVersion) proc VERSION*(X: var sdl.TVersion)
# This function gets the version of the dynamically linked SDL_mixer library. # This function gets the version of the dynamically linked SDL_mixer library.
# It should NOT be used to fill a version structure, instead you should use the # It should NOT be used to fill a version structure, instead you should use the
# SDL_MIXER_VERSION() macro. # SDL_MIXER_VERSION() macro.
proc Mix_Linked_Version*(): Pversion{.cdecl, importc: "Mix_Linked_Version", proc Linked_Version*(): sdl.Pversion{.cdecl, importc: "Mix_Linked_Version",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Open the mixer with a certain audio format # Open the mixer with a certain audio format
proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int, proc OpenAudio*(frequency: int, format: Uint16, channels: int,
chunksize: int): int{.cdecl, importc: "Mix_OpenAudio", chunksize: int): int{.cdecl, importc: "Mix_OpenAudio",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Dynamically change the number of channels managed by the mixer. # Dynamically change the number of channels managed by the mixer.
@ -308,456 +291,193 @@ proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int,
# stopped. # stopped.
# This function returns the new number of allocated channels. # This function returns the new number of allocated channels.
# #
proc Mix_AllocateChannels*(numchannels: int): int{.cdecl, proc AllocateChannels*(numchannels: int): int{.cdecl,
importc: "Mix_AllocateChannels", dynlib: MixerLibName.} importc: "Mix_AllocateChannels", dynlib: MixerLibName.}
# Find out what the actual audio device parameters are. # Find out what the actual audio device parameters are.
# This function returns 1 if the audio has been opened, 0 otherwise. # This function returns 1 if the audio has been opened, 0 otherwise.
# #
proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{. proc QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{.
cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.} cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}
# Load a wave file or a music (.mod .s3m .it .xm) file # Load a wave file or a music (.mod .s3m .it .xm) file
proc Mix_LoadWAV_RW*(src: PRWops, freesrc: int): PMix_Chunk{.cdecl, proc LoadWAV_RW*(src: PRWops, freesrc: int): PChunk{.cdecl,
importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.} importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}
proc Mix_LoadWAV*(filename: cstring): PMix_Chunk proc LoadWAV*(filename: cstring): PChunk
proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl, importc: "Mix_LoadMUS", proc LoadMUS*(filename: cstring): PMusic{.cdecl, importc: "Mix_LoadMUS",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Load a wave file of the mixer format from a memory buffer # Load a wave file of the mixer format from a memory buffer
proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl, proc QuickLoad_WAV*(mem: PUint8): PChunk{.cdecl,
importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.} importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.}
# Free an audio chunk previously loaded # Free an audio chunk previously loaded
proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc: "Mix_FreeChunk", proc FreeChunk*(chunk: PChunk){.cdecl, importc: "Mix_FreeChunk",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc: "Mix_FreeMusic", proc FreeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Find out the music format of a mixer music, or the currently playing # Find out the music format of a mixer music, or the currently playing
# music, if 'music' is NULL. # music, if 'music' is NULL.
proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl, proc GetMusicType*(music: PMusic): TMusicType{.cdecl,
importc: "Mix_GetMusicType", dynlib: MixerLibName.} importc: "Mix_GetMusicType", dynlib: MixerLibName.}
# Set a function that is called after all mixing is performed. # Set a function that is called after all mixing is performed.
# This can be used to provide real-time visual display of the audio stream # This can be used to provide real-time visual display of the audio stream
# or add a custom mixer filter for the stream data. # or add a custom mixer filter for the stream data.
# #
proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl, proc SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl,
importc: "Mix_SetPostMix", dynlib: MixerLibName.} importc: "Mix_SetPostMix", dynlib: MixerLibName.}
# Add your own music player or additional mixer function. # Add your own music player or additional mixer function.
# If 'mix_func' is NULL, the default music player is re-enabled. # If 'mix_func' is NULL, the default music player is re-enabled.
# #
proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl, proc HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl,
importc: "Mix_HookMusic", dynlib: MixerLibName.} importc: "Mix_HookMusic", dynlib: MixerLibName.}
# Add your own callback when the music has finished playing. # Add your own callback when the music has finished playing.
# #
proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl, proc HookMusicFinished*(music_finished: Pointer){.cdecl,
importc: "Mix_HookMusicFinished", dynlib: MixerLibName.} importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}
# Get a pointer to the user data for the current music hook # Get a pointer to the user data for the current music hook
proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc: "Mix_GetMusicHookData", proc GetMusicHookData*(): Pointer{.cdecl, importc: "Mix_GetMusicHookData",
dynlib: MixerLibName.} dynlib: MixerLibName.}
#* Add your own callback when a channel has finished playing. NULL #* Add your own callback when a channel has finished playing. NULL
# * to disable callback.* # * to disable callback.*
type type
TChannel_finished* = proc (channel: int){.cdecl.} TChannel_finished* = proc (channel: int){.cdecl.}
proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl, proc ChannelFinished*(channel_finished: TChannel_finished){.cdecl,
importc: "Mix_ChannelFinished", dynlib: MixerLibName.} importc: "Mix_ChannelFinished", dynlib: MixerLibName.}
const const
MIX_CHANNEL_POST* = - 2 # This is the format of a special effect callback: CHANNEL_POST* = - 2
# myeffect(int chan, void *stream, int len, void *udata);
#
# (chan) is the channel number that your effect is affecting. (stream) is
# the buffer of data to work upon. (len) is the size of (stream), and
# (udata) is a user-defined bit of data, which you pass as the last arg of
# Mix_RegisterEffect(), and is passed back unmolested to your callback.
# Your effect changes the contents of (stream) based on whatever parameters
# are significant, or just leaves it be, if you prefer. You can do whatever
# you like to the buffer, though, and it will continue in its changed state
# down the mixing pipeline, through any other effect functions, then finally
# to be mixed with the rest of the channels and music for the final output
# stream.
#
type type
TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int, TEffectFunc* = proc (chan: int, stream: Pointer, length: int,
udata: Pointer): Pointer{.cdecl.} # * This is a callback that signifies that a channel has finished all its udata: Pointer): Pointer{.cdecl.}
# * loops and has completed playback. This gets called if the buffer TEffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.}
# * plays out normally, or if you call Mix_HaltChannel(), implicitly stop proc RegisterEffect*(chan: int, f: TEffectFunc, d: TEffectDone,
# * a channel via
# Mix_AllocateChannels(), or unregister a callback while
# * it's still playing.
TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.} #* Register a special effect function. At mixing time, the channel data is
# * copied into a buffer and passed through each registered effect function.
# * After it passes through all the functions, it is mixed into the final
# * output stream. The copy to buffer is performed once, then each effect
# * function performs on the output of the previous effect. Understand that
# * this extra copy to a buffer is not performed if there are no effects
# * registered for a given chunk, which saves CPU cycles, and any given
# * effect will be extra cycles, too, so it is crucial that your code run
# * fast. Also note that the data that your function is given is in the
# * format of the sound device, and not the format you gave to Mix_OpenAudio(),
# * although they may in reality be the same. This is an unfortunate but
# * necessary speed concern. Use Mix_QuerySpec() to determine if you can
# * handle the data before you register your effect, and take appropriate
# * actions.
# * You may also specify a callback (Mix_EffectDone_t) that is called when
# * the channel finishes playing. This gives you a more fine-grained control
# * than Mix_ChannelFinished(), in case you need to free effect-specific
# * resources, etc. If you don't need this, you can specify NULL.
# * You may set the callbacks before or after calling Mix_PlayChannel().
# * Things like Mix_SetPanning() are just internal special effect functions,
# * so if you are using that, you've already incurred the overhead of a copy
# * to a separate buffer, and that these effects will be in the queue with
# * any functions you've registered. The list of registered effects for a
# * channel is reset when a chunk finishes playing, so you need to explicitly
# * set them with each call to Mix_PlayChannel*().
# * You may also register a special effect function that is to be run after
# * final mixing occurs. The rules for these callbacks are identical to those
# * in Mix_RegisterEffect, but they are run after all the channels and the
# * music have been mixed into a single stream, whereas channel-specific
# * effects run on a given channel before any other mixing occurs. These
# * global effect callbacks are call "posteffects". Posteffects only have
# * their Mix_EffectDone_t function called when they are unregistered (since
# * the main output stream is never "done" in the same sense as a channel).
# * You must unregister them manually when you've had enough. Your callback
# * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
# * processing is considered a posteffect.
# *
# * After all these effects have finished processing, the callback registered
# * through Mix_SetPostMix() runs, and then the stream goes to the audio
# * device.
# *
# * returns zero if error (no such channel), nonzero if added.
# * Error messages can be retrieved from Mix_GetError().
# *
proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone,
arg: Pointer): int{.cdecl, arg: Pointer): int{.cdecl,
importc: "Mix_RegisterEffect", dynlib: MixerLibName.} importc: "Mix_RegisterEffect", dynlib: MixerLibName.}
#* You may not need to call this explicitly, unless you need to stop an
# * effect from processing in the middle of a chunk's playback. proc UnregisterEffect*(channel: int, f: TEffectFunc): int{.cdecl,
# * Posteffects are never implicitly unregistered as they are for channels,
# * but they may be explicitly unregistered through this function by
# * specifying MIX_CHANNEL_POST for a channel.
# * returns zero if error (no such channel or effect), nonzero if removed.
# * Error messages can be retrieved from Mix_GetError().
# *
proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl,
importc: "Mix_UnregisterEffect", dynlib: MixerLibName.} importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
#* You may not need to call this explicitly, unless you need to stop all
# * effects from processing in the middle of a chunk's playback. Note that proc UnregisterAllEffects*(channel: int): int{.cdecl,
# * this will also shut off some internal effect processing, since
# * Mix_SetPanning( ) and others may use this API under the hood.This is
# * called internally when a channel completes playback.
# * Posteffects are never implicitly unregistered as they are for channels,
# * but they may be explicitly unregistered through this function by
# * specifying MIX_CHANNEL_POST for a channel.
# * returns zero if error( no such channel ), nonzero if all effects removed.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl,
importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.} importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
const const
MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED" # * These are the internally - defined mixing effects.They use the same API that EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
# * effects defined in the application use, but are provided here as a proc SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl,
# * convenience.Some effects can reduce their quality or use more memory in
# * the name of speed; to enable this, make sure the environment variable
# * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
# * Mix_OpenAudio( ).
# *
#* set the panning of a channel.The left and right channels are specified
# * as integers between 0 and 255, quietest to loudest, respectively.
# *
# * Technically, this is just individual volume control for a sample with
# * two( stereo )channels, so it can be used for more than just panning.
# * if you want real panning, call it like this :
# *
# * Mix_SetPanning( channel, left, 255 - left );
# *
# * ...which isn't so hard.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the panning will be done to the final mixed stream before passing it on
# * to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally, and returns without
# * registering the effect function if the audio device is not configured
# * for stereo output.Setting both( left ) and ( right ) to 255 causes this
# * effect to be unregistered, since that is the data's normal state.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if panning effect enabled.Note that an audio device in mono
# * mode is a no - op, but this call will return successful in that case .
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl,
importc: "Mix_SetPanning", dynlib: MixerLibName.} importc: "Mix_SetPanning", dynlib: MixerLibName.}
# * set the position ofa channel.( angle ) is an integer from 0 to 360, that
# * specifies the location of the sound in relation to the listener.( angle ) proc SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
# * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
# * Angle 0 is due north, and rotates clockwise as the value increases.
# * for efficiency, the precision of this effect may be limited( angles 1
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
# * ( distance ) is an integer between 0 and 255 that specifies the space
# * between the sound and the listener.The larger the number, the further
# * away the sound is .Using 255 does not guarantee that the channel will be
# * culled from the mixing process or be completely silent.For efficiency,
# * the precision of this effect may be limited( distance 0 through 5 might
# * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
# * and ( distance ) to 0 unregisters this effect, since the data would be
# * unchanged.
# *
# * if you need more precise positional audio, consider using OpenAL for
# * spatialized effects instead of SDL_mixer.This is only meant to be a
# * basic effect for simple "3D" games.
# *
# * if the audio device is configured for mono output, then you won't get
# * any effectiveness from the angle; however, distance attenuation on the
# * channel will still occur.While this effect will function with stereo
# * voices, it makes more sense to use voices with only one channel of sound,
# * so when they are mixed through this effect, the positioning will sound
# * correct.You can convert them to mono through SDL before giving them to
# * the mixer in the first place if you like.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the positioning will be done to the final mixed stream before passing it
# * on to the audio device.
# *
# * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if position effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
importc: "Mix_SetPosition", dynlib: MixerLibName.} importc: "Mix_SetPosition", dynlib: MixerLibName.}
#* set the "distance" of a channel.( distance ) is an integer from 0 to 255
# * that specifies the location of the sound in relation to the listener. proc SetDistance*(channel: int, distance: Uint8): int{.cdecl,
# * Distance 0 is overlapping the listener, and 255 is as far away as possible
# * A distance of 255 does not guarantee silence; in such a case , you might
# * want to try changing the chunk's volume, or just cull the sample from the
# * mixing process with Mix_HaltChannel( ).
# * for efficiency, the precision of this effect may be limited( distances 1
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
# * ( distance ) is an integer between 0 and 255 that specifies the space
# * between the sound and the listener.The larger the number, the further
# * away the sound is .
# * Setting( distance ) to 0 unregisters this effect, since the data would be
# * unchanged.
# * if you need more precise positional audio, consider using OpenAL for
# * spatialized effects instead of SDL_mixer.This is only meant to be a
# * basic effect for simple "3D" games.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the distance attenuation will be done to the final mixed stream before
# * passing it on to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if position effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl,
importc: "Mix_SetDistance", dynlib: MixerLibName.} importc: "Mix_SetDistance", dynlib: MixerLibName.}
# *
# * !!! FIXME : Haven't implemented, since the effect goes past the proc SetReverseStereo*(channel: int, flip: int): int{.cdecl,
# * end of the sound buffer.Will have to think about this.
# * - -ryan.
# * /
# { if 0
# { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
# * of echo to mix.0 is no echo, 255 is infinite( and probably not
# * what you want ).
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the reverbing will be done to the final mixed stream before passing it on
# * to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
# * of zero, the effect is unregistered, as the data is already in that state.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if reversing effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
# extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
# #E ndif
# * Causes a channel to reverse its stereo.This is handy if the user has his
# * speakers hooked up backwards, or you would like to have a minor bit of
# * psychedelia in your sound code. : )Calling this function with ( flip )
# * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
# * the effect is unregistered.
# *
# * This uses the Mix_RegisterEffect( )API internally, and thus is probably
# * more CPU intensive than having the user just plug in his speakers
# * correctly.Mix_SetReverseStereo( )returns without registering the effect
# * function if the audio device is not configured for stereo output.
# *
# * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
# * on the final mixed stream before sending it on to the audio device( a
# * posteffect ).
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if reversing effect is enabled.Note that an audio device in mono
# * mode is a no - op, but this call will return successful in that case .
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl,
importc: "Mix_SetReverseStereo", dynlib: MixerLibName.} importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}
# end of effects API. - -ryan. *
# Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate proc ReserveChannels*(num: int): int{.cdecl, importc: "Mix_ReserveChannels",
# them dynamically to the next sample if requested with a -1 value below.
# Returns the number of reserved channels.
#
proc Mix_ReserveChannels*(num: int): int{.cdecl, importc: "Mix_ReserveChannels",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Channel grouping functions
# Attach a tag to a channel. A tag can be assigned to several mixer proc GroupChannel*(which: int, tag: int): int{.cdecl,
# channels, to form groups of channels.
# If 'tag' is -1, the tag is removed (actually -1 is the tag used to
# represent the group of all the channels).
# Returns true if everything was OK.
#
proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl,
importc: "Mix_GroupChannel", dynlib: MixerLibName.} importc: "Mix_GroupChannel", dynlib: MixerLibName.}
# Assign several consecutive channels to a group proc GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl,
proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl,
importc: "Mix_GroupChannels", dynlib: MixerLibName.} importc: "Mix_GroupChannels", dynlib: MixerLibName.}
# Finds the first available channel in a group of channels proc GroupAvailable*(tag: int): int{.cdecl, importc: "Mix_GroupAvailable",
proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc: "Mix_GroupAvailable",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Returns the number of channels in a group. This is also a subtle proc GroupCount*(tag: int): int{.cdecl, importc: "Mix_GroupCount",
# way to get the total number of channels when 'tag' is -1
#
proc Mix_GroupCount*(tag: int): int{.cdecl, importc: "Mix_GroupCount",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Finds the "oldest" sample playing in a group of channels proc GroupOldest*(tag: int): int{.cdecl, importc: "Mix_GroupOldest",
proc Mix_GroupOldest*(tag: int): int{.cdecl, importc: "Mix_GroupOldest",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Finds the "most recent" (i.e. last) sample playing in a group of channels proc GroupNewer*(tag: int): int{.cdecl, importc: "Mix_GroupNewer",
proc Mix_GroupNewer*(tag: int): int{.cdecl, importc: "Mix_GroupNewer",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# The same as above, but the sound is played at most 'ticks' milliseconds proc PlayChannelTimed*(channel: int, chunk: PChunk, loops: int,
proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int,
ticks: int): int{.cdecl, ticks: int): int{.cdecl,
importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.} importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}
# Play an audio chunk on a specific channel. proc PlayChannel*(channel: int, chunk: PChunk, loops: int): int
# If the specified channel is -1, play on the first free channel. proc PlayMusic*(music: PMusic, loops: int): int{.cdecl,
# If 'loops' is greater than zero, loop the sound that many times.
# If 'loops' is -1, loop inifinitely (~65000 times).
# Returns which channel was used to play the sound.
#
proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int
proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl,
importc: "Mix_PlayMusic", dynlib: MixerLibName.} importc: "Mix_PlayMusic", dynlib: MixerLibName.}
# Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions proc FadeInMusic*(music: PMusic, loops: int, ms: int): int{.cdecl,
proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl,
importc: "Mix_FadeInMusic", dynlib: MixerLibName.} importc: "Mix_FadeInMusic", dynlib: MixerLibName.}
proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, proc FadeInChannelTimed*(channel: int, chunk: PChunk, loops: int,
ms: int, ticks: int): int{.cdecl, ms: int, ticks: int): int{.cdecl,
importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.} importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}
proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int proc FadeInChannel*(channel: int, chunk: PChunk, loops: int, ms: int): int
# Set the volume in the range of 0-128 of a specific channel or chunk.
# If the specified channel is -1, set volume for all channels. proc Volume*(channel: int, volume: int): int{.cdecl, importc: "Mix_Volume",
# Returns the original volume.
# If the specified volume is -1, just return the current volume.
#
proc Mix_Volume*(channel: int, volume: int): int{.cdecl, importc: "Mix_Volume",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl, proc VolumeChunk*(chunk: PChunk, volume: int): int{.cdecl,
importc: "Mix_VolumeChunk", dynlib: MixerLibName.} importc: "Mix_VolumeChunk", dynlib: MixerLibName.}
proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc: "Mix_VolumeMusic", proc VolumeMusic*(volume: int): int{.cdecl, importc: "Mix_VolumeMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Halt playing of a particular channel
proc Mix_HaltChannel*(channel: int): int{.cdecl, importc: "Mix_HaltChannel", proc HaltChannel*(channel: int): int{.cdecl, importc: "Mix_HaltChannel",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_HaltGroup*(tag: int): int{.cdecl, importc: "Mix_HaltGroup", proc HaltGroup*(tag: int): int{.cdecl, importc: "Mix_HaltGroup",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_HaltMusic*(): int{.cdecl, importc: "Mix_HaltMusic", proc HaltMusic*(): int{.cdecl, importc: "Mix_HaltMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Change the expiration delay for a particular channel. # Change the expiration delay for a particular channel.
# The sample will stop playing after the 'ticks' milliseconds have elapsed, # The sample will stop playing after the 'ticks' milliseconds have elapsed,
# or remove the expiration if 'ticks' is -1 # or remove the expiration if 'ticks' is -1
# #
proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl, proc ExpireChannel*(channel: int, ticks: int): int{.cdecl,
importc: "Mix_ExpireChannel", dynlib: MixerLibName.} importc: "Mix_ExpireChannel", dynlib: MixerLibName.}
# Halt a channel, fading it out progressively till it's silent # Halt a channel, fading it out progressively till it's silent
# The ms parameter indicates the number of milliseconds the fading # The ms parameter indicates the number of milliseconds the fading
# will take. # will take.
# #
proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl, proc FadeOutChannel*(which: int, ms: int): int{.cdecl,
importc: "Mix_FadeOutChannel", dynlib: MixerLibName.} importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}
proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, proc FadeOutGroup*(tag: int, ms: int): int{.cdecl,
importc: "Mix_FadeOutGroup", dynlib: MixerLibName.} importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}
proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc: "Mix_FadeOutMusic", proc FadeOutMusic*(ms: int): int{.cdecl, importc: "Mix_FadeOutMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Query the fading status of a channel # Query the fading status of a channel
proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc: "Mix_FadingMusic", proc FadingMusic*(): TFading{.cdecl, importc: "Mix_FadingMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl, proc FadingChannel*(which: int): TFading{.cdecl,
importc: "Mix_FadingChannel", dynlib: MixerLibName.} importc: "Mix_FadingChannel", dynlib: MixerLibName.}
# Pause/Resume a particular channel
proc Mix_Pause*(channel: int){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.} proc Pause*(channel: int){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}
proc Mix_Resume*(channel: int){.cdecl, importc: "Mix_Resume", proc Resume*(channel: int){.cdecl, importc: "Mix_Resume",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_Paused*(channel: int): int{.cdecl, importc: "Mix_Paused", proc Paused*(channel: int): int{.cdecl, importc: "Mix_Paused",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Pause/Resume the music stream
proc Mix_PauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.} proc PauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.}
proc Mix_ResumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.} proc ResumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.}
proc Mix_RewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.} proc RewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.}
proc Mix_PausedMusic*(): int{.cdecl, importc: "Mix_PausedMusic", proc PausedMusic*(): int{.cdecl, importc: "Mix_PausedMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Set the current position in the music stream.
# This returns 0 if successful, or -1 if it failed or isn't implemented. proc SetMusicPosition*(position: float64): int{.cdecl,
# This function is only implemented for MOD music formats (set pattern
# order number) and for OGG music (set position in seconds), at the
# moment.
#
proc Mix_SetMusicPosition*(position: float64): int{.cdecl,
importc: "Mix_SetMusicPosition", dynlib: MixerLibName.} importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}
# Check the status of a specific channel.
# If the specified channel is -1, check all channels. proc Playing*(channel: int): int{.cdecl, importc: "Mix_Playing",
#
proc Mix_Playing*(channel: int): int{.cdecl, importc: "Mix_Playing",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_PlayingMusic*(): int{.cdecl, importc: "Mix_PlayingMusic", proc PlayingMusic*(): int{.cdecl, importc: "Mix_PlayingMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Stop music and set external music playback command
proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc: "Mix_SetMusicCMD", proc SetMusicCMD*(command: cstring): int{.cdecl, importc: "Mix_SetMusicCMD",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Synchro value is set by MikMod from modules while playing
proc Mix_SetSynchroValue*(value: int): int{.cdecl, proc SetSynchroValue*(value: int): int{.cdecl,
importc: "Mix_SetSynchroValue", dynlib: MixerLibName.} importc: "Mix_SetSynchroValue", dynlib: MixerLibName.}
proc Mix_GetSynchroValue*(): int{.cdecl, importc: "Mix_GetSynchroValue", proc GetSynchroValue*(): int{.cdecl, importc: "Mix_GetSynchroValue",
dynlib: MixerLibName.} dynlib: MixerLibName.}
#
# Get the Mix_Chunk currently associated with a mixer channel proc GetChunk*(channel: int): PChunk{.cdecl, importc: "Mix_GetChunk",
# Returns nil if it's an invalid channel, or there's no chunk associated.
#
proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc: "Mix_GetChunk",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Close the mixer, halting all playing audio
proc Mix_CloseAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
# We'll use SDL for reporting errors
proc Mix_SetError*(fmt: cstring)
proc Mix_GetError*(): cstring
# implementation
proc MIXER_VERSION(X: var Tversion) = proc CloseAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
X.major = MIXER_MAJOR_VERSION
X.minor = MIXER_MINOR_VERSION
X.patch = MIXER_PATCHLEVEL
proc Mix_LoadWAV(filename: cstring): PMix_Chunk = proc VERSION(X: var sdl.Tversion) =
result = Mix_LoadWAV_RW(RWFromFile(filename, "rb"), 1) X.major = MAJOR_VERSION
X.minor = MINOR_VERSION
X.patch = PATCHLEVEL
proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int = proc LoadWAV(filename: cstring): PChunk =
result = Mix_PlayChannelTimed(channel, chunk, loops, - 1) result = LoadWAV_RW(RWFromFile(filename, "rb"), 1)
proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int = proc PlayChannel(channel: int, chunk: PChunk, loops: int): int =
result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1) result = PlayChannelTimed(channel, chunk, loops, - 1)
proc Mix_SetError(fmt: cstring) = proc FadeInChannel(channel: int, chunk: PChunk, loops: int, ms: int): int =
SetError(fmt) result = FadeInChannelTimed(channel, chunk, loops, ms, - 1)
proc Mix_GetError(): cstring =
result = GetError()

View file

@ -3,7 +3,7 @@
#****************************************************************************** #******************************************************************************
import import
sdl
when defined(windows): when defined(windows):
const const
@ -15,29 +15,24 @@ else:
const const
MixerLibName = "libSDL_mixer.so" MixerLibName = "libSDL_mixer.so"
const const
MIXER_MAJOR_VERSION* = 1'i8 MAJOR_VERSION* = 1'i8
MIXER_MINOR_VERSION* = 2'i8 MINOR_VERSION* = 2'i8
MIXER_PATCHLEVEL* = 7'i8 # Backwards compatibility PATCHLEVEL* = 7'i8 # Backwards compatibility
MIX_MAJOR_VERSION* = MIXER_MAJOR_VERSION
MIX_MINOR_VERSION* = MIXER_MINOR_VERSION CHANNELS* = 8 # Good default values for a PC soundcard
MIX_PATCHLEVEL* = MIXER_PATCHLEVEL # SDL_Mixer.h constants DEFAULT_FREQUENCY* = 22050
# The default mixer has 8 simultaneous mixing channels
MIX_CHANNELS* = 8 # Good default values for a PC soundcard
MIX_DEFAULT_FREQUENCY* = 22050
when defined(IA32): when defined(IA32):
const const
MIX_DEFAULT_FORMAT* = AUDIO_S16LSB DEFAULT_FORMAT* = AUDIO_S16LSB
else: else:
const const
MIX_DEFAULT_FORMAT* = AUDIO_S16MSB DEFAULT_FORMAT* = AUDIO_S16MSB
const const
MIX_DEFAULT_CHANNELS* = 2 DEFAULT_CHANNELS* = 2
MIX_MAX_VOLUME* = 128 # Volume of a chunk MAX_VOLUME* = 128 # Volume of a chunk
PATH_MAX* = 255 # mikmod.h constants PATH_MAX* = 255
#*
# * Library version
# *
LIBMIKMOD_VERSION_MAJOR* = 3 LIBMIKMOD_VERSION_MAJOR* = 3
LIBMIKMOD_VERSION_MINOR* = 1 LIBMIKMOD_VERSION_MINOR* = 1
LIBMIKMOD_REVISION* = 8 LIBMIKMOD_REVISION* = 8
@ -108,35 +103,33 @@ type #music_cmd.h types
PUNIMOD* = ptr TUNIMOD PUNIMOD* = ptr TUNIMOD
TUNIMOD* = TMODULE #SDL_mixer.h types TUNIMOD* = TMODULE #SDL_mixer.h types
# The internal format for an audio chunk # The internal format for an audio chunk
PMix_Chunk* = ptr TMix_Chunk PChunk* = ptr TChunk
TMix_Chunk*{.final.} = object TChunk*{.final.} = object
allocated*: int allocated*: int
abuf*: PUint8 abuf*: PUint8
alen*: Uint32 alen*: Uint32
volume*: Uint8 # Per-sample volume, 0-128 volume*: Uint8 # Per-sample volume, 0-128
Mix_Chunk* = TMix_Chunk # The different fading types supported TFading* = enum
TMix_Fading* = enum
MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN
Mix_Fading* = TMix_Fading TMusicType* = enum
TMix_MusicType* = enum
MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG MUS_NONE, MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG
PMix_Music* = ptr TMix_Music PMusic* = ptr TMusic
TMix_Music*{.final.} = object TMusic*{.final.} = object
type_*: TMix_MusicType type_*: TMusicType
TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{. TMixFunction* = proc (udata: Pointer, stream: PUint8, length: int): Pointer{.
cdecl.} # This macro can be used to fill a version structure with the compile-time cdecl.} # This macro can be used to fill a version structure with the compile-time
# version of the SDL_mixer library. # version of the SDL_mixer library.
proc MIXER_VERSION*(X: var TVersion) proc VERSION*(X: var sdl.TVersion)
# This function gets the version of the dynamically linked SDL_mixer library. # This function gets the version of the dynamically linked SDL_mixer library.
# It should NOT be used to fill a version structure, instead you should use the # It should NOT be used to fill a version structure, instead you should use the
# SDL_MIXER_VERSION() macro. # SDL_MIXER_VERSION() macro.
proc Mix_Linked_Version*(): Pversion{.cdecl, importc: "Mix_Linked_Version", proc Linked_Version*(): sdl.Pversion{.cdecl, importc: "Mix_Linked_Version",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Open the mixer with a certain audio format # Open the mixer with a certain audio format
proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int, proc OpenAudio*(frequency: int, format: Uint16, channels: int,
chunksize: int): int{.cdecl, importc: "Mix_OpenAudio", chunksize: int): int{.cdecl, importc: "Mix_OpenAudio",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Dynamically change the number of channels managed by the mixer. # Dynamically change the number of channels managed by the mixer.
@ -144,402 +137,170 @@ proc Mix_OpenAudio*(frequency: int, format: Uint16, channels: int,
# stopped. # stopped.
# This function returns the new number of allocated channels. # This function returns the new number of allocated channels.
# #
proc Mix_AllocateChannels*(numchannels: int): int{.cdecl, proc AllocateChannels*(numchannels: int): int{.cdecl,
importc: "Mix_AllocateChannels", dynlib: MixerLibName.} importc: "Mix_AllocateChannels", dynlib: MixerLibName.}
# Find out what the actual audio device parameters are. # Find out what the actual audio device parameters are.
# This function returns 1 if the audio has been opened, 0 otherwise. # This function returns 1 if the audio has been opened, 0 otherwise.
# #
proc Mix_QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{. proc QuerySpec*(frequency: var int, format: var Uint16, channels: var int): int{.
cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.} cdecl, importc: "Mix_QuerySpec", dynlib: MixerLibName.}
# Load a wave file or a music (.mod .s3m .it .xm) file # Load a wave file or a music (.mod .s3m .it .xm) file
proc Mix_LoadWAV_RW*(src: PRWops, freesrc: int): PMix_Chunk{.cdecl, proc LoadWAV_RW*(src: PRWops, freesrc: int): PChunk{.cdecl,
importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.} importc: "Mix_LoadWAV_RW", dynlib: MixerLibName.}
proc Mix_LoadWAV*(filename: cstring): PMix_Chunk proc LoadWAV*(filename: cstring): PChunk
proc Mix_LoadMUS*(filename: cstring): PMix_Music{.cdecl, importc: "Mix_LoadMUS", proc LoadMUS*(filename: cstring): PMusic{.cdecl, importc: "Mix_LoadMUS",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Load a wave file of the mixer format from a memory buffer # Load a wave file of the mixer format from a memory buffer
proc Mix_QuickLoad_WAV*(mem: PUint8): PMix_Chunk{.cdecl, proc QuickLoad_WAV*(mem: PUint8): PChunk{.cdecl,
importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.} importc: "Mix_QuickLoad_WAV", dynlib: MixerLibName.}
# Free an audio chunk previously loaded # Free an audio chunk previously loaded
proc Mix_FreeChunk*(chunk: PMix_Chunk){.cdecl, importc: "Mix_FreeChunk", proc FreeChunk*(chunk: PChunk){.cdecl, importc: "Mix_FreeChunk",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_FreeMusic*(music: PMix_Music){.cdecl, importc: "Mix_FreeMusic", proc FreeMusic*(music: PMusic){.cdecl, importc: "Mix_FreeMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Find out the music format of a mixer music, or the currently playing # Find out the music format of a mixer music, or the currently playing
# music, if 'music' is NULL. # music, if 'music' is NULL.
proc Mix_GetMusicType*(music: PMix_Music): TMix_MusicType{.cdecl, proc GetMusicType*(music: PMusic): TMusicType{.cdecl,
importc: "Mix_GetMusicType", dynlib: MixerLibName.} importc: "Mix_GetMusicType", dynlib: MixerLibName.}
# Set a function that is called after all mixing is performed. # Set a function that is called after all mixing is performed.
# This can be used to provide real-time visual display of the audio stream # This can be used to provide real-time visual display of the audio stream
# or add a custom mixer filter for the stream data. # or add a custom mixer filter for the stream data.
# #
proc Mix_SetPostMix*(mix_func: TMixFunction, arg: Pointer){.cdecl, proc SetPostMix*(mixfunc: TMixFunction, arg: Pointer){.cdecl,
importc: "Mix_SetPostMix", dynlib: MixerLibName.} importc: "Mix_SetPostMix", dynlib: MixerLibName.}
# Add your own music player or additional mixer function. # Add your own music player or additional mixer function.
# If 'mix_func' is NULL, the default music player is re-enabled. # If 'mix_func' is NULL, the default music player is re-enabled.
# #
proc Mix_HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl, proc HookMusic*(mix_func: TMixFunction, arg: Pointer){.cdecl,
importc: "Mix_HookMusic", dynlib: MixerLibName.} importc: "Mix_HookMusic", dynlib: MixerLibName.}
# Add your own callback when the music has finished playing. # Add your own callback when the music has finished playing.
# #
proc Mix_HookMusicFinished*(music_finished: Pointer){.cdecl, proc HookMusicFinished*(music_finished: Pointer){.cdecl,
importc: "Mix_HookMusicFinished", dynlib: MixerLibName.} importc: "Mix_HookMusicFinished", dynlib: MixerLibName.}
# Get a pointer to the user data for the current music hook # Get a pointer to the user data for the current music hook
proc Mix_GetMusicHookData*(): Pointer{.cdecl, importc: "Mix_GetMusicHookData", proc GetMusicHookData*(): Pointer{.cdecl, importc: "Mix_GetMusicHookData",
dynlib: MixerLibName.} dynlib: MixerLibName.}
#* Add your own callback when a channel has finished playing. NULL #* Add your own callback when a channel has finished playing. NULL
# * to disable callback.* # * to disable callback.*
type type
TChannel_finished* = proc (channel: int){.cdecl.} TChannel_finished* = proc (channel: int){.cdecl.}
proc Mix_ChannelFinished*(channel_finished: TChannel_finished){.cdecl, proc ChannelFinished*(channel_finished: TChannel_finished){.cdecl,
importc: "Mix_ChannelFinished", dynlib: MixerLibName.} importc: "Mix_ChannelFinished", dynlib: MixerLibName.}
const const
MIX_CHANNEL_POST* = - 2 #* This is the format of a special effect callback: CHANNEL_POST* = - 2
# *
# * myeffect(int chan, void *stream, int len, void *udata);
# *
# * (chan) is the channel number that your effect is affecting. (stream) is
# * the buffer of data to work upon. (len) is the size of (stream), and
# * (udata) is a user-defined bit of data, which you pass as the last arg of
# * Mix_RegisterEffect(), and is passed back unmolested to your callback.
# * Your effect changes the contents of (stream) based on whatever parameters
# * are significant, or just leaves it be, if you prefer. You can do whatever
# * you like to the buffer, though, and it will continue in its changed state
# * down the mixing pipeline, through any other effect functions, then finally
# * to be mixed with the rest of the channels and music for the final output
# * stream.
# *
type type
TMix_EffectFunc* = proc (chan: int, stream: Pointer, length: int, TEffectFunc* = proc (chan: int, stream: Pointer, length: int,
udata: Pointer): Pointer{.cdecl.} # * This is a callback that signifies that a channel has finished all its udata: Pointer): Pointer{.cdecl.}
# * loops and has completed playback. This gets called if the buffer TEffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.}
# * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
# * a channel via
# Mix_AllocateChannels(), or unregister a callback while
# * it's still playing.
TMix_EffectDone* = proc (chan: int, udata: Pointer): Pointer{.cdecl.} #* Register a special effect function. At mixing time, the channel data is
# * copied into a buffer and passed through each registered effect function.
# * After it passes through all the functions, it is mixed into the final
# * output stream. The copy to buffer is performed once, then each effect
# * function performs on the output of the previous effect. Understand that
# * this extra copy to a buffer is not performed if there are no effects
# * registered for a given chunk, which saves CPU cycles, and any given
# * effect will be extra cycles, too, so it is crucial that your code run
# * fast. Also note that the data that your function is given is in the
# * format of the sound device, and not the format you gave to Mix_OpenAudio(),
# * although they may in reality be the same. This is an unfortunate but
# * necessary speed concern. Use Mix_QuerySpec() to determine if you can
# * handle the data before you register your effect, and take appropriate
# * actions.
# * You may also specify a callback (Mix_EffectDone_t) that is called when
# * the channel finishes playing. This gives you a more fine-grained control
# * than Mix_ChannelFinished(), in case you need to free effect-specific
# * resources, etc. If you don't need this, you can specify NULL.
# * You may set the callbacks before or after calling Mix_PlayChannel().
# * Things like Mix_SetPanning() are just internal special effect functions,
# * so if you are using that, you've already incurred the overhead of a copy
# * to a separate buffer, and that these effects will be in the queue with
# * any functions you've registered. The list of registered effects for a
# * channel is reset when a chunk finishes playing, so you need to explicitly
# * set them with each call to Mix_PlayChannel*().
# * You may also register a special effect function that is to be run after
# * final mixing occurs. The rules for these callbacks are identical to those
# * in Mix_RegisterEffect, but they are run after all the channels and the
# * music have been mixed into a single stream, whereas channel-specific
# * effects run on a given channel before any other mixing occurs. These
# * global effect callbacks are call "posteffects". Posteffects only have
# * their Mix_EffectDone_t function called when they are unregistered (since
# * the main output stream is never "done" in the same sense as a channel).
# * You must unregister them manually when you've had enough. Your callback
# * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
# * processing is considered a posteffect.
# *
# * After all these effects have finished processing, the callback registered
# * through Mix_SetPostMix() runs, and then the stream goes to the audio
# * device.
# *
# * returns zero if error (no such channel), nonzero if added.
# * Error messages can be retrieved from Mix_GetError().
proc Mix_RegisterEffect*(chan: int, f: TMix_EffectFunc, d: TMix_EffectDone, proc RegisterEffect*(chan: int, f: TEffectFunc, d: TEffectDone,
arg: Pointer): int{.cdecl, arg: Pointer): int{.cdecl,
importc: "Mix_RegisterEffect", dynlib: MixerLibName.} importc: "Mix_RegisterEffect", dynlib: MixerLibName.}
#* You may not need to call this explicitly, unless you need to stop an
# * effect from processing in the middle of a chunk's playback.
# * Posteffects are never implicitly unregistered as they are for channels,
# * but they may be explicitly unregistered through this function by
# * specifying MIX_CHANNEL_POST for a channel.
# * returns zero if error (no such channel or effect), nonzero if removed.
# * Error messages can be retrieved from Mix_GetError().
# *
proc Mix_UnregisterEffect*(channel: int, f: TMix_EffectFunc): int{.cdecl,
importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
#* You may not need to call this explicitly, unless you need to stop all
# * effects from processing in the middle of a chunk's playback. Note that
# * this will also shut off some internal effect processing, since
# * Mix_SetPanning( ) and others may use this API under the hood.This is
# * called internally when a channel completes playback.
# * Posteffects are never implicitly unregistered as they are for channels,
# * but they may be explicitly unregistered through this function by
# * specifying MIX_CHANNEL_POST for a channel.
# * returns zero if error( no such channel ), nonzero if all effects removed.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_UnregisterAllEffects*(channel: int): int{.cdecl,
importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
const
MIX_EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED" # * These are the internally - defined mixing effects.They use the same API that
# * effects defined in the application use, but are provided here as a
# * convenience.Some effects can reduce their quality or use more memory in
# * the name of speed; to enable this, make sure the environment variable
# * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
# * Mix_OpenAudio( ).
# *
#* set the panning of a channel.The left and right channels are specified
# * as integers between 0 and 255, quietest to loudest, respectively.
# *
# * Technically, this is just individual volume control for a sample with
# * two( stereo )channels, so it can be used for more than just panning.
# * if you want real panning, call it like this :
# *
# * Mix_SetPanning( channel, left, 255 - left );
# *
# * ...which isn't so hard.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the panning will be done to the final mixed stream before passing it on
# * to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally, and returns without
# * registering the effect function if the audio device is not configured
# * for stereo output.Setting both( left ) and ( right ) to 255 causes this
# * effect to be unregistered, since that is the data's normal state.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if panning effect enabled.Note that an audio device in mono
# * mode is a no - op, but this call will return successful in that case .
# * Error messages can be retrieved from Mix_GetError( ).
proc Mix_SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl, proc UnregisterEffect*(channel: int, f: TEffectFunc): int{.cdecl,
importc: "Mix_UnregisterEffect", dynlib: MixerLibName.}
proc UnregisterAllEffects*(channel: int): int{.cdecl,
importc: "Mix_UnregisterAllEffects", dynlib: MixerLibName.}
const
EFFECTSMAXSPEED* = "MIX_EFFECTSMAXSPEED"
proc SetPanning*(channel: int, left: Uint8, right: Uint8): int{.cdecl,
importc: "Mix_SetPanning", dynlib: MixerLibName.} importc: "Mix_SetPanning", dynlib: MixerLibName.}
# * set the position ofa channel.( angle ) is an integer from 0 to 360, that
# * specifies the location of the sound in relation to the listener.( angle ) proc SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
# * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
# * Angle 0 is due north, and rotates clockwise as the value increases.
# * for efficiency, the precision of this effect may be limited( angles 1
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
# * ( distance ) is an integer between 0 and 255 that specifies the space
# * between the sound and the listener.The larger the number, the further
# * away the sound is .Using 255 does not guarantee that the channel will be
# * culled from the mixing process or be completely silent.For efficiency,
# * the precision of this effect may be limited( distance 0 through 5 might
# * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
# * and ( distance ) to 0 unregisters this effect, since the data would be
# * unchanged.
# *
# * if you need more precise positional audio, consider using OpenAL for
# * spatialized effects instead of SDL_mixer.This is only meant to be a
# * basic effect for simple "3D" games.
# *
# * if the audio device is configured for mono output, then you won't get
# * any effectiveness from the angle; however, distance attenuation on the
# * channel will still occur.While this effect will function with stereo
# * voices, it makes more sense to use voices with only one channel of sound,
# * so when they are mixed through this effect, the positioning will sound
# * correct.You can convert them to mono through SDL before giving them to
# * the mixer in the first place if you like.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the positioning will be done to the final mixed stream before passing it
# * on to the audio device.
# *
# * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if position effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetPosition*(channel: int, angle: Sint16, distance: Uint8): int{.cdecl,
importc: "Mix_SetPosition", dynlib: MixerLibName.} importc: "Mix_SetPosition", dynlib: MixerLibName.}
#* set the "distance" of a channel.( distance ) is an integer from 0 to 255
# * that specifies the location of the sound in relation to the listener. proc SetDistance*(channel: int, distance: Uint8): int{.cdecl,
# * Distance 0 is overlapping the listener, and 255 is as far away as possible
# * A distance of 255 does not guarantee silence; in such a case , you might
# * want to try changing the chunk's volume, or just cull the sample from the
# * mixing process with Mix_HaltChannel( ).
# * for efficiency, the precision of this effect may be limited( distances 1
# * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
# * ( distance ) is an integer between 0 and 255 that specifies the space
# * between the sound and the listener.The larger the number, the further
# * away the sound is .
# * Setting( distance ) to 0 unregisters this effect, since the data would be
# * unchanged.
# * if you need more precise positional audio, consider using OpenAL for
# * spatialized effects instead of SDL_mixer.This is only meant to be a
# * basic effect for simple "3D" games.
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the distance attenuation will be done to the final mixed stream before
# * passing it on to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if position effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetDistance*(channel: int, distance: Uint8): int{.cdecl,
importc: "Mix_SetDistance", dynlib: MixerLibName.} importc: "Mix_SetDistance", dynlib: MixerLibName.}
# *
# * !!! FIXME : Haven't implemented, since the effect goes past the proc SetReverseStereo*(channel: int, flip: int): int{.cdecl,
# * end of the sound buffer.Will have to think about this.
# * - -ryan.
# * /
# { if 0
# { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
# * of echo to mix.0 is no echo, 255 is infinite( and probably not
# * what you want ).
# *
# * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
# * the reverbing will be done to the final mixed stream before passing it on
# * to the audio device.
# *
# * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
# * of zero, the effect is unregistered, as the data is already in that state.
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if reversing effect is enabled.
# * Error messages can be retrieved from Mix_GetError( ).
# *
# extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
# #E ndif
# * Causes a channel to reverse its stereo.This is handy if the user has his
# * speakers hooked up backwards, or you would like to have a minor bit of
# * psychedelia in your sound code. : )Calling this function with ( flip )
# * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
# * the effect is unregistered.
# *
# * This uses the Mix_RegisterEffect( )API internally, and thus is probably
# * more CPU intensive than having the user just plug in his speakers
# * correctly.Mix_SetReverseStereo( )returns without registering the effect
# * function if the audio device is not configured for stereo output.
# *
# * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
# * on the final mixed stream before sending it on to the audio device( a
# * posteffect ).
# *
# * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
# * nonzero if reversing effect is enabled.Note that an audio device in mono
# * mode is a no - op, but this call will return successful in that case .
# * Error messages can be retrieved from Mix_GetError( ).
# *
proc Mix_SetReverseStereo*(channel: int, flip: int): int{.cdecl,
importc: "Mix_SetReverseStereo", dynlib: MixerLibName.} importc: "Mix_SetReverseStereo", dynlib: MixerLibName.}
# end of effects API. - -ryan. *
# Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate proc ReserveChannels*(num: int): int{.cdecl, importc: "Mix_ReserveChannels",
# them dynamically to the next sample if requested with a -1 value below.
# Returns the number of reserved channels.
#
proc Mix_ReserveChannels*(num: int): int{.cdecl, importc: "Mix_ReserveChannels",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Channel grouping functions
# Attach a tag to a channel. A tag can be assigned to several mixer proc GroupChannel*(which: int, tag: int): int{.cdecl,
# channels, to form groups of channels.
# If 'tag' is -1, the tag is removed (actually -1 is the tag used to
# represent the group of all the channels).
# Returns true if everything was OK.
#
proc Mix_GroupChannel*(which: int, tag: int): int{.cdecl,
importc: "Mix_GroupChannel", dynlib: MixerLibName.} importc: "Mix_GroupChannel", dynlib: MixerLibName.}
# Assign several consecutive channels to a group # Assign several consecutive channels to a group
proc Mix_GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl, proc GroupChannels*(`from`: int, `to`: int, tag: int): int{.cdecl,
importc: "Mix_GroupChannels", dynlib: MixerLibName.} importc: "Mix_GroupChannels", dynlib: MixerLibName.}
# Finds the first available channel in a group of channels # Finds the first available channel in a group of channels
proc Mix_GroupAvailable*(tag: int): int{.cdecl, importc: "Mix_GroupAvailable", proc GroupAvailable*(tag: int): int{.cdecl, importc: "Mix_GroupAvailable",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Returns the number of channels in a group. This is also a subtle # Returns the number of channels in a group. This is also a subtle
# way to get the total number of channels when 'tag' is -1 # way to get the total number of channels when 'tag' is -1
# #
proc Mix_GroupCount*(tag: int): int{.cdecl, importc: "Mix_GroupCount", proc GroupCount*(tag: int): int{.cdecl, importc: "Mix_GroupCount",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Finds the "oldest" sample playing in a group of channels # Finds the "oldest" sample playing in a group of channels
proc Mix_GroupOldest*(tag: int): int{.cdecl, importc: "Mix_GroupOldest", proc GroupOldest*(tag: int): int{.cdecl, importc: "Mix_GroupOldest",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Finds the "most recent" (i.e. last) sample playing in a group of channels # Finds the "most recent" (i.e. last) sample playing in a group of channels
proc Mix_GroupNewer*(tag: int): int{.cdecl, importc: "Mix_GroupNewer", proc GroupNewer*(tag: int): int{.cdecl, importc: "Mix_GroupNewer",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# The same as above, but the sound is played at most 'ticks' milliseconds # The same as above, but the sound is played at most 'ticks' milliseconds
proc Mix_PlayChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, proc PlayChannelTimed*(channel: int, chunk: PChunk, loops: int,
ticks: int): int{.cdecl, ticks: int): int{.cdecl,
importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.} importc: "Mix_PlayChannelTimed", dynlib: MixerLibName.}
# Play an audio chunk on a specific channel.
# If the specified channel is -1, play on the first free channel. proc PlayChannel*(channel: int, chunk: PChunk, loops: int): int
# If 'loops' is greater than zero, loop the sound that many times. proc PlayMusic*(music: PMusic, loops: int): int{.cdecl,
# If 'loops' is -1, loop inifinitely (~65000 times).
# Returns which channel was used to play the sound.
#
proc Mix_PlayChannel*(channel: int, chunk: PMix_Chunk, loops: int): int
proc Mix_PlayMusic*(music: PMix_Music, loops: int): int{.cdecl,
importc: "Mix_PlayMusic", dynlib: MixerLibName.} importc: "Mix_PlayMusic", dynlib: MixerLibName.}
# Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions # Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions
proc Mix_FadeInMusic*(music: PMix_Music, loops: int, ms: int): int{.cdecl, proc FadeInMusic*(music: PMusic, loops: int, ms: int): int{.cdecl,
importc: "Mix_FadeInMusic", dynlib: MixerLibName.} importc: "Mix_FadeInMusic", dynlib: MixerLibName.}
proc Mix_FadeInChannelTimed*(channel: int, chunk: PMix_Chunk, loops: int, proc FadeInChannelTimed*(channel: int, chunk: PChunk, loops: int,
ms: int, ticks: int): int{.cdecl, ms: int, ticks: int): int{.cdecl,
importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.} importc: "Mix_FadeInChannelTimed", dynlib: MixerLibName.}
proc Mix_FadeInChannel*(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int proc FadeInChannel*(channel: int, chunk: PChunk, loops: int, ms: int): int
# Set the volume in the range of 0-128 of a specific channel or chunk. # Set the volume in the range of 0-128 of a specific channel or chunk.
# If the specified channel is -1, set volume for all channels. # If the specified channel is -1, set volume for all channels.
# Returns the original volume. # Returns the original volume.
# If the specified volume is -1, just return the current volume. # If the specified volume is -1, just return the current volume.
# #
proc Mix_Volume*(channel: int, volume: int): int{.cdecl, importc: "Mix_Volume", proc Volume*(channel: int, volume: int): int{.cdecl, importc: "Mix_Volume",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_VolumeChunk*(chunk: PMix_Chunk, volume: int): int{.cdecl, proc VolumeChunk*(chunk: PChunk, volume: int): int{.cdecl,
importc: "Mix_VolumeChunk", dynlib: MixerLibName.} importc: "Mix_VolumeChunk", dynlib: MixerLibName.}
proc Mix_VolumeMusic*(volume: int): int{.cdecl, importc: "Mix_VolumeMusic", proc VolumeMusic*(volume: int): int{.cdecl, importc: "Mix_VolumeMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Halt playing of a particular channel # Halt playing of a particular channel
proc Mix_HaltChannel*(channel: int): int{.cdecl, importc: "Mix_HaltChannel", proc HaltChannel*(channel: int): int{.cdecl, importc: "Mix_HaltChannel",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_HaltGroup*(tag: int): int{.cdecl, importc: "Mix_HaltGroup", proc HaltGroup*(tag: int): int{.cdecl, importc: "Mix_HaltGroup",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_HaltMusic*(): int{.cdecl, importc: "Mix_HaltMusic", proc HaltMusic*(): int{.cdecl, importc: "Mix_HaltMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Change the expiration delay for a particular channel.
# The sample will stop playing after the 'ticks' milliseconds have elapsed, proc ExpireChannel*(channel: int, ticks: int): int{.cdecl,
# or remove the expiration if 'ticks' is -1
#
proc Mix_ExpireChannel*(channel: int, ticks: int): int{.cdecl,
importc: "Mix_ExpireChannel", dynlib: MixerLibName.} importc: "Mix_ExpireChannel", dynlib: MixerLibName.}
# Halt a channel, fading it out progressively till it's silent
# The ms parameter indicates the number of milliseconds the fading proc FadeOutChannel*(which: int, ms: int): int{.cdecl,
# will take.
#
proc Mix_FadeOutChannel*(which: int, ms: int): int{.cdecl,
importc: "Mix_FadeOutChannel", dynlib: MixerLibName.} importc: "Mix_FadeOutChannel", dynlib: MixerLibName.}
proc Mix_FadeOutGroup*(tag: int, ms: int): int{.cdecl, proc FadeOutGroup*(tag: int, ms: int): int{.cdecl,
importc: "Mix_FadeOutGroup", dynlib: MixerLibName.} importc: "Mix_FadeOutGroup", dynlib: MixerLibName.}
proc Mix_FadeOutMusic*(ms: int): int{.cdecl, importc: "Mix_FadeOutMusic", proc FadeOutMusic*(ms: int): int{.cdecl, importc: "Mix_FadeOutMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Query the fading status of a channel # Query the fading status of a channel
proc Mix_FadingMusic*(): TMix_Fading{.cdecl, importc: "Mix_FadingMusic", proc FadingMusic*(): TFading{.cdecl, importc: "Mix_FadingMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_FadingChannel*(which: int): TMix_Fading{.cdecl, proc FadingChannel*(which: int): TFading{.cdecl,
importc: "Mix_FadingChannel", dynlib: MixerLibName.} importc: "Mix_FadingChannel", dynlib: MixerLibName.}
# Pause/Resume a particular channel # Pause/Resume a particular channel
proc Mix_Pause*(channel: int){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.} proc Pause*(channel: int){.cdecl, importc: "Mix_Pause", dynlib: MixerLibName.}
proc Mix_Resume*(channel: int){.cdecl, importc: "Mix_Resume", proc Resume*(channel: int){.cdecl, importc: "Mix_Resume",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_Paused*(channel: int): int{.cdecl, importc: "Mix_Paused", proc Paused*(channel: int): int{.cdecl, importc: "Mix_Paused",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Pause/Resume the music stream # Pause/Resume the music stream
proc Mix_PauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.} proc PauseMusic*(){.cdecl, importc: "Mix_PauseMusic", dynlib: MixerLibName.}
proc Mix_ResumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.} proc ResumeMusic*(){.cdecl, importc: "Mix_ResumeMusic", dynlib: MixerLibName.}
proc Mix_RewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.} proc RewindMusic*(){.cdecl, importc: "Mix_RewindMusic", dynlib: MixerLibName.}
proc Mix_PausedMusic*(): int{.cdecl, importc: "Mix_PausedMusic", proc PausedMusic*(): int{.cdecl, importc: "Mix_PausedMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Set the current position in the music stream. # Set the current position in the music stream.
# This returns 0 if successful, or -1 if it failed or isn't implemented. # This returns 0 if successful, or -1 if it failed or isn't implemented.
@ -547,52 +308,44 @@ proc Mix_PausedMusic*(): int{.cdecl, importc: "Mix_PausedMusic",
# order number) and for OGG music (set position in seconds), at the # order number) and for OGG music (set position in seconds), at the
# moment. # moment.
# #
proc Mix_SetMusicPosition*(position: float64): int{.cdecl, proc SetMusicPosition*(position: float64): int{.cdecl,
importc: "Mix_SetMusicPosition", dynlib: MixerLibName.} importc: "Mix_SetMusicPosition", dynlib: MixerLibName.}
# Check the status of a specific channel. # Check the status of a specific channel.
# If the specified channel is -1, check all channels. # If the specified channel is -1, check all channels.
# #
proc Mix_Playing*(channel: int): int{.cdecl, importc: "Mix_Playing", proc Playing*(channel: int): int{.cdecl, importc: "Mix_Playing",
dynlib: MixerLibName.} dynlib: MixerLibName.}
proc Mix_PlayingMusic*(): int{.cdecl, importc: "Mix_PlayingMusic", proc PlayingMusic*(): int{.cdecl, importc: "Mix_PlayingMusic",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Stop music and set external music playback command # Stop music and set external music playback command
proc Mix_SetMusicCMD*(command: cstring): int{.cdecl, importc: "Mix_SetMusicCMD", proc SetMusicCMD*(command: cstring): int{.cdecl, importc: "Mix_SetMusicCMD",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Synchro value is set by MikMod from modules while playing # Synchro value is set by MikMod from modules while playing
proc Mix_SetSynchroValue*(value: int): int{.cdecl, proc SetSynchroValue*(value: int): int{.cdecl,
importc: "Mix_SetSynchroValue", dynlib: MixerLibName.} importc: "Mix_SetSynchroValue", dynlib: MixerLibName.}
proc Mix_GetSynchroValue*(): int{.cdecl, importc: "Mix_GetSynchroValue", proc GetSynchroValue*(): int{.cdecl, importc: "Mix_GetSynchroValue",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# #
# Get the Mix_Chunk currently associated with a mixer channel # Get the Mix_Chunk currently associated with a mixer channel
# Returns nil if it's an invalid channel, or there's no chunk associated. # Returns nil if it's an invalid channel, or there's no chunk associated.
# #
proc Mix_GetChunk*(channel: int): PMix_Chunk{.cdecl, importc: "Mix_GetChunk", proc GetChunk*(channel: int): PChunk{.cdecl, importc: "Mix_GetChunk",
dynlib: MixerLibName.} dynlib: MixerLibName.}
# Close the mixer, halting all playing audio # Close the mixer, halting all playing audio
proc Mix_CloseAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.} proc CloseAudio*(){.cdecl, importc: "Mix_CloseAudio", dynlib: MixerLibName.}
# We'll use SDL for reporting errors # We'll use SDL for reporting errors
proc Mix_SetError*(fmt: cstring)
proc Mix_GetError*(): cstring
# implementation
proc MIXER_VERSION(X: var Tversion) = proc VERSION(X: var Tversion) =
X.major = MIXER_MAJOR_VERSION X.major = MAJOR_VERSION
X.minor = MIXER_MINOR_VERSION X.minor = MINOR_VERSION
X.patch = MIXER_PATCHLEVEL X.patch = PATCHLEVEL
proc Mix_LoadWAV(filename: cstring): PMix_Chunk = proc LoadWAV(filename: cstring): PChunk =
result = Mix_LoadWAV_RW(RWFromFile(filename, "rb"), 1) result = LoadWAV_RW(RWFromFile(filename, "rb"), 1)
proc Mix_PlayChannel(channel: int, chunk: PMix_Chunk, loops: int): int = proc PlayChannel(channel: int, chunk: PChunk, loops: int): int =
result = Mix_PlayChannelTimed(channel, chunk, loops, - 1) result = PlayChannelTimed(channel, chunk, loops, - 1)
proc Mix_FadeInChannel(channel: int, chunk: PMix_Chunk, loops: int, ms: int): int = proc FadeInChannel(channel: int, chunk: PChunk, loops: int, ms: int): int =
result = Mix_FadeInChannelTimed(channel, chunk, loops, ms, - 1) result = FadeInChannelTimed(channel, chunk, loops, ms, - 1)
proc Mix_SetError(fmt: cstring) =
SetError(fmt)
proc Mix_GetError(): cstring =
result = GetError()

View file

@ -110,7 +110,7 @@
#****************************************************************************** #******************************************************************************
import import
sdl
when defined(windows): when defined(windows):
const const
@ -122,9 +122,9 @@ else:
const const
NetLibName = "libSDL_net.so" NetLibName = "libSDL_net.so"
const #* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL * const #* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *
NET_MAJOR_VERSION* = 1'i8 MAJOR_VERSION* = 1'i8
NET_MINOR_VERSION* = 2'i8 MINOR_VERSION* = 2'i8
NET_PATCHLEVEL* = 5'i8 # SDL_Net.h constants PATCHLEVEL* = 5'i8 # SDL_Net.h constants
#* Resolve a host name and port to an IP address in network form. #* Resolve a host name and port to an IP address in network form.
# If the function succeeds, it will return 0. # If the function succeeds, it will return 0.
# If the host couldn't be resolved, the host portion of the returned # If the host couldn't be resolved, the host portion of the returned
@ -136,8 +136,8 @@ const #* Printable format: "%d.%d.%d", MAJOR, MINOR, PAT
#* UDP network API * #* UDP network API *
#*********************************************************************** #***********************************************************************
#* The maximum channels on a a UDP socket * #* The maximum channels on a a UDP socket *
NET_MAX_UDPCHANNELS* = 32 #* The maximum addresses bound to a single UDP socket channel * MAX_UDPCHANNELS* = 32 #* The maximum addresses bound to a single UDP socket channel *
NET_MAX_UDPADDRESSES* = 4 MAX_UDPADDRESSES* = 4
type # SDL_net.h types type # SDL_net.h types
#*********************************************************************** #***********************************************************************
@ -149,9 +149,7 @@ type # SDL_net.h types
port*: Uint16 # 16-bit protocol port */ port*: Uint16 # 16-bit protocol port */
PTCPSocket* = ptr TTCPSocket PTCPSocket* = ptr TTCPSocket
TTCPSocket*{.final.} = object #*********************************************************************** TTCPSocket*{.final.} = object # UDP network API
#* UDP network API *
#***********************************************************************
ready*: int ready*: int
channel*: int channel*: int
remoteAddress*: TIPaddress remoteAddress*: TIPaddress
@ -161,14 +159,14 @@ type # SDL_net.h types
PUDP_Channel* = ptr TUDP_Channel PUDP_Channel* = ptr TUDP_Channel
TUDP_Channel*{.final.} = object TUDP_Channel*{.final.} = object
numbound*: int numbound*: int
address*: array[0..NET_MAX_UDPADDRESSES - 1, TIPAddress] address*: array[0..MAX_UDPADDRESSES - 1, TIPAddress]
PUDPSocket* = ptr TUDPSocket PUDPSocket* = ptr TUDPSocket
TUDPSocket*{.final.} = object TUDPSocket*{.final.} = object
ready*: int ready*: int
channel*: int channel*: int
address*: TIPAddress address*: TIPAddress
binding*: array[0..NET_MAX_UDPCHANNELS - 1, TUDP_Channel] binding*: array[0..MAX_UDPCHANNELS - 1, TUDP_Channel]
PUDPpacket* = ptr TUDPpacket PUDPpacket* = ptr TUDPpacket
PPUDPpacket* = ptr PUDPpacket PPUDPpacket* = ptr PUDPpacket
@ -182,44 +180,43 @@ type # SDL_net.h types
status*: int #* packet status after sending * status*: int #* packet status after sending *
address*: TIPAddress #* The source/dest address of an incoming/outgoing packet * address*: TIPAddress #* The source/dest address of an incoming/outgoing packet *
PNet_Socket* = ptr TNet_Socket PSocket* = ptr TSocket
TNet_Socket*{.final.} = object TSocket*{.final.} = object
ready*: int ready*: int
channel*: int channel*: int
PNet_SocketSet* = ptr TNet_SocketSet PSocketSet* = ptr TSocketSet
TNet_SocketSet*{.final.} = object #* Any network socket can be safely cast to this socket type * TSocketSet*{.final.} = object # Any network socket can be safely cast to this socket type *
numsockets*: int numsockets*: int
maxsockets*: int maxsockets*: int
sockets*: PNet_Socket sockets*: PSocket
PNet_GenericSocket* = ptr TNet_GenericSocket PGenericSocket* = ptr TGenericSocket
TNet_GenericSocket*{.final.} = object # This macro can be used to fill a version structure with the compile-time TGenericSocket*{.final.} = object
# version of the SDL_net library.
ready*: int ready*: int
proc NET_VERSION*(X: var Tversion) proc VERSION*(X: var Tversion)
#* Initialize/Cleanup the network API #* Initialize/Cleanup the network API
# SDL must be initialized before calls to functions in this library, # SDL must be initialized before calls to functions in this library,
# because this library uses utility functions from the SDL library. # because this library uses utility functions from the SDL library.
#* #*
proc Net_Init*(): int{.cdecl, importc: "SDLNet_Init", dynlib: NetLibName.} proc Init*(): int{.cdecl, importc: "SDLNet_Init", dynlib: NetLibName.}
proc Net_Quit*(){.cdecl, importc: "SDLNet_Quit", dynlib: NetLibName.} proc Quit*(){.cdecl, importc: "SDLNet_Quit", dynlib: NetLibName.}
#* Resolve a host name and port to an IP address in network form. #* Resolve a host name and port to an IP address in network form.
# If the function succeeds, it will return 0. # If the function succeeds, it will return 0.
# If the host couldn't be resolved, the host portion of the returned # If the host couldn't be resolved, the host portion of the returned
# address will be INADDR_NONE, and the function will return -1. # address will be INADDR_NONE, and the function will return -1.
# If 'host' is NULL, the resolved host will be set to INADDR_ANY. # If 'host' is NULL, the resolved host will be set to INADDR_ANY.
# * # *
proc Net_ResolveHost*(address: var TIPaddress, host: cstring, port: Uint16): int{. proc ResolveHost*(address: var TIPaddress, host: cstring, port: Uint16): int{.
cdecl, importc: "SDLNet_ResolveHost", dynlib: NetLibName.} cdecl, importc: "SDLNet_ResolveHost", dynlib: NetLibName.}
#* Resolve an ip address to a host name in canonical form. #* Resolve an ip address to a host name in canonical form.
# If the ip couldn't be resolved, this function returns NULL, # If the ip couldn't be resolved, this function returns NULL,
# otherwise a pointer to a static buffer containing the hostname # otherwise a pointer to a static buffer containing the hostname
# is returned. Note that this function is not thread-safe. # is returned. Note that this function is not thread-safe.
#* #*
proc Net_ResolveIP*(ip: var TIPaddress): cstring{.cdecl, proc ResolveIP*(ip: var TIPaddress): cstring{.cdecl,
importc: "SDLNet_ResolveIP", dynlib: NetLibName.} importc: "SDLNet_ResolveIP", dynlib: NetLibName.}
#*********************************************************************** #***********************************************************************
#* TCP network API * #* TCP network API *
@ -232,24 +229,24 @@ proc Net_ResolveIP*(ip: var TIPaddress): cstring{.cdecl,
# in the correct form). # in the correct form).
# The newly created socket is returned, or NULL if there was an error. # The newly created socket is returned, or NULL if there was an error.
#* #*
proc Net_TCP_Open*(ip: var TIPaddress): PTCPSocket{.cdecl, proc TCP_Open*(ip: var TIPaddress): PTCPSocket{.cdecl,
importc: "SDLNet_TCP_Open", dynlib: NetLibName.} importc: "SDLNet_TCP_Open", dynlib: NetLibName.}
#* Accept an incoming connection on the given server socket. #* Accept an incoming connection on the given server socket.
# The newly created socket is returned, or NULL if there was an error. # The newly created socket is returned, or NULL if there was an error.
#* #*
proc Net_TCP_Accept*(server: PTCPsocket): PTCPSocket{.cdecl, proc TCP_Accept*(server: PTCPsocket): PTCPSocket{.cdecl,
importc: "SDLNet_TCP_Accept", dynlib: NetLibName.} importc: "SDLNet_TCP_Accept", dynlib: NetLibName.}
#* Get the IP address of the remote system associated with the socket. #* Get the IP address of the remote system associated with the socket.
# If the socket is a server socket, this function returns NULL. # If the socket is a server socket, this function returns NULL.
#* #*
proc Net_TCP_GetPeerAddress*(sock: PTCPsocket): PIPAddress{.cdecl, proc TCP_GetPeerAddress*(sock: PTCPsocket): PIPAddress{.cdecl,
importc: "SDLNet_TCP_GetPeerAddress", dynlib: NetLibName.} importc: "SDLNet_TCP_GetPeerAddress", dynlib: NetLibName.}
#* Send 'len' bytes of 'data' over the non-server socket 'sock' #* Send 'len' bytes of 'data' over the non-server socket 'sock'
# This function returns the actual amount of data sent. If the return value # This function returns the actual amount of data sent. If the return value
# is less than the amount of data sent, then either the remote connection was # is less than the amount of data sent, then either the remote connection was
# closed, or an unknown socket error occurred. # closed, or an unknown socket error occurred.
#* #*
proc Net_TCP_Send*(sock: PTCPsocket, data: Pointer, length: int): int{.cdecl, proc TCP_Send*(sock: PTCPsocket, data: Pointer, length: int): int{.cdecl,
importc: "SDLNet_TCP_Send", dynlib: NetLibName.} importc: "SDLNet_TCP_Send", dynlib: NetLibName.}
#* Receive up to 'maxlen' bytes of data over the non-server socket 'sock', #* Receive up to 'maxlen' bytes of data over the non-server socket 'sock',
# and store them in the buffer pointed to by 'data'. # and store them in the buffer pointed to by 'data'.
@ -257,10 +254,10 @@ proc Net_TCP_Send*(sock: PTCPsocket, data: Pointer, length: int): int{.cdecl,
# value is less than or equal to zero, then either the remote connection was # value is less than or equal to zero, then either the remote connection was
# closed, or an unknown socket error occurred. # closed, or an unknown socket error occurred.
#* #*
proc Net_TCP_Recv*(sock: PTCPsocket, data: Pointer, maxlen: int): int{.cdecl, proc TCP_Recv*(sock: PTCPsocket, data: Pointer, maxlen: int): int{.cdecl,
importc: "SDLNet_TCP_Recv", dynlib: NetLibName.} importc: "SDLNet_TCP_Recv", dynlib: NetLibName.}
#* Close a TCP network socket * #* Close a TCP network socket *
proc Net_TCP_Close*(sock: PTCPsocket){.cdecl, importc: "SDLNet_TCP_Close", proc TCP_Close*(sock: PTCPsocket){.cdecl, importc: "SDLNet_TCP_Close",
dynlib: NetLibName.} dynlib: NetLibName.}
#*********************************************************************** #***********************************************************************
#* UDP network API * #* UDP network API *
@ -268,26 +265,26 @@ proc Net_TCP_Close*(sock: PTCPsocket){.cdecl, importc: "SDLNet_TCP_Close",
#* Allocate/resize/free a single UDP packet 'size' bytes long. #* Allocate/resize/free a single UDP packet 'size' bytes long.
# The new packet is returned, or NULL if the function ran out of memory. # The new packet is returned, or NULL if the function ran out of memory.
# * # *
proc Net_AllocPacket*(size: int): PUDPpacket{.cdecl, proc AllocPacket*(size: int): PUDPpacket{.cdecl,
importc: "SDLNet_AllocPacket", dynlib: NetLibName.} importc: "SDLNet_AllocPacket", dynlib: NetLibName.}
proc Net_ResizePacket*(packet: PUDPpacket, newsize: int): int{.cdecl, proc ResizePacket*(packet: PUDPpacket, newsize: int): int{.cdecl,
importc: "SDLNet_ResizePacket", dynlib: NetLibName.} importc: "SDLNet_ResizePacket", dynlib: NetLibName.}
proc Net_FreePacket*(packet: PUDPpacket){.cdecl, importc: "SDLNet_FreePacket", proc FreePacket*(packet: PUDPpacket){.cdecl, importc: "SDLNet_FreePacket",
dynlib: NetLibName.} dynlib: NetLibName.}
#* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets, #* Allocate/Free a UDP packet vector (array of packets) of 'howmany' packets,
# each 'size' bytes long. # each 'size' bytes long.
# A pointer to the first packet in the array is returned, or NULL if the # A pointer to the first packet in the array is returned, or NULL if the
# function ran out of memory. # function ran out of memory.
# * # *
proc Net_AllocPacketV*(howmany: int, size: int): PUDPpacket{.cdecl, proc AllocPacketV*(howmany: int, size: int): PUDPpacket{.cdecl,
importc: "SDLNet_AllocPacketV", dynlib: NetLibName.} importc: "SDLNet_AllocPacketV", dynlib: NetLibName.}
proc Net_FreePacketV*(packetV: PUDPpacket){.cdecl, proc FreePacketV*(packetV: PUDPpacket){.cdecl,
importc: "SDLNet_FreePacketV", dynlib: NetLibName.} importc: "SDLNet_FreePacketV", dynlib: NetLibName.}
#* Open a UDP network socket #* Open a UDP network socket
# If 'port' is non-zero, the UDP socket is bound to a local port. # If 'port' is non-zero, the UDP socket is bound to a local port.
# This allows other systems to send to this socket via a known port. # This allows other systems to send to this socket via a known port.
#* #*
proc Net_UDP_Open*(port: Uint16): PUDPsocket{.cdecl, importc: "SDLNet_UDP_Open", proc UDP_Open*(port: Uint16): PUDPsocket{.cdecl, importc: "SDLNet_UDP_Open",
dynlib: NetLibName.} dynlib: NetLibName.}
#* Bind the address 'address' to the requested channel on the UDP socket. #* Bind the address 'address' to the requested channel on the UDP socket.
# If the channel is -1, then the first unbound channel will be bound with # If the channel is -1, then the first unbound channel will be bound with
@ -298,10 +295,10 @@ proc Net_UDP_Open*(port: Uint16): PUDPsocket{.cdecl, importc: "SDLNet_UDP_Open",
# address, to which all outbound packets on the channel are sent. # address, to which all outbound packets on the channel are sent.
# This function returns the channel which was bound, or -1 on error. # This function returns the channel which was bound, or -1 on error.
#* #*
proc Net_UDP_Bind*(sock: PUDPsocket, channel: int, address: var TIPaddress): int{. proc UDP_Bind*(sock: PUDPsocket, channel: int, address: var TIPaddress): int{.
cdecl, importc: "SDLNet_UDP_Bind", dynlib: NetLibName.} cdecl, importc: "SDLNet_UDP_Bind", dynlib: NetLibName.}
#* Unbind all addresses from the given channel * #* Unbind all addresses from the given channel *
proc Net_UDP_Unbind*(sock: PUDPsocket, channel: int){.cdecl, proc UDP_Unbind*(sock: PUDPsocket, channel: int){.cdecl,
importc: "SDLNet_UDP_Unbind", dynlib: NetLibName.} importc: "SDLNet_UDP_Unbind", dynlib: NetLibName.}
#* Get the primary IP address of the remote system associated with the #* Get the primary IP address of the remote system associated with the
# socket and channel. If the channel is -1, then the primary IP port # socket and channel. If the channel is -1, then the primary IP port
@ -309,7 +306,7 @@ proc Net_UDP_Unbind*(sock: PUDPsocket, channel: int){.cdecl,
# opened with a specific port. # opened with a specific port.
# If the channel is not bound and not -1, this function returns NULL. # If the channel is not bound and not -1, this function returns NULL.
# * # *
proc Net_UDP_GetPeerAddress*(sock: PUDPsocket, channel: int): PIPAddress{.cdecl, proc UDP_GetPeerAddress*(sock: PUDPsocket, channel: int): PIPAddress{.cdecl,
importc: "SDLNet_UDP_GetPeerAddress", dynlib: NetLibName.} importc: "SDLNet_UDP_GetPeerAddress", dynlib: NetLibName.}
#* Send a vector of packets to the the channels specified within the packet. #* Send a vector of packets to the the channels specified within the packet.
# If the channel specified in the packet is -1, the packet will be sent to # If the channel specified in the packet is -1, the packet will be sent to
@ -318,7 +315,7 @@ proc Net_UDP_GetPeerAddress*(sock: PUDPsocket, channel: int): PIPAddress{.cdecl,
# been sent, -1 if the packet send failed. # been sent, -1 if the packet send failed.
# This function returns the number of packets sent. # This function returns the number of packets sent.
#* #*
proc Net_UDP_SendV*(sock: PUDPsocket, packets: PPUDPpacket, npackets: int): int{. proc UDP_SendV*(sock: PUDPsocket, packets: PPUDPpacket, npackets: int): int{.
cdecl, importc: "SDLNet_UDP_SendV", dynlib: NetLibName.} cdecl, importc: "SDLNet_UDP_SendV", dynlib: NetLibName.}
#* Send a single packet to the specified channel. #* Send a single packet to the specified channel.
# If the channel specified in the packet is -1, the packet will be sent to # If the channel specified in the packet is -1, the packet will be sent to
@ -327,7 +324,7 @@ proc Net_UDP_SendV*(sock: PUDPsocket, packets: PPUDPpacket, npackets: int): int{
# been sent. # been sent.
# This function returns 1 if the packet was sent, or 0 on error. # This function returns 1 if the packet was sent, or 0 on error.
#* #*
proc Net_UDP_Send*(sock: PUDPsocket, channel: int, packet: PUDPpacket): int{. proc UDP_Send*(sock: PUDPsocket, channel: int, packet: PUDPpacket): int{.
cdecl, importc: "SDLNet_UDP_Send", dynlib: NetLibName.} cdecl, importc: "SDLNet_UDP_Send", dynlib: NetLibName.}
#* Receive a vector of pending packets from the UDP socket. #* Receive a vector of pending packets from the UDP socket.
# The returned packets contain the source address and the channel they arrived # The returned packets contain the source address and the channel they arrived
@ -339,7 +336,7 @@ proc Net_UDP_Send*(sock: PUDPsocket, channel: int, packet: PUDPpacket): int{.
# This function returns the number of packets read from the network, or -1 # This function returns the number of packets read from the network, or -1
# on error. This function does not block, so can return 0 packets pending. # on error. This function does not block, so can return 0 packets pending.
#* #*
proc Net_UDP_RecvV*(sock: PUDPsocket, packets: PPUDPpacket): int{.cdecl, proc UDP_RecvV*(sock: PUDPsocket, packets: PPUDPpacket): int{.cdecl,
importc: "SDLNet_UDP_RecvV", dynlib: NetLibName.} importc: "SDLNet_UDP_RecvV", dynlib: NetLibName.}
#* Receive a single packet from the UDP socket. #* Receive a single packet from the UDP socket.
# The returned packet contains the source address and the channel it arrived # The returned packet contains the source address and the channel it arrived
@ -351,10 +348,10 @@ proc Net_UDP_RecvV*(sock: PUDPsocket, packets: PPUDPpacket): int{.cdecl,
# This function returns the number of packets read from the network, or -1 # This function returns the number of packets read from the network, or -1
# on error. This function does not block, so can return 0 packets pending. # on error. This function does not block, so can return 0 packets pending.
#* #*
proc Net_UDP_Recv*(sock: PUDPsocket, packet: PUDPpacket): int{.cdecl, proc UDP_Recv*(sock: PUDPsocket, packet: PUDPpacket): int{.cdecl,
importc: "SDLNet_UDP_Recv", dynlib: NetLibName.} importc: "SDLNet_UDP_Recv", dynlib: NetLibName.}
#* Close a UDP network socket * #* Close a UDP network socket *
proc Net_UDP_Close*(sock: PUDPsocket){.cdecl, importc: "SDLNet_UDP_Close", proc UDP_Close*(sock: PUDPsocket){.cdecl, importc: "SDLNet_UDP_Close",
dynlib: NetLibName.} dynlib: NetLibName.}
#*********************************************************************** #***********************************************************************
#* Hooks for checking sockets for available data * #* Hooks for checking sockets for available data *
@ -363,19 +360,19 @@ proc Net_UDP_Close*(sock: PUDPsocket){.cdecl, importc: "SDLNet_UDP_Close",
# This returns a socket set for up to 'maxsockets' sockets, or NULL if # This returns a socket set for up to 'maxsockets' sockets, or NULL if
# the function ran out of memory. # the function ran out of memory.
# * # *
proc Net_AllocSocketSet*(maxsockets: int): PNet_SocketSet{.cdecl, proc AllocSocketSet*(maxsockets: int): PSocketSet{.cdecl,
importc: "SDLNet_AllocSocketSet", dynlib: NetLibName.} importc: "SDLNet_AllocSocketSet", dynlib: NetLibName.}
#* Add a socket to a set of sockets to be checked for available data * #* Add a socket to a set of sockets to be checked for available data *
proc Net_AddSocket*(theSet: PNet_SocketSet, sock: PNet_GenericSocket): int{. proc AddSocket*(theSet: PSocketSet, sock: PGenericSocket): int{.
cdecl, importc: "SDLNet_AddSocket", dynlib: NetLibName.} cdecl, importc: "SDLNet_AddSocket", dynlib: NetLibName.}
proc Net_TCP_AddSocket*(theSet: PNet_SocketSet, sock: PTCPSocket): int proc TCP_AddSocket*(theSet: PSocketSet, sock: PTCPSocket): int
proc Net_UDP_AddSocket*(theSet: PNet_SocketSet, sock: PUDPSocket): int proc UDP_AddSocket*(theSet: PSocketSet, sock: PUDPSocket): int
#* Remove a socket from a set of sockets to be checked for available data * #* Remove a socket from a set of sockets to be checked for available data *
proc Net_DelSocket*(theSet: PNet_SocketSet, sock: PNet_GenericSocket): int{. proc DelSocket*(theSet: PSocketSet, sock: PGenericSocket): int{.
cdecl, importc: "SDLNet_DelSocket", dynlib: NetLibName.} cdecl, importc: "SDLNet_DelSocket", dynlib: NetLibName.}
proc Net_TCP_DelSocket*(theSet: PNet_SocketSet, sock: PTCPSocket): int proc TCP_DelSocket*(theSet: PSocketSet, sock: PTCPSocket): int
# SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock) # SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
proc Net_UDP_DelSocket*(theSet: PNet_SocketSet, sock: PUDPSocket): int proc UDP_DelSocket*(theSet: PSocketSet, sock: PUDPSocket): int
#SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock) #SDLNet_DelSocket(set, (SDLNet_GenericSocket)sock)
#* This function checks to see if data is available for reading on the #* This function checks to see if data is available for reading on the
# given set of sockets. If 'timeout' is 0, it performs a quick poll, # given set of sockets. If 'timeout' is 0, it performs a quick poll,
@ -384,59 +381,47 @@ proc Net_UDP_DelSocket*(theSet: PNet_SocketSet, sock: PUDPSocket): int
# first. This function returns the number of sockets ready for reading, # first. This function returns the number of sockets ready for reading,
# or -1 if there was an error with the select() system call. # or -1 if there was an error with the select() system call.
#* #*
proc Net_CheckSockets*(theSet: PNet_SocketSet, timeout: Sint32): int{.cdecl, proc CheckSockets*(theSet: PSocketSet, timeout: Sint32): int{.cdecl,
importc: "SDLNet_CheckSockets", dynlib: NetLibName.} importc: "SDLNet_CheckSockets", dynlib: NetLibName.}
#* After calling SDLNet_CheckSockets(), you can use this function on a #* After calling SDLNet_CheckSockets(), you can use this function on a
# socket that was in the socket set, to find out if data is available # socket that was in the socket set, to find out if data is available
# for reading. # for reading.
#* #*
proc Net_SocketReady*(sock: PNet_GenericSocket): bool proc SocketReady*(sock: PGenericSocket): bool
#* Free a set of sockets allocated by SDL_NetAllocSocketSet() * #* Free a set of sockets allocated by SDL_NetAllocSocketSet() *
proc Net_FreeSocketSet*(theSet: PNet_SocketSet){.cdecl, proc FreeSocketSet*(theSet: PSocketSet){.cdecl,
importc: "SDLNet_FreeSocketSet", dynlib: NetLibName.} importc: "SDLNet_FreeSocketSet", dynlib: NetLibName.}
#*********************************************************************** #***********************************************************************
#* Platform-independent data conversion functions * #* Platform-independent data conversion functions *
#*********************************************************************** #***********************************************************************
#* Write a 16/32 bit value to network packet buffer * #* Write a 16/32 bit value to network packet buffer *
proc Net_Write16*(value: Uint16, area: Pointer){.cdecl, proc Write16*(value: Uint16, area: Pointer){.cdecl,
importc: "SDLNet_Write16", dynlib: NetLibName.} importc: "SDLNet_Write16", dynlib: NetLibName.}
proc Net_Write32*(value: Uint32, area: Pointer){.cdecl, proc Write32*(value: Uint32, area: Pointer){.cdecl,
importc: "SDLNet_Write32", dynlib: NetLibName.} importc: "SDLNet_Write32", dynlib: NetLibName.}
#* Read a 16/32 bit value from network packet buffer * #* Read a 16/32 bit value from network packet buffer *
proc Net_Read16*(area: Pointer): Uint16{.cdecl, importc: "SDLNet_Read16", proc Read16*(area: Pointer): Uint16{.cdecl, importc: "SDLNet_Read16",
dynlib: NetLibName.} dynlib: NetLibName.}
proc Net_Read32*(area: Pointer): Uint32{.cdecl, importc: "SDLNet_Read32", proc Read32*(area: Pointer): Uint32{.cdecl, importc: "SDLNet_Read32",
dynlib: NetLibName.} dynlib: NetLibName.}
#***********************************************************************
#* Error reporting functions *
#***********************************************************************
#* We'll use SDL's functions for error reporting *
proc Net_SetError*(fmt: cstring)
proc Net_GetError*(): cstring
# implementation
proc NET_VERSION(X: var Tversion) = proc VERSION(X: var Tversion) =
X.major = NET_MAJOR_VERSION X.major = MAJOR_VERSION
X.minor = NET_MINOR_VERSION X.minor = MINOR_VERSION
X.patch = NET_PATCHLEVEL X.patch = PATCHLEVEL
proc Net_TCP_AddSocket(theSet: PNet_SocketSet, sock: PTCPSocket): int = proc TCP_AddSocket(theSet: PSocketSet, sock: PTCPSocket): int =
result = Net_AddSocket(theSet, cast[PNet_GenericSocket](sock)) result = AddSocket(theSet, cast[PGenericSocket](sock))
proc Net_UDP_AddSocket(theSet: PNet_SocketSet, sock: PUDPSocket): int = proc UDP_AddSocket(theSet: PSocketSet, sock: PUDPSocket): int =
result = Net_AddSocket(theSet, cast[PNet_GenericSocket](sock)) result = AddSocket(theSet, cast[PGenericSocket](sock))
proc Net_TCP_DelSocket(theSet: PNet_SocketSet, sock: PTCPSocket): int = proc TCP_DelSocket(theSet: PSocketSet, sock: PTCPSocket): int =
result = Net_DelSocket(theSet, cast[PNet_GenericSocket](sock)) result = DelSocket(theSet, cast[PGenericSocket](sock))
proc Net_UDP_DelSocket(theSet: PNet_SocketSet, sock: PUDPSocket): int = proc UDP_DelSocket(theSet: PSocketSet, sock: PUDPSocket): int =
result = Net_DelSocket(theSet, cast[PNet_GenericSocket](sock)) result = DelSocket(theSet, cast[PGenericSocket](sock))
proc Net_SocketReady(sock: PNet_GenericSocket): bool = proc SocketReady(sock: PGenericSocket): bool =
result = ((sock != nil) and (sock.ready == 1)) result = ((sock != nil) and (sock.ready == 1))
proc Net_SetError(fmt: cstring) =
SetError(fmt)
proc Net_GetError(): cstring =
result = GetError()

View file

@ -153,7 +153,7 @@
# #
import import
sdl
when defined(windows): when defined(windows):
const const
@ -165,97 +165,88 @@ else:
const const
ttfLibName = "libSDL_ttf.so" ttfLibName = "libSDL_ttf.so"
const const
TTF_MAJOR_VERSION* = 2'i8 MAJOR_VERSION* = 2'i8
TTF_MINOR_VERSION* = 0'i8 MINOR_VERSION* = 0'i8
TTF_PATCHLEVEL* = 8'i8 # Backwards compatibility PATCHLEVEL* = 8'i8 # Backwards compatibility
TTF_MAJOR_VERSION* = TTF_MAJOR_VERSION
TTF_MINOR_VERSION* = TTF_MINOR_VERSION STYLE_NORMAL* = 0x00000000
TTF_PATCHLEVEL* = TTF_PATCHLEVEL #* STYLE_BOLD* = 0x00000001
# Set and retrieve the font style STYLE_ITALIC* = 0x00000002
# This font style is implemented by modifying the font glyphs, and STYLE_UNDERLINE* = 0x00000004 # ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
# doesn't reflect any inherent properties of the truetype font file.
#*
TTF_STYLE_NORMAL* = 0x00000000
TTF_STYLE_BOLD* = 0x00000001
TTF_STYLE_ITALIC* = 0x00000002
TTF_STYLE_UNDERLINE* = 0x00000004 # ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark)
UNICODE_BOM_NATIVE* = 0x0000FEFF UNICODE_BOM_NATIVE* = 0x0000FEFF
UNICODE_BOM_SWAPPED* = 0x0000FFFE UNICODE_BOM_SWAPPED* = 0x0000FFFE
type type
PTTF_Font* = ptr TTTF_font PFont* = ptr Tfont
TTTF_Font*{.final.} = object # This macro can be used to fill a version structure with the compile-time TFont*{.final.} = object # This macro can be used to fill a version structure with the compile-time
# version of the SDL_ttf library. # version of the SDL_ttf library.
proc TTF_VERSION*(X: var Tversion)
# This function gets the version of the dynamically linked SDL_ttf library. proc Linked_Version*(): sdl.Pversion{.cdecl, importc: "TTF_Linked_Version",
# It should NOT be used to fill a version structure, instead you should use the
# SDL_TTF_VERSION() macro.
proc TTF_Linked_Version*(): Pversion{.cdecl, importc: "TTF_Linked_Version",
dynlib: ttfLibName.} dynlib: ttfLibName.}
# This function tells the library whether UNICODE text is generally # This function tells the library whether UNICODE text is generally
# byteswapped. A UNICODE BOM character in a string will override # byteswapped. A UNICODE BOM character in a string will override
# this setting for the remainder of that string. # this setting for the remainder of that string.
# #
proc TTF_ByteSwappedUNICODE*(swapped: int){.cdecl, proc ByteSwappedUNICODE*(swapped: int){.cdecl,
importc: "TTF_ByteSwappedUNICODE", dynlib: ttfLibName.} importc: "TTF_ByteSwappedUNICODE", dynlib: ttfLibName.}
#returns 0 on succes, -1 if error occurs #returns 0 on succes, -1 if error occurs
proc TTF_Init*(): int{.cdecl, importc: "TTF_Init", dynlib: ttfLibName.} proc Init*(): int{.cdecl, importc: "TTF_Init", dynlib: ttfLibName.}
# #
# Open a font file and create a font of the specified point size. # Open a font file and create a font of the specified point size.
# Some .fon fonts will have several sizes embedded in the file, so the # Some .fon fonts will have several sizes embedded in the file, so the
# point size becomes the index of choosing which size. If the value # point size becomes the index of choosing which size. If the value
# is too high, the last indexed size will be the default. # is too high, the last indexed size will be the default.
# #
proc TTF_OpenFont*(filename: cstring, ptsize: int): PTTF_Font{.cdecl, proc OpenFont*(filename: cstring, ptsize: int): PFont{.cdecl,
importc: "TTF_OpenFont", dynlib: ttfLibName.} importc: "TTF_OpenFont", dynlib: ttfLibName.}
proc TTF_OpenFontIndex*(filename: cstring, ptsize: int, index: int32): PTTF_Font{. proc OpenFontIndex*(filename: cstring, ptsize: int, index: int32): PFont{.
cdecl, importc: "TTF_OpenFontIndex", dynlib: ttfLibName.} cdecl, importc: "TTF_OpenFontIndex", dynlib: ttfLibName.}
proc TTF_OpenFontRW*(src: PRWops, freesrc: int, ptsize: int): PTTF_Font{.cdecl, proc OpenFontRW*(src: PRWops, freesrc: int, ptsize: int): PFont{.cdecl,
importc: "TTF_OpenFontRW", dynlib: ttfLibName.} importc: "TTF_OpenFontRW", dynlib: ttfLibName.}
proc TTF_OpenFontIndexRW*(src: PRWops, freesrc: int, ptsize: int, index: int32): PTTF_Font{. proc OpenFontIndexRW*(src: PRWops, freesrc: int, ptsize: int, index: int32): PFont{.
cdecl, importc: "TTF_OpenFontIndexRW", dynlib: ttfLibName.} cdecl, importc: "TTF_OpenFontIndexRW", dynlib: ttfLibName.}
proc TTF_GetFontStyle*(font: PTTF_Font): int{.cdecl, proc GetFontStyle*(font: PFont): int{.cdecl,
importc: "TTF_GetFontStyle", dynlib: ttfLibName.} importc: "TTF_GetFontStyle", dynlib: ttfLibName.}
proc TTF_SetFontStyle*(font: PTTF_Font, style: int){.cdecl, proc SetFontStyle*(font: PFont, style: int){.cdecl,
importc: "TTF_SetFontStyle", dynlib: ttfLibName.} importc: "TTF_SetFontStyle", dynlib: ttfLibName.}
# Get the total height of the font - usually equal to point size # Get the total height of the font - usually equal to point size
proc TTF_FontHeight*(font: PTTF_Font): int{.cdecl, importc: "TTF_FontHeight", proc FontHeight*(font: PFont): int{.cdecl, importc: "TTF_FontHeight",
dynlib: ttfLibName.} dynlib: ttfLibName.}
# Get the offset from the baseline to the top of the font # Get the offset from the baseline to the top of the font
# This is a positive value, relative to the baseline. # This is a positive value, relative to the baseline.
# #
proc TTF_FontAscent*(font: PTTF_Font): int{.cdecl, importc: "TTF_FontAscent", proc FontAscent*(font: PFont): int{.cdecl, importc: "TTF_FontAscent",
dynlib: ttfLibName.} dynlib: ttfLibName.}
# Get the offset from the baseline to the bottom of the font # Get the offset from the baseline to the bottom of the font
# This is a negative value, relative to the baseline. # This is a negative value, relative to the baseline.
# #
proc TTF_FontDescent*(font: PTTF_Font): int{.cdecl, importc: "TTF_FontDescent", proc FontDescent*(font: PFont): int{.cdecl, importc: "TTF_FontDescent",
dynlib: ttfLibName.} dynlib: ttfLibName.}
# Get the recommended spacing between lines of text for this font # Get the recommended spacing between lines of text for this font
proc TTF_FontLineSkip*(font: PTTF_Font): int{.cdecl, proc FontLineSkip*(font: PFont): int{.cdecl,
importc: "TTF_FontLineSkip", dynlib: ttfLibName.} importc: "TTF_FontLineSkip", dynlib: ttfLibName.}
# Get the number of faces of the font # Get the number of faces of the font
proc TTF_FontFaces*(font: PTTF_Font): int32{.cdecl, importc: "TTF_FontFaces", proc FontFaces*(font: PFont): int32{.cdecl, importc: "TTF_FontFaces",
dynlib: ttfLibName.} dynlib: ttfLibName.}
# Get the font face attributes, if any # Get the font face attributes, if any
proc TTF_FontFaceIsFixedWidth*(font: PTTF_Font): int{.cdecl, proc FontFaceIsFixedWidth*(font: PFont): int{.cdecl,
importc: "TTF_FontFaceIsFixedWidth", dynlib: ttfLibName.} importc: "TTF_FontFaceIsFixedWidth", dynlib: ttfLibName.}
proc TTF_FontFaceFamilyName*(font: PTTF_Font): cstring{.cdecl, proc FontFaceFamilyName*(font: PFont): cstring{.cdecl,
importc: "TTF_FontFaceFamilyName", dynlib: ttfLibName.} importc: "TTF_FontFaceFamilyName", dynlib: ttfLibName.}
proc TTF_FontFaceStyleName*(font: PTTF_Font): cstring{.cdecl, proc FontFaceStyleName*(font: PFont): cstring{.cdecl,
importc: "TTF_FontFaceStyleName", dynlib: ttfLibName.} importc: "TTF_FontFaceStyleName", dynlib: ttfLibName.}
# Get the metrics (dimensions) of a glyph # Get the metrics (dimensions) of a glyph
proc TTF_GlyphMetrics*(font: PTTF_Font, ch: Uint16, minx: var int, proc GlyphMetrics*(font: PFont, ch: Uint16, minx: var int,
maxx: var int, miny: var int, maxy: var int, maxx: var int, miny: var int, maxy: var int,
advance: var int): int{.cdecl, advance: var int): int{.cdecl,
importc: "TTF_GlyphMetrics", dynlib: ttfLibName.} importc: "TTF_GlyphMetrics", dynlib: ttfLibName.}
# Get the dimensions of a rendered string of text # Get the dimensions of a rendered string of text
proc TTF_SizeText*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{. proc SizeText*(font: PFont, text: cstring, w: var int, y: var int): int{.
cdecl, importc: "TTF_SizeText", dynlib: ttfLibName.} cdecl, importc: "TTF_SizeText", dynlib: ttfLibName.}
proc TTF_SizeUTF8*(font: PTTF_Font, text: cstring, w: var int, y: var int): int{. proc SizeUTF8*(font: PFont, text: cstring, w: var int, y: var int): int{.
cdecl, importc: "TTF_SizeUTF8", dynlib: ttfLibName.} cdecl, importc: "TTF_SizeUTF8", dynlib: ttfLibName.}
proc TTF_SizeUNICODE*(font: PTTF_Font, text: PUint16, w: var int, y: var int): int{. proc SizeUNICODE*(font: PFont, text: PUint16, w: var int, y: var int): int{.
cdecl, importc: "TTF_SizeUNICODE", dynlib: ttfLibName.} cdecl, importc: "TTF_SizeUNICODE", dynlib: ttfLibName.}
# Create an 8-bit palettized surface and render the given text at # Create an 8-bit palettized surface and render the given text at
# fast quality with the given font and color. The 0 pixel is the # fast quality with the given font and color. The 0 pixel is the
@ -263,9 +254,9 @@ proc TTF_SizeUNICODE*(font: PTTF_Font, text: PUint16, w: var int, y: var int): i
# to the text color. # to the text color.
# This function returns the new surface, or NULL if there was an error. # This function returns the new surface, or NULL if there was an error.
# #
proc TTF_RenderUTF8_Solid*(font: PTTF_Font, text: cstring, fg: TColor): PSurface{. proc RenderUTF8_Solid*(font: PFont, text: cstring, fg: TColor): PSurface{.
cdecl, importc: "TTF_RenderUTF8_Solid", dynlib: ttfLibName.} cdecl, importc: "TTF_RenderUTF8_Solid", dynlib: ttfLibName.}
proc TTF_RenderUNICODE_Solid*(font: PTTF_Font, text: PUint16, fg: TColor): PSurface{. proc RenderUNICODE_Solid*(font: PFont, text: PUint16, fg: TColor): PSurface{.
cdecl, importc: "TTF_RenderUNICODE_Solid", dynlib: ttfLibName.} cdecl, importc: "TTF_RenderUNICODE_Solid", dynlib: ttfLibName.}
# #
#Create an 8-bit palettized surface and render the given glyph at #Create an 8-bit palettized surface and render the given glyph at
@ -275,20 +266,20 @@ proc TTF_RenderUNICODE_Solid*(font: PTTF_Font, text: PUint16, fg: TColor): PSurf
# centering in the X direction, and aligned normally in the Y direction. # centering in the X direction, and aligned normally in the Y direction.
# This function returns the new surface, or NULL if there was an error. # This function returns the new surface, or NULL if there was an error.
# #
proc TTF_RenderGlyph_Solid*(font: PTTF_Font, ch: Uint16, fg: TColor): PSurface{. proc RenderGlyph_Solid*(font: PFont, ch: Uint16, fg: TColor): PSurface{.
cdecl, importc: "TTF_RenderGlyph_Solid", dynlib: ttfLibName.} cdecl, importc: "TTF_RenderGlyph_Solid", dynlib: ttfLibName.}
# Create an 8-bit palettized surface and render the given text at # Create an 8-bit palettized surface and render the given text at
# high quality with the given font and colors. The 0 pixel is background, # high quality with the given font and colors. The 0 pixel is background,
# while other pixels have varying degrees of the foreground color. # while other pixels have varying degrees of the foreground color.
# This function returns the new surface, or NULL if there was an error. # This function returns the new surface, or NULL if there was an error.
# #
proc TTF_RenderText_Shaded*(font: PTTF_Font, text: cstring, fg: TColor, proc RenderText_Shaded*(font: PFont, text: cstring, fg: TColor,
bg: TColor): PSurface{.cdecl, bg: TColor): PSurface{.cdecl,
importc: "TTF_RenderText_Shaded", dynlib: ttfLibName.} importc: "TTF_RenderText_Shaded", dynlib: ttfLibName.}
proc TTF_RenderUTF8_Shaded*(font: PTTF_Font, text: cstring, fg: TColor, proc RenderUTF8_Shaded*(font: PFont, text: cstring, fg: TColor,
bg: TColor): PSurface{.cdecl, bg: TColor): PSurface{.cdecl,
importc: "TTF_RenderUTF8_Shaded", dynlib: ttfLibName.} importc: "TTF_RenderUTF8_Shaded", dynlib: ttfLibName.}
proc TTF_RenderUNICODE_Shaded*(font: PTTF_Font, text: PUint16, fg: TColor, proc RenderUNICODE_Shaded*(font: PFont, text: PUint16, fg: TColor,
bg: TColor): PSurface{.cdecl, bg: TColor): PSurface{.cdecl,
importc: "TTF_RenderUNICODE_Shaded", dynlib: ttfLibName.} importc: "TTF_RenderUNICODE_Shaded", dynlib: ttfLibName.}
# Create an 8-bit palettized surface and render the given glyph at # Create an 8-bit palettized surface and render the given glyph at
@ -298,17 +289,17 @@ proc TTF_RenderUNICODE_Shaded*(font: PTTF_Font, text: PUint16, fg: TColor,
# direction, and aligned normally in the Y direction. # direction, and aligned normally in the Y direction.
# This function returns the new surface, or NULL if there was an error. # This function returns the new surface, or NULL if there was an error.
# #
proc TTF_RenderGlyph_Shaded*(font: PTTF_Font, ch: Uint16, fg: TColor, bg: TColor): PSurface{. proc RenderGlyph_Shaded*(font: PFont, ch: Uint16, fg: TColor, bg: TColor): PSurface{.
cdecl, importc: "TTF_RenderGlyph_Shaded", dynlib: ttfLibName.} cdecl, importc: "TTF_RenderGlyph_Shaded", dynlib: ttfLibName.}
# Create a 32-bit ARGB surface and render the given text at high quality, # Create a 32-bit ARGB surface and render the given text at high quality,
# using alpha blending to dither the font with the given color. # using alpha blending to dither the font with the given color.
# This function returns the new surface, or NULL if there was an error. # This function returns the new surface, or NULL if there was an error.
# #
proc TTF_RenderText_Blended*(font: PTTF_Font, text: cstring, fg: TColor): PSurface{. proc RenderText_Blended*(font: PFont, text: cstring, fg: TColor): PSurface{.
cdecl, importc: "TTF_RenderText_Blended", dynlib: ttfLibName.} cdecl, importc: "TTF_RenderText_Blended", dynlib: ttfLibName.}
proc TTF_RenderUTF8_Blended*(font: PTTF_Font, text: cstring, fg: TColor): PSurface{. proc RenderUTF8_Blended*(font: PFont, text: cstring, fg: TColor): PSurface{.
cdecl, importc: "TTF_RenderUTF8_Blended", dynlib: ttfLibName.} cdecl, importc: "TTF_RenderUTF8_Blended", dynlib: ttfLibName.}
proc TTF_RenderUNICODE_Blended*(font: PTTF_Font, text: PUint16, fg: TColor): PSurface{. proc RenderUNICODE_Blended*(font: PFont, text: PUint16, fg: TColor): PSurface{.
cdecl, importc: "TTF_RenderUNICODE_Blended", dynlib: ttfLibName.} cdecl, importc: "TTF_RenderUNICODE_Blended", dynlib: ttfLibName.}
# Create a 32-bit ARGB surface and render the given glyph at high quality, # Create a 32-bit ARGB surface and render the given glyph at high quality,
# using alpha blending to dither the font with the given color. # using alpha blending to dither the font with the given color.
@ -316,7 +307,7 @@ proc TTF_RenderUNICODE_Blended*(font: PTTF_Font, text: PUint16, fg: TColor): PSu
# direction, and aligned normally in the Y direction. # direction, and aligned normally in the Y direction.
# This function returns the new surface, or NULL if there was an error. # This function returns the new surface, or NULL if there was an error.
# #
proc TTF_RenderGlyph_Blended*(font: PTTF_Font, ch: Uint16, fg: TColor): PSurface{. proc RenderGlyph_Blended*(font: PFont, ch: Uint16, fg: TColor): PSurface{.
cdecl, importc: "TTF_RenderGlyph_Blended", dynlib: ttfLibName.} cdecl, importc: "TTF_RenderGlyph_Blended", dynlib: ttfLibName.}
# For compatibility with previous versions, here are the old functions # For compatibility with previous versions, here are the old functions
##define TTF_RenderText(font, text, fg, bg) ##define TTF_RenderText(font, text, fg, bg)
@ -326,32 +317,25 @@ proc TTF_RenderGlyph_Blended*(font: PTTF_Font, ch: Uint16, fg: TColor): PSurface
##define TTF_RenderUNICODE(font, text, fg, bg) ##define TTF_RenderUNICODE(font, text, fg, bg)
# TTF_RenderUNICODE_Shaded(font, text, fg, bg) # TTF_RenderUNICODE_Shaded(font, text, fg, bg)
# Close an opened font file # Close an opened font file
proc TTF_CloseFont*(font: PTTF_Font){.cdecl, importc: "TTF_CloseFont", proc CloseFont*(font: PFont){.cdecl, importc: "TTF_CloseFont",
dynlib: ttfLibName.} dynlib: ttfLibName.}
#De-initialize TTF engine #De-initialize TTF engine
proc TTF_Quit*(){.cdecl, importc: "TTF_Quit", dynlib: ttfLibName.} proc Quit*(){.cdecl, importc: "TTF_Quit", dynlib: ttfLibName.}
# Check if the TTF engine is initialized # Check if the TTF engine is initialized
proc TTF_WasInit*(): int{.cdecl, importc: "TTF_WasInit", dynlib: ttfLibName.} proc WasInit*(): int{.cdecl, importc: "TTF_WasInit", dynlib: ttfLibName.}
# We'll use SDL for reporting errors
proc TTF_SetError*(fmt: cstring)
proc TTF_GetError*(): cstring
# implementation
proc TTF_VERSION(X: var Tversion) =
X.major = TTF_MAJOR_VERSION
X.minor = TTF_MINOR_VERSION
X.patch = TTF_PATCHLEVEL
proc TTF_SetError(fmt: cstring) = proc VERSION*(X: var sdl.Tversion) =
SetError(fmt) X.major = MAJOR_VERSION
X.minor = MINOR_VERSION
X.patch = PATCHLEVEL
proc TTF_GetError(): cstring =
result = GetError()
when not (defined(Workaround_TTF_RenderText_Solid)): when not (defined(Workaround_RenderText_Solid)):
proc TTF_RenderText_Solid*(font: PTTF_Font, text: cstring, fg: TColor): PSurface{. proc RenderText_Solid*(font: PFont, text: cstring, fg: TColor): PSurface{.
cdecl, importc: "TTF_RenderText_Solid", dynlib: ttfLibName.} cdecl, importc: "TTF_RenderText_Solid", dynlib: ttfLibName.}
else: else:
proc TTF_RenderText_Solid(font: PTTF_Font, text: cstring, fg: TColor): PSurface = proc RenderText_Solid(font: PFont, text: cstring, fg: TColor): PSurface =
var Black: TColor # initialized to zero var Black: TColor # initialized to zero
Result = TTF_RenderText_Shaded(font, text, fg, Black) result = RenderText_Shaded(font, text, fg, Black)

View file

@ -126,7 +126,7 @@
#****************************************************************************** #******************************************************************************
import import
sdl
when defined(windows): when defined(windows):
const const
@ -138,57 +138,53 @@ else:
const const
SmpegLibName = "libsmpeg.so" SmpegLibName = "libsmpeg.so"
const const
SMPEG_FILTER_INFO_MB_ERROR* = 1 FILTER_INFO_MB_ERROR* = 1
SMPEG_FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG FILTER_INFO_PIXEL_ERROR* = 2 # Filter info from SMPEG
type type
SMPEG_FilterInfo*{.final.} = object TFilterInfo*{.final.} = object
yuv_mb_square_error*: PUint16 yuv_mb_square_error*: PUint16
yuv_pixel_square_error*: PUint16 yuv_pixel_square_error*: PUint16
TSMPEG_FilterInfo* = SMPEG_FilterInfo PFilterInfo* = ptr TFilterInfo # MPEG filter definition
PSMPEG_FilterInfo* = ptr SMPEG_FilterInfo # MPEG filter definition PFilter* = ptr TFilter # Callback functions for the filter
PSMPEG_Filter* = ptr TSMPEG_Filter # Callback functions for the filter TFilterCallback* = proc (dest, source: POverlay, region: PRect,
TSMPEG_FilterCallback* = proc (dest, source: POverlay, region: PRect, filter_info: PFilterInfo, data: Pointer): Pointer{.
filter_info: PSMPEG_FilterInfo, data: Pointer): Pointer{.
cdecl.} cdecl.}
TSMPEG_FilterDestroy* = proc (Filter: PSMPEG_Filter): Pointer{.cdecl.} # The filter TFilterDestroy* = proc (Filter: PFilter): Pointer{.cdecl.} # The filter definition itself
# TFilter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay.
# definition itself
TSMPEG_Filter*{.final.} = object # The null filter (default). It simply copies the source rectangle to the video overlay.
flags*: Uint32 flags*: Uint32
data*: Pointer data*: Pointer
callback*: TSMPEG_FilterCallback callback*: TFilterCallback
destroy*: TSMPEG_FilterDestroy destroy*: TFilterDestroy
proc SMPEGfilter_null*(): PSMPEG_Filter{.cdecl, importc: "SMPEGfilter_null", proc filter_null*(): PFilter{.cdecl, importc: "SMPEGfilter_null",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# The bilinear filter. A basic low-pass filter that will produce a smoother image. # The bilinear filter. A basic low-pass filter that will produce a smoother image.
proc SMPEGfilter_bilinear*(): PSMPEG_Filter{.cdecl, proc filter_bilinear*(): PFilter{.cdecl,
importc: "SMPEGfilter_bilinear", dynlib: SmpegLibName.} importc: "SMPEGfilter_bilinear", dynlib: SmpegLibName.}
# The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness # The deblocking filter. It filters block borders and non-intra coded blocks to reduce blockiness
proc SMPEGfilter_deblocking*(): PSMPEG_Filter{.cdecl, proc filter_deblocking*(): PFilter{.cdecl,
importc: "SMPEGfilter_deblocking", dynlib: SmpegLibName.} importc: "SMPEGfilter_deblocking", dynlib: SmpegLibName.}
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# SMPEG.h # SMPEG.h
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
const const
SMPEG_MAJOR_VERSION* = 0'i8 MAJOR_VERSION* = 0'i8
SMPEG_MINOR_VERSION* = 4'i8 MINOR_VERSION* = 4'i8
SMPEG_PATCHLEVEL* = 2'i8 PATCHLEVEL* = 2'i8
type type
SMPEG_version*{.final.} = object TVersion*{.final.} = object
major*: UInt8 major*: UInt8
minor*: UInt8 minor*: UInt8
patch*: UInt8 patch*: UInt8
TSMPEG_version* = SMPEG_version Pversion* = ptr Tversion # This is the actual SMPEG object
PSMPEG_version* = ptr TSMPEG_version # This is the actual SMPEG object
TSMPEG*{.final.} = object TSMPEG*{.final.} = object
PSMPEG* = ptr TSMPEG # Used to get information about the SMPEG object PSMPEG* = ptr TSMPEG # Used to get information about the SMPEG object
TSMPEG_Info*{.final.} = object TInfo*{.final.} = object
has_audio*: int has_audio*: int
has_video*: int has_video*: int
width*: int width*: int
@ -202,138 +198,138 @@ type
current_time*: float64 current_time*: float64
total_time*: float64 total_time*: float64
PSMPEG_Info* = ptr TSMPEG_Info # Possible MPEG status codes PInfo* = ptr TInfo # Possible MPEG status codes
const const
STATUS_SMPEG_ERROR* = - 1 STATUS_ERROR* = - 1
STATUS_SMPEG_STOPPED* = 0 STATUS_STOPPED* = 0
STATUS_SMPEG_PLAYING* = 1 STATUS_PLAYING* = 1
type type
TSMPEGstatus* = int Tstatus* = int
PSMPEGstatus* = ptr int # Matches the declaration of SDL_UpdateRect() Pstatus* = ptr int # Matches the declaration of SDL_UpdateRect()
TSMPEG_DisplayCallback* = proc (dst: PSurface, x, y: int, w, h: int): Pointer{. TDisplayCallback* = proc (dst: PSurface, x, y: int, w, h: int): Pointer{.
cdecl.} # Create a new SMPEG object from an MPEG file. cdecl.} # Create a new SMPEG object from an MPEG file.
# On return, if 'info' is not NULL, it will be filled with information # On return, if 'info' is not NULL, it will be filled with information
# about the MPEG object. # about the MPEG object.
# This function returns a new SMPEG object. Use SMPEG_error() to find out # This function returns a new SMPEG object. Use error() to find out
# whether or not there was a problem building the MPEG stream. # whether or not there was a problem building the MPEG stream.
# The sdl_audio parameter indicates if SMPEG should initialize the SDL audio # The sdl_audio parameter indicates if SMPEG should initialize the SDL audio
# subsystem. If not, you will have to use the SMPEG_playaudio() function below # subsystem. If not, you will have to use the playaudio() function below
# to extract the decoded data. # to extract the decoded data.
proc SMPEG_new*(theFile: cstring, info: PSMPEG_Info, audio: int): PSMPEG{.cdecl, proc SMPEG_new*(theFile: cstring, info: PInfo, audio: int): PSMPEG{.cdecl,
importc: "SMPEG_new", dynlib: SmpegLibName.} importc: "SMPEG_new", dynlib: SmpegLibName.}
# The same as above for a file descriptor # The same as above for a file descriptor
proc SMPEG_new_descr*(theFile: int, info: PSMPEG_Info, audio: int): PSMPEG{. proc new_descr*(theFile: int, info: PInfo, audio: int): PSMPEG{.
cdecl, importc: "SMPEG_new_descr", dynlib: SmpegLibName.} cdecl, importc: "SMPEG_new_descr", dynlib: SmpegLibName.}
# The same as above but for a raw chunk of data. SMPEG makes a copy of the # The same as above but for a raw chunk of data. SMPEG makes a copy of the
# data, so the application is free to delete after a successful call to this # data, so the application is free to delete after a successful call to this
# function. # function.
proc SMPEG_new_data*(data: Pointer, size: int, info: PSMPEG_Info, audio: int): PSMPEG{. proc new_data*(data: Pointer, size: int, info: PInfo, audio: int): PSMPEG{.
cdecl, importc: "SMPEG_new_data", dynlib: SmpegLibName.} cdecl, importc: "SMPEG_new_data", dynlib: SmpegLibName.}
# Get current information about an SMPEG object # Get current information about an SMPEG object
proc SMPEG_getinfo*(mpeg: PSMPEG, info: PSMPEG_Info){.cdecl, proc getinfo*(mpeg: PSMPEG, info: PInfo){.cdecl,
importc: "SMPEG_getinfo", dynlib: SmpegLibName.} importc: "SMPEG_getinfo", dynlib: SmpegLibName.}
#procedure SMPEG_getinfo(mpeg: PSMPEG; info: Pointer); #procedure getinfo(mpeg: PSMPEG; info: Pointer);
#cdecl; external SmpegLibName; #cdecl; external SmpegLibName;
# Enable or disable audio playback in MPEG stream # Enable or disable audio playback in MPEG stream
proc SMPEG_enableaudio*(mpeg: PSMPEG, enable: int){.cdecl, proc enableaudio*(mpeg: PSMPEG, enable: int){.cdecl,
importc: "SMPEG_enableaudio", dynlib: SmpegLibName.} importc: "SMPEG_enableaudio", dynlib: SmpegLibName.}
# Enable or disable video playback in MPEG stream # Enable or disable video playback in MPEG stream
proc SMPEG_enablevideo*(mpeg: PSMPEG, enable: int){.cdecl, proc enablevideo*(mpeg: PSMPEG, enable: int){.cdecl,
importc: "SMPEG_enablevideo", dynlib: SmpegLibName.} importc: "SMPEG_enablevideo", dynlib: SmpegLibName.}
# Delete an SMPEG object # Delete an SMPEG object
proc SMPEG_delete*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_delete", proc delete*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_delete",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# Get the current status of an SMPEG object # Get the current status of an SMPEG object
proc SMPEG_status*(mpeg: PSMPEG): TSMPEGstatus{.cdecl, importc: "SMPEG_status", proc status*(mpeg: PSMPEG): Tstatus{.cdecl, importc: "SMPEG_status",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# status # status
# Set the audio volume of an MPEG stream, in the range 0-100 # Set the audio volume of an MPEG stream, in the range 0-100
proc SMPEG_setvolume*(mpeg: PSMPEG, volume: int){.cdecl, proc setvolume*(mpeg: PSMPEG, volume: int){.cdecl,
importc: "SMPEG_setvolume", dynlib: SmpegLibName.} importc: "SMPEG_setvolume", dynlib: SmpegLibName.}
# Set the destination surface for MPEG video playback # Set the destination surface for MPEG video playback
# 'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL. # 'surfLock' is a mutex used to synchronize access to 'dst', and can be NULL.
# 'callback' is a function called when an area of 'dst' needs to be updated. # 'callback' is a function called when an area of 'dst' needs to be updated.
# If 'callback' is NULL, the default function (SDL_UpdateRect) will be used. # If 'callback' is NULL, the default function (SDL_UpdateRect) will be used.
proc SMPEG_setdisplay*(mpeg: PSMPEG, dst: PSurface, surfLock: Pmutex, proc setdisplay*(mpeg: PSMPEG, dst: PSurface, surfLock: Pmutex,
callback: TSMPEG_DisplayCallback){.cdecl, callback: TDisplayCallback){.cdecl,
importc: "SMPEG_setdisplay", dynlib: SmpegLibName.} importc: "SMPEG_setdisplay", dynlib: SmpegLibName.}
# Set or clear looping play on an SMPEG object # Set or clear looping play on an SMPEG object
proc SMPEG_loop*(mpeg: PSMPEG, repeat_: int){.cdecl, importc: "SMPEG_loop", proc loop*(mpeg: PSMPEG, repeat_: int){.cdecl, importc: "SMPEG_loop",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# Scale pixel display on an SMPEG object # Scale pixel display on an SMPEG object
proc SMPEG_scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl, proc scaleXY*(mpeg: PSMPEG, width, height: int){.cdecl,
importc: "SMPEG_scaleXY", dynlib: SmpegLibName.} importc: "SMPEG_scaleXY", dynlib: SmpegLibName.}
proc SMPEG_scale*(mpeg: PSMPEG, scale: int){.cdecl, importc: "SMPEG_scale", proc scale*(mpeg: PSMPEG, scale: int){.cdecl, importc: "SMPEG_scale",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
proc SMPEG_Double*(mpeg: PSMPEG, doubleit: bool) proc Double*(mpeg: PSMPEG, doubleit: bool)
# Move the video display area within the destination surface # Move the video display area within the destination surface
proc SMPEG_move*(mpeg: PSMPEG, x, y: int){.cdecl, importc: "SMPEG_move", proc move*(mpeg: PSMPEG, x, y: int){.cdecl, importc: "SMPEG_move",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# Set the region of the video to be shown # Set the region of the video to be shown
proc SMPEG_setdisplayregion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl, proc setdisplayregion*(mpeg: PSMPEG, x, y, w, h: int){.cdecl,
importc: "SMPEG_setdisplayregion", dynlib: SmpegLibName.} importc: "SMPEG_setdisplayregion", dynlib: SmpegLibName.}
# Play an SMPEG object # Play an SMPEG object
proc SMPEG_play*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_play", proc play*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_play",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# Pause/Resume playback of an SMPEG object # Pause/Resume playback of an SMPEG object
proc SMPEG_pause*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_pause", proc pause*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_pause",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# Stop playback of an SMPEG object # Stop playback of an SMPEG object
proc SMPEG_stop*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_stop", proc stop*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_stop",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# Rewind the play position of an SMPEG object to the beginning of the MPEG # Rewind the play position of an SMPEG object to the beginning of the MPEG
proc SMPEG_rewind*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_rewind", proc rewind*(mpeg: PSMPEG){.cdecl, importc: "SMPEG_rewind",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# Seek 'bytes' bytes in the MPEG stream # Seek 'bytes' bytes in the MPEG stream
proc SMPEG_seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc: "SMPEG_seek", proc seek*(mpeg: PSMPEG, bytes: int){.cdecl, importc: "SMPEG_seek",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# Skip 'seconds' seconds in the MPEG stream # Skip 'seconds' seconds in the MPEG stream
proc SMPEG_skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc: "SMPEG_skip", proc skip*(mpeg: PSMPEG, seconds: float32){.cdecl, importc: "SMPEG_skip",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# Render a particular frame in the MPEG video # Render a particular frame in the MPEG video
# API CHANGE: This function no longer takes a target surface and position. # API CHANGE: This function no longer takes a target surface and position.
# Use SMPEG_setdisplay() and SMPEG_move() to set this information. # Use setdisplay() and move() to set this information.
proc SMPEG_renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl, proc renderFrame*(mpeg: PSMPEG, framenum: int){.cdecl,
importc: "SMPEG_renderFrame", dynlib: SmpegLibName.} importc: "SMPEG_renderFrame", dynlib: SmpegLibName.}
# Render the last frame of an MPEG video # Render the last frame of an MPEG video
proc SMPEG_renderFinal*(mpeg: PSMPEG, dst: PSurface, x, y: int){.cdecl, proc renderFinal*(mpeg: PSMPEG, dst: PSurface, x, y: int){.cdecl,
importc: "SMPEG_renderFinal", dynlib: SmpegLibName.} importc: "SMPEG_renderFinal", dynlib: SmpegLibName.}
# Set video filter # Set video filter
proc SMPEG_filter*(mpeg: PSMPEG, filter: PSMPEG_Filter): PSMPEG_Filter{.cdecl, proc filter*(mpeg: PSMPEG, filter: PFilter): PFilter{.cdecl,
importc: "SMPEG_filter", dynlib: SmpegLibName.} importc: "SMPEG_filter", dynlib: SmpegLibName.}
# Return NULL if there is no error in the MPEG stream, or an error message # Return NULL if there is no error in the MPEG stream, or an error message
# if there was a fatal error in the MPEG stream for the SMPEG object. # if there was a fatal error in the MPEG stream for the SMPEG object.
proc SMPEG_error*(mpeg: PSMPEG): cstring{.cdecl, importc: "SMPEG_error", proc error*(mpeg: PSMPEG): cstring{.cdecl, importc: "SMPEG_error",
dynlib: SmpegLibName.} dynlib: SmpegLibName.}
# Exported callback function for audio playback. # Exported callback function for audio playback.
# The function takes a buffer and the amount of data to fill, and returns # The function takes a buffer and the amount of data to fill, and returns
# the amount of data in bytes that was actually written. This will be the # the amount of data in bytes that was actually written. This will be the
# amount requested unless the MPEG audio has finished. # amount requested unless the MPEG audio has finished.
# #
proc SMPEG_playAudio*(mpeg: PSMPEG, stream: PUInt8, length: int): int{.cdecl, proc playAudio*(mpeg: PSMPEG, stream: PUInt8, length: int): int{.cdecl,
importc: "SMPEG_playAudio", dynlib: SmpegLibName.} importc: "SMPEG_playAudio", dynlib: SmpegLibName.}
# Wrapper for SMPEG_playAudio() that can be passed to SDL and SDL_mixer # Wrapper for playAudio() that can be passed to SDL and SDL_mixer
proc SMPEG_playAudioSDL*(mpeg: Pointer, stream: PUInt8, length: int){.cdecl, proc playAudioSDL*(mpeg: Pointer, stream: PUInt8, length: int){.cdecl,
importc: "SMPEG_playAudioSDL", dynlib: SmpegLibName.} importc: "SMPEG_playAudioSDL", dynlib: SmpegLibName.}
# Get the best SDL audio spec for the audio stream # Get the best SDL audio spec for the audio stream
proc SMPEG_wantedSpec*(mpeg: PSMPEG, wanted: PAudioSpec): int{.cdecl, proc wantedSpec*(mpeg: PSMPEG, wanted: PAudioSpec): int{.cdecl,
importc: "SMPEG_wantedSpec", dynlib: SmpegLibName.} importc: "SMPEG_wantedSpec", dynlib: SmpegLibName.}
# Inform SMPEG of the actual SDL audio spec used for sound playback # Inform SMPEG of the actual SDL audio spec used for sound playback
proc SMPEG_actualSpec*(mpeg: PSMPEG, spec: PAudioSpec){.cdecl, proc actualSpec*(mpeg: PSMPEG, spec: PAudioSpec){.cdecl,
importc: "SMPEG_actualSpec", dynlib: SmpegLibName.} importc: "SMPEG_actualSpec", dynlib: SmpegLibName.}
# This macro can be used to fill a version structure with the compile-time # This macro can be used to fill a version structure with the compile-time
# version of the SDL library. # version of the SDL library.
proc SMPEG_GETVERSION*(X: var TSMPEG_version) proc GETVERSION*(X: var Tversion)
# implementation # implementation
proc SMPEG_double(mpeg: PSMPEG, doubleit: bool) = proc double(mpeg: PSMPEG, doubleit: bool) =
if doubleit: SMPEG_scale(mpeg, 2) if doubleit: scale(mpeg, 2)
else: SMPEG_scale(mpeg, 1) else: scale(mpeg, 1)
proc SMPEG_GETVERSION(X: var TSMPEG_version) = proc GETVERSION(X: var Tversion) =
X.major = SMPEG_MAJOR_VERSION X.major = MAJOR_VERSION
X.minor = SMPEG_MINOR_VERSION X.minor = MINOR_VERSION
X.patch = SMPEG_PATCHLEVEL X.patch = PATCHLEVEL

View file

@ -1,7 +1,7 @@
# #
# #
# The Nimrod Compiler # The Nimrod Compiler
# (c) Copyright 2009 Andreas Rumpf # (c) Copyright 2010 Andreas Rumpf
# #
# See the file "copying.txt", included in this # See the file "copying.txt", included in this
# distribution, for details about the copyright. # distribution, for details about the copyright.