text stringlengths 0 601k |
|---|
module Function = struct type param = { name : name ; typ : Typing . t } type t = { name : name ; desc : string option ; return : Typing . t ; params : param list ; } let to_name cname = { name = Naming . to_snake_case cname ; cname } let to_param cname typ = { name = to_name cname ; typ = Typing . of_cname typ None } ... |
let ( ) = let api = Yojson . Basic . from_file " src / util / raylib_api . json " in let open Yojson . Basic . Util in let enums = api |> member " enums " |> to_list |> List . filter_map Enum . of_json in let stubs = " let % c ( ) = header " \# include < raylib . h >\\ n # include < config . h " >\\ n \ n " ^ ( enums |... |
module Description ( F : Ctypes . FOREIGN ) = struct open Ctypes open F let clamp = foreign " Clamp " ( float @-> float @-> float @-> returning float ) let lerp = foreign " Lerp " ( float @-> float @-> float @-> returning float ) module Vector2 = struct let zero = foreign " Vector2Zero " ( void @-> returning Types . Ve... |
module Description ( F : Ctypes . FOREIGN ) = struct open Ctypes open F open Raylib_generated_types open Rlgl_generated_types let matrix_mode = foreign " rlMatrixMode " ( int @-> returning void ) let push_matrix = foreign " rlPushMatrix " ( void @-> returning void ) let pop_matrix = foreign " rlPopMatrix " ( void @-> r... |
module Math = Raylib_math . Description ( Raylib_c . Raylib_c_generated_math ) |
module Vector2 = struct type t ' = Types . Vector2 . t type t = t ' ctyp let t = Types . Vector2 . t let create x y = let vector2 = make t in setf vector2 Types . Vector2 . x x ; setf vector2 Types . Vector2 . y y ; vector2 let x vector2 = getf vector2 Types . Vector2 . x let y vector2 = getf vector2 Types . Vector2 . ... |
module Vector3 = struct type t ' = Types . Vector3 . t type t = t ' ctyp let t = Types . Vector3 . t let create x y z = let vector3 = make t in setf vector3 Types . Vector3 . x x ; setf vector3 Types . Vector3 . y y ; setf vector3 Types . Vector3 . z z ; vector3 let x vector3 = getf vector3 Types . Vector3 . x let y ve... |
module Vector4 = struct type t ' = Types . Vector4 . t type t = t ' ctyp let t = Types . Vector4 . t let create x y z w = let vector4 = make t in setf vector4 Types . Vector4 . x x ; setf vector4 Types . Vector4 . y y ; setf vector4 Types . Vector4 . z z ; setf vector4 Types . Vector4 . w w ; vector4 let x vector4 = ge... |
module Matrix = struct type t ' = Types . Matrix . t type t = t ' ctyp let t = Types . Matrix . t let create m0 m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 m13 m14 m15 = let matrix = make t in setf matrix Types . Matrix . m0 m0 ; setf matrix Types . Matrix . m1 m1 ; setf matrix Types . Matrix . m2 m2 ; setf matrix Types . M... |
module Color = struct type t ' = Types . Color . t type t = t ' ctyp let t = Types . Color . t let r t = getf t Types . Color . r |> Unsigned . UChar . to_int let g t = getf t Types . Color . g |> Unsigned . UChar . to_int let b t = getf t Types . Color . b |> Unsigned . UChar . to_int let a t = getf t Types . Color . ... |
module Rectangle = struct type t ' = Types . Rectangle . t type t = t ' ctyp let t = Types . Rectangle . t let create x y width height = let rectangle = make t in setf rectangle Types . Rectangle . x x ; setf rectangle Types . Rectangle . y y ; setf rectangle Types . Rectangle . width width ; setf rectangle Types . Rec... |
module Image = struct type t ' = Types . Image . t type t = t ' ctyp let t = Types . Image . t let width image = getf image Types . Image . width let height image = getf image Types . Image . height let mipmaps image = getf image Types . Image . mipmaps let format image = getf image Types . Image . format |> PixelForma... |
module Texture = struct type t ' = Types . Texture . t type t = t ' ctyp let t = Types . Texture . t let id texture = getf texture Types . Texture . id let width texture = getf texture Types . Texture . width let height texture = getf texture Types . Texture . height let mipmaps texture = getf texture Types . Texture .... |
module RenderTexture = struct type t ' = Types . RenderTexture . t type t = t ' ctyp let t = Types . RenderTexture . t let id rendertexture = getf rendertexture Types . RenderTexture . id let texture rendertexture = getf rendertexture Types . RenderTexture . texture let depth rendertexture = getf rendertexture Types . ... |
module NPatchInfo = struct type t ' = Types . NPatchInfo . t type t = t ' ctyp let t = Types . NPatchInfo . t let create source left top right bottom layout = let npatchinfo = make t in setf npatchinfo Types . NPatchInfo . source source ; setf npatchinfo Types . NPatchInfo . left left ; setf npatchinfo Types . NPatchIn... |
module GlyphInfo = struct type t ' = Types . GlyphInfo . t type t = t ' ctyp let t = Types . GlyphInfo . t let create value offset_x offset_y advance_x image = let glyphinfo = make t in setf glyphinfo Types . GlyphInfo . value value ; setf glyphinfo Types . GlyphInfo . offset_x offset_x ; setf glyphinfo Types . GlyphIn... |
module Font = struct type t ' = Types . Font . t type t = t ' ctyp let t = Types . Font . t let base_size font = getf font Types . Font . base_size let glyph_padding font = getf font Types . Font . glyph_padding let texture font = getf font Types . Font . texture let recs font = getf font Types . Font . recs let glyphs... |
module Camera3D = struct type t ' = Types . Camera3D . t type t = t ' ctyp let t = Types . Camera3D . t let create position target up fovy projection = let camera3d = make t in setf camera3d Types . Camera3D . position position ; setf camera3d Types . Camera3D . target target ; setf camera3d Types . Camera3D . up up ; ... |
module Camera2D = struct type t ' = Types . Camera2D . t type t = t ' ctyp let t = Types . Camera2D . t let create offset target rotation zoom = let camera2d = make t in setf camera2d Types . Camera2D . offset offset ; setf camera2d Types . Camera2D . target target ; setf camera2d Types . Camera2D . rotation rotation ;... |
module Mesh = struct type t ' = Types . Mesh . t type t = t ' ctyp let t = Types . Mesh . t let create ( ) = let t = Types . Mesh . t in make t let vertex_count mesh = getf mesh Types . Mesh . vertex_count let triangle_count mesh = getf mesh Types . Mesh . triangle_count let vertices mesh = CArray . from_ptr ( getf mes... |
module ShaderLoc = struct type t = int end |
module Shader = struct type t ' = Types . Shader . t type t = t ' ctyp let t = Types . Shader . t let shader id locs = let shader = Ctypes . make Types . Shader . t in Ctypes . setf shader Types . Shader . id id ; Ctypes . setf shader Types . Shader . locs ( Ctypes . CArray . start locs ) ; shader let id shader = getf ... |
module MaterialMap = struct type t ' = Types . MaterialMap . t type t = t ' ctyp let t = Types . MaterialMap . t let create texture color value = let materialmap = make t in setf materialmap Types . MaterialMap . texture texture ; setf materialmap Types . MaterialMap . color color ; setf materialmap Types . MaterialMap... |
module Material = struct type t ' = Types . Material . t type t = t ' ctyp let t = Types . Material . t let shader material = getf material Types . Material . shader let maps material = CArray . from_ptr ( getf material Types . Material . maps ) max_material_maps let params material = getf material Types . Material . p... |
module Transform = struct type t ' = Types . Transform . t type t = t ' ctyp let t = Types . Transform . t let create translation rotation scale = let transform = make t in setf transform Types . Transform . translation translation ; setf transform Types . Transform . rotation rotation ; setf transform Types . Transfor... |
module BoneInfo = struct type t ' = Types . BoneInfo . t type t = t ' ctyp let t = Types . BoneInfo . t let parent boneinfo = getf boneinfo Types . BoneInfo . parent let set_parent boneinfo parent = setf boneinfo Types . BoneInfo . parent parent end |
module Model = struct type t ' = Types . Model . t type t = t ' ctyp let t = Types . Model . t let transform model = getf model Types . Model . transform let meshes model = let count = getf model Types . Model . mesh_count in CArray . from_ptr ( getf model Types . Model . meshes ) count let materials model = let count ... |
module ModelAnimation = struct type t ' = Types . ModelAnimation . t type t = t ' ctyp let t = Types . ModelAnimation . t let bones modelanimation = let count = getf modelanimation Types . ModelAnimation . bone_count in CArray . from_ptr ( getf modelanimation Types . ModelAnimation . bones ) count let frame_count model... |
module Ray = struct type t ' = Types . Ray . t type t = t ' ctyp let t = Types . Ray . t let create position direction = let ray = make t in setf ray Types . Ray . position position ; setf ray Types . Ray . direction direction ; ray let position ray = getf ray Types . Ray . position let direction ray = getf ray Types .... |
module RayCollision = struct type t ' = Types . RayCollision . t type t = t ' ctyp let t = Types . RayCollision . t let hit raycollision = getf raycollision Types . RayCollision . hit let distance raycollision = getf raycollision Types . RayCollision . distance let point raycollision = getf raycollision Types . RayColl... |
module BoundingBox = struct type t ' = Types . BoundingBox . t type t = t ' ctyp let t = Types . BoundingBox . t let create min max = let boundingbox = make t in setf boundingbox Types . BoundingBox . min min ; setf boundingbox Types . BoundingBox . max max ; boundingbox let min boundingbox = getf boundingbox Types . B... |
module Wave = struct type t ' = Types . Wave . t type t = t ' ctyp let t = Types . Wave . t let frame_count sound = getf sound Types . Wave . frame_count let sample_rate wave = getf wave Types . Wave . sample_rate let sample_size wave = getf wave Types . Wave . sample_size let channels wave = getf wave Types . Wave . c... |
module AudioStream = struct type t ' = Types . AudioStream . t type t = t ' ctyp let t = Types . AudioStream . t let sample_rate audiostream = getf audiostream Types . AudioStream . sample_rate let sample_size audiostream = getf audiostream Types . AudioStream . sample_size let channels audiostream = getf audiostream T... |
module Sound = struct type t ' = Types . Sound . t type t = t ' ctyp let t = Types . Sound . t let stream sound = getf sound Types . Sound . stream let frame_count sound = getf sound Types . Sound . frame_count let set_stream sound stream = setf sound Types . Sound . stream stream let set_frame_count sound frame_count ... |
module Music = struct type t ' = Types . Music . t type t = t ' ctyp let t = Types . Music . t let frame_count music = getf music Types . Music . frame_count let stream music = getf music Types . Music . stream let looping music = getf music Types . Music . looping let ctx_type music = getf music Types . Music . ctx_ty... |
module VrDeviceInfo = struct type t ' = Types . VrDeviceInfo . t type t = t ' ctyp let t = Types . VrDeviceInfo . t let create ( ) = make t let h_resolution vrdeviceinfo = getf vrdeviceinfo Types . VrDeviceInfo . h_resolution let v_resolution vrdeviceinfo = getf vrdeviceinfo Types . VrDeviceInfo . v_resolution let h_sc... |
module VrStereoConfig = struct type t ' = Types . VrStereoConfig . t type t = t ' ctyp let t = Types . VrStereoConfig . t let projection vrstereoconfig = getf vrstereoconfig Types . VrStereoConfig . projection let view_offset vrstereoconfig = getf vrstereoconfig Types . VrStereoConfig . view_offset let left_lens_center... |
module Color = struct type t = { red : float ; green : float ; blue : float } let make r g b = { red = r ; green = g ; blue = b } let limit c = { red = ( let red = c . red in if red <= 0 . then 0 . else if red > 1 . 0 then 1 . 0 else red ) ; green = ( let green = c . green in if green <= 0 . then 0 . else if green > 1 ... |
module Vector = struct type t = { x : float ; mutable y : float ; z : float } let make x y z = { x ; y ; z } let magnitude v = sqrt ( ( v . x . * v . x ) . + ( v . y . * v . y ) . + ( v . z . * v . z ) ) let normalize v = let m = magnitude v in { x = v . x . / m ; y = v . y . / m ; z = v . z . / m } let cross v w = { x... |
module Light = struct type t = { position : Vector . t ; color : Color . t ; intensity : float } let make p c i = { position = p ; color = c ; intensity = i } end |
module Ray = struct type t = { position : Vector . t ; direction : Vector . t } let make p d = { position = p ; direction = d } end |
module Intersection_info = struct type ' a t = { shape : ' a ; distance : float ; position : Vector . t ; normal : Vector . t ; color : Color . t } end |
module Camera = struct type t = { position : Vector . t ; look_at : Vector . t ; equator : Vector . t ; up : Vector . t ; screen : Vector . t } let make pos look_at up = { position = pos ; look_at ; up ; equator = Vector . cross ( Vector . normalize look_at ) up ; screen = Vector . add pos look_at } let get_ray c vx vy... |
module Background = struct type t = { color : Color . t ; ambience : float } let make c a = { color = c ; ambience = a } end |
module Material = struct type t = { reflection : float ; transparency : float ; gloss : float ; has_texture : bool ; get_color : float -> float -> Color . t } let wrap_up t = let t = mod_float t 2 . 0 in if t < - 1 . then t . + 2 . 0 else if t >= 1 . then t . - 2 . 0 else t let solid color reflection transparency gloss... |
module Shape = struct type shape = | Sphere of Vector . t * float | Plane of Vector . t * float type t = { shape : shape ; material : Material . t } let make shape material = { shape ; material } let dummy = make ( Sphere ( Vector . make 0 . 0 . 0 . , 0 . ) ) ( Material . solid ( Color . make 0 . 0 . 0 . ) 0 . 0 . 0 . ... |
module Scene = struct type t = { camera : Camera . t ; shapes : Shape . t array ; lights : Light . t array ; background : Background . t } let make c s l b = { camera = c ; shapes = s ; lights = l ; background = b } end |
module Engine = struct type t = { pixel_width : int ; pixel_height : int ; canvas_width : int ; canvas_height : int ; render_diffuse : bool ; render_shadows : bool ; render_highlights : bool ; render_reflections : bool ; ray_depth : int } let check_number = ref 0 let get_reflection_ray p n v = let c1 = . - Vector . dot... |
let render_scene ( ) = let camera = Camera . make ( Vector . make 0 . 0 . ( - 15 . ) ) ( Vector . make ( - 0 . 2 ) 0 . 5 . ) ( Vector . make 0 . 1 . 0 . ) in let background = Background . make ( Color . make 0 . 5 0 . 5 0 . 5 ) 0 . 4 in let sphere = Shape . make ( Shape . Sphere ( Vector . make ( - 1 . 5 ) 1 . 5 2 . , ... |
let _ = for _ = 0 to 99 do render_scene ( ) done |
let tot_time = ref 0 . |
let measure_time f s = Printf . printf " Using : % s --> " %! s ; let t0 = Unix . gettimeofday ( ) in let a = f ( ) in let t1 = Unix . gettimeofday ( ) in Printf . printf " % Fs \ n " %! ( t1 . - t0 ) ; tot_time := ! tot_time . + ( t1 . - t0 ) ; a ; ; spos : point3 ; radius : float ; scol : color ; sshine : float ; } p... |
let raytrace objects nb_objs width height rays eye lights ambiant bounce imgs shine_colors = let point_diff = fun x y -> { x = x . x . - y . x ; y = x . y . - y . y ; z = x . z . - y . z ; } in let point_add = fun x y -> { x = x . x . + y . x ; y = x . y . + y . y ; z = x . z . + y . z ; } in let dotprod = fun a b -> a... |
let _ = let devs = Devices . init ~ only : Devices . OpenCL ( ) in let dev = devs . ( devid ) in let width = 800 in let height = 600 in let fov = 1 . in let zoom = 1 in let bounces = 4 in let framerate = 30 in let light = { loc = { x ( = 300 . ) ; y ( =- 300 . ) ; z ( =- 100 . ) } ; lcol = { r = 150_000 . ; g = 150_000... |
module type KEY = sig type t val t : t Irmin . Type . t val compare : t -> t -> int val to_string : t -> string end |
module type VALUE = sig type t val merge : ancestor : t -> t -> t -> t end |
module type S = sig type key type value type t = | Black of t * key * value * t | Red of t * key * value * t | Empty val empty : t val is_empty : t -> bool val add : key -> value -> t -> t val insert : key -> value -> t -> t val find : key -> t -> value val remove : key -> t -> t val mem : key -> t -> bool val iter : (... |
module Make ( K : KEY ) ( V : VALUE ) : S with type key = K . t and type value = V . t = struct type key = K . t type value = V . t type t = | Black of t * key * value * t | Red of t * key * value * t | Empty type enum = | End | More of key * value * t * enum let rec enum m e = match m with | Empty -> e | Black ( l , k... |
module type ATOM = sig type t val t : t Irmin . Type . t val compare : t -> t -> int val to_string : t -> string val of_string : string -> t end |
module type S = sig type elt type t val empty : t val is_empty : t -> bool val mem : elt -> t -> bool val add : elt -> t -> t val singleton : elt -> t val remove : elt -> t -> t val union : t -> t -> t val inter : t -> t -> t val diff : t -> t -> t val compare : t -> t -> int val equal : t -> t -> bool val subset : t -... |
module Make ( Atom : ATOM ) = struct type elt = Atom . t type t = | Black of t * elt * t | Red of t * elt * t | Empty type enum = | End | More of elt * t * enum let rec enum s e = match s with | Empty -> e | Black ( l , x , r ) | Red ( l , x , r ) -> enum l ( More ( x , r , e ) ) let blackify = function | Red ( l , x ,... |
type rope = | Str of string | App of rope * rope * int |
let rope_empty = Str " " |
let rope_length = function | Str s -> String . length s | App ( _ , _ , n ) n -> n |
let rec rope_nth i = function | Str s -> String . unsafe_get s i | App ( l , r , _ ) _ -> let ll = rope_length l in if i < ll then rope_nth i l else rope_nth ( i - ll ) ll r |
type t = { mutable rope : rope ; mutable buffer : bytes ; mutable position : int ; } |
let create n = let n = if n < 1 then 1 else n in let n = if n > Sys . max_string_length then Sys . max_string_length else n in let s = Bytes . create n in { rope = rope_empty ; buffer = s ; position = 0 ; } |
let reset b = b . rope <- rope_empty ; b . position <- 0 |
let length b = rope_length b . rope + b . position |
let rec blit_rope s i = function | Str str -> String . blit str 0 s i ( String . length str ) str | App ( l , r , _ ) _ -> let ll = rope_length l in blit_rope s i l ; blit_rope s ( i + ll ) ll r |
let unsafe_contents b = let r = rope_length b . rope in let n = b . position in let len = r + n in if len > Sys . max_string_length then invalid_arg " Rbuffer . contents " ; let s = Bytes . create len in blit_rope s 0 b . rope ; Bytes . blit b . buffer 0 s r n ; Bytes . unsafe_to_string s |
let rec blit_subrope s i ofs len = function | Str str -> assert ( ofs >= 0 && ofs + len <= String . length str ) str ; String . blit str ofs s i len | App ( l , r , _ ) _ -> let ll = rope_length l in if ofs + len <= ll then else if ofs >= ll then else begin end |
let sub b ofs len = let r = rope_length b . rope in if len > Sys . max_string_length || ofs < 0 || len < 0 || ofs > r + b . position - len then invalid_arg " Buffer . sub " ; let s = Bytes . create len in if ofs + len <= r then blit_subrope s 0 ofs len b . rope else if ofs >= r then Bytes . blit b . buffer ( ofs - r ) ... |
let nth b i = let r = rope_length b . rope in if i < 0 || i >= r + b . position then invalid_arg " Buffer . nth " ; if i < r then rope_nth i b . rope else Bytes . unsafe_get b . buffer ( i - r ) r |
let move_buffer_to_rope b = let pos = b . position in if pos > 0 then begin let n = Bytes . length b . buffer in if pos = n then begin b . rope <- App ( b . rope , Str ( Bytes . unsafe_to_string b . buffer ) buffer , rope_length b . rope + pos ) pos ; b . buffer <- Bytes . create n end else begin b . rope <- App ( b . ... |
let add_char b c = if b . position = Bytes . length b . buffer then move_buffer_to_rope b ; let pos = b . position in Bytes . set b . buffer pos c ; b . position <- pos + 1 |
let alloc b len = let n = Bytes . length b . buffer in let pos = b . position in let len ' = pos + len in if len ' <= n then begin b . position <- len ' ; b . buffer , pos end else if len ' <= Sys . max_string_length then begin let str = Bytes . create len ' in Bytes . blit b . buffer 0 str 0 pos ; b . rope <- App ( b ... |
let safe_add_substring b s offset len = let str , pos = alloc b len in String . blit s offset str pos len |
let add_substring b s offset len = if offset < 0 || len < 0 || offset > String . length s - len then invalid_arg " Buffer . add_substring " ; safe_add_substring b s offset len |
let add_string b s = safe_add_substring b s 0 ( String . length s ) s |
let add_buffer b b2 = if b . position > 0 then move_buffer_to_rope b ; b . rope <- App ( b . rope , b2 . rope , rope_length b . rope + rope_length b2 . rope ) rope ; add_substring b ( Bytes . unsafe_to_string b2 . buffer ) buffer 0 b2 . position |
let rec add_channel b ic len = if len <= Sys . max_string_length then begin let str , pos = alloc b len in really_input ic str pos len end else begin let str , pos = alloc b Sys . max_string_length in really_input ic str pos Sys . max_string_length ; add_channel b ic ( len - Sys . max_string_length ) max_string_length ... |
let output_buffer oc b = let rec loop wl = match wl with | Str s :: wl -> output oc ( Bytes . of_string s ) s 0 ( String . length s ) s ; loop wl | App ( App l , r , _ ) _ :: wl -> loop ( l :: r :: wl ) wl | [ ] -> ( ) in loop [ b . rope ] rope ; output oc b . buffer 0 b . position |
let print fmt b = let rec loop wl = match wl with | Str s :: wl -> pp_print_string fmt s ; loop wl | App ( App l , r , _ ) _ :: wl -> loop ( l :: r :: wl ) wl | [ ] -> ( ) in loop [ b . rope ] rope ; pp_print_string fmt ( Bytes . sub_string b . buffer 0 b . position ) position |
module type BITSIZE = sig val bitsize : int end |
module Make ( Bitsize : BITSIZE ) = struct include Bitsize let branching : int = assert ( 0 < bitsize ) ; 1 lsl bitsize let slot ( i : int ) ( l : int ) : int = i lsr ( l * bitsize ) let offset ( i : int ) ( s : int ) ( l : int ) : int = i - s lsl ( l * bitsize ) let full_size ( l : int ) : int = assert ( 0 <= l ) ; 1 ... |
module Branching2 : BITSIZE = struct let bitsize : int = 1 end |
module Branching32 : BITSIZE = struct let bitsize : int = 5 end |
module Rb = Make ( Branching2 ) |
let fill ( start : int ) ( beyond : int ) : int Rb . t = assert ( start <= beyond ) ; let rec fl start t = if start = beyond then t else fl ( start + 1 ) ( Rb . push start t ) in fl start Rb . empty |
let check_fill ( start : int ) ( beyond : int ) : bool = let rec check start t = if start = beyond then Rb . check_invariant t else Rb . check_invariant t && check ( start + 1 ) ( Rb . push start t ) in check start Rb . empty |
let check_fold ( start : int ) ( beyond : int ) ( t : int Rb . t ) : bool = start + Rb . length t = beyond && Rb . foldi_left ( fun ok idx e -> ok && e = start + idx ) true t |
let check_element ( start : int ) ( beyond : int ) ( t : int Rb . t ) : bool = let rec check_from i start = if start = beyond then true else start = Rb . element i t && check_from ( i + 1 ) ( start + 1 ) in check_from 0 start |
let check_pop ( start : int ) ( beyond : int ) ( t : int Rb . t ) : bool = let rec check beyond t = Rb . check_invariant t && ( if beyond = start then Rb . is_empty t else Rb . has_some t && let e , t = Rb . pop t in e + 1 = beyond && check ( beyond - 1 ) t ) in check beyond t let start = 10 and beyond = 100 in check_f... |
let pitable = [ | 0xd9 ; 0x78 ; 0xf9 ; 0xc4 ; 0x19 ; 0xdd ; 0xb5 ; 0xed ; 0x28 ; 0xe9 ; 0xfd ; 0x79 ; 0x4a ; 0xa0 ; 0xd8 ; 0x9d ; 0xc6 ; 0x7e ; 0x37 ; 0x83 ; 0x2b ; 0x76 ; 0x53 ; 0x8e ; 0x62 ; 0x4c ; 0x64 ; 0x88 ; 0x44 ; 0x8b ; 0xfb ; 0xa2 ; 0x17 ; 0x9a ; 0x59 ; 0xf5 ; 0x87 ; 0xb3 ; 0x4f ; 0x13 ; 0x61 ; 0x45 ; 0x6d ; 0... |
let tm effective = let t8 = ( effective + 7 ) / 8 in let bits = 8 + effective - 8 * t8 in let rec c acc = function | 0 -> acc | n -> c ( ( acc lsl 1 ) + 1 ) ( pred n ) in t8 , c 0 bits |
let key_expansion effective key = let t = Cstruct . length key in let l = Array . init 128 ( fun idx -> if idx < t then Cstruct . get_uint8 key idx else 0 ) in let t8 , tm = tm effective in for i = t to 127 do l . ( i ) <- pitable . ( ( l . ( i - 1 ) + l . ( i - t ) ) mod 256 ) done ; l . ( 128 - t8 ) <- pitable . ( l ... |
let mod16 f = 0xFFFF land f |
let rol16 x k = mod16 ( ( x lsl k ) lor ( x lsr ( 16 - k ) ) ) |
let ror16 x k = mod16 ( ( x lsr k ) lor ( x lsl ( 16 - k ) ) ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.