├── .cargo
└── config.toml
├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── Cargo.toml
├── LICENSE.txt
├── README.md
├── build.sh
├── cargo-box
├── .gitignore
├── Cargo.toml
├── box
│ ├── box.entitlements
│ ├── box.xcodeproj
│ │ ├── project.pbxproj
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── box.xcscheme
│ └── cfg.xcconfig
└── src
│ └── main.rs
├── cidre-macros
├── .gitignore
├── Cargo.toml
└── src
│ └── lib.rs
└── cidre
├── Cargo.toml
├── README.md
├── benches
├── alloc.rs
├── array_indexing.rs
├── blocks.rs
├── cf_date_formatter.rs
├── cf_string.rs
├── dispatch_sync.rs
├── impl_call.rs
├── interleave.rs
├── ns_array_from.rs
└── uuid.rs
├── build.rs
├── examples
├── am-device-list
│ └── main.rs
├── am-device-mount-dev-image
│ └── main.rs
├── at-audio
│ └── main.rs
├── au-capture
│ └── main.rs
├── av-asset-reader
│ └── main.rs
├── av-asset-writer-hls
│ └── main.rs
├── av-asset-writer
│ └── main.rs
├── av-capture-session-mic
│ └── main.rs
├── av-capture
│ └── main.rs
├── av-route-changes
│ └── main.rs
├── ax-observer
│ └── main.rs
├── ax-tree
│ └── main.rs
├── cg-event-tap-kb
│ └── main.rs
├── cg-event-tap-mouse
│ └── main.rs
├── cg-image-props
│ └── main.rs
├── core-audio-record
│ └── main.rs
├── device-formats
│ └── main.rs
├── mlc-gemm
│ └── main.rs
├── mtl-fence
│ └── main.rs
├── mtl-font
│ └── main.rs
├── mtl-triangle
│ └── main.rs
├── ns-workspace-notifications
│ └── main.rs
├── nw-connection
│ └── main.rs
├── nw-path-monitor
│ └── main.rs
├── queue-bench
│ └── main.rs
├── sc-picker
│ └── main.rs
├── sc-record
│ └── main.rs
├── sec-dev-teams
│ └── main.rs
├── sound-analysis
│ └── main.rs
├── speech
│ └── main.rs
├── vn-thumbnail-generator
│ └── main.rs
└── wk-web-view
│ └── main.rs
├── pomace
├── app
│ ├── app.h
│ └── app.m
├── av
│ ├── av.h
│ └── av.m
├── av_kit
│ ├── av_kit.h
│ └── av_kit.m
├── ca
│ ├── ca.h
│ └── ca.m
├── ci
│ ├── ci.h
│ └── ci.m
├── cl
│ ├── cl.h
│ └── cl.m
├── core_audio
│ ├── core_audio.h
│ └── core_audio.m
├── core_motion
│ ├── core_motion.h
│ └── core_motion.m
├── gc
│ ├── gc.h
│ └── gc.m
├── mc
│ ├── mc.h
│ └── mc.m
├── mlc
│ ├── mlc.h
│ └── mlc.m
├── mps
│ ├── mps.h
│ └── mps.m
├── mpsg
│ ├── mpsg.h
│ └── mpsg.m
├── mtk
│ ├── mtk.h
│ └── mtk.m
├── mtl
│ ├── mtl.h
│ └── mtl.m
├── nl
│ ├── nl.h
│ └── nl.m
├── ns
│ ├── ns.h
│ └── ns.m
├── pomace.xcodeproj
│ ├── project.pbxproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── IDEWorkspaceChecks.plist
│ └── xcshareddata
│ │ └── xcschemes
│ │ └── mlc.xcscheme
├── sc
│ ├── sc.h
│ └── sc.m
├── sn
│ ├── sn.h
│ └── sn.m
├── ui
│ ├── ui.h
│ └── ui.m
├── un
│ ├── un.h
│ └── un.m
├── ut
│ ├── ut.h
│ └── ut.m
├── vn
│ ├── vn.h
│ └── vn.m
├── wc
│ ├── wc.h
│ └── wc.m
└── wk
│ ├── wk.h
│ └── wk.m
└── src
├── am.rs
├── am
├── device.rs
├── device
│ ├── base.rs
│ ├── development.rs
│ ├── discovery.rs
│ ├── error.rs
│ ├── installation.rs
│ └── log.rs
└── service_connection.rs
├── api.rs
├── arc.rs
├── at.rs
├── at
├── audio.rs
└── audio
│ ├── codec.rs
│ ├── component.rs
│ ├── converter.rs
│ ├── file.rs
│ ├── format.rs
│ ├── queue.rs
│ ├── unit.rs
│ └── unit
│ ├── component.rs
│ ├── format_converter.rs
│ ├── multi_channel_mixer.rs
│ ├── output.rs
│ ├── parameters.rs
│ └── properties.rs
├── av.rs
├── av
├── animation.rs
├── asset.rs
├── asset
│ ├── cache.rs
│ ├── image_generator.rs
│ ├── reader.rs
│ ├── reader_output.rs
│ ├── segment_report.rs
│ ├── track.rs
│ ├── writer.rs
│ └── writer_input.rs
├── audio.rs
├── audio
│ ├── application.rs
│ ├── buffer.rs
│ ├── channel_layout.rs
│ ├── connection_point.rs
│ ├── converter.rs
│ ├── engine.rs
│ ├── file.rs
│ ├── format.rs
│ ├── io_node.rs
│ ├── mixer_node.rs
│ ├── mixing.rs
│ ├── node.rs
│ ├── player.rs
│ ├── player_node.rs
│ ├── session.rs
│ ├── session
│ │ ├── route.rs
│ │ └── types.rs
│ ├── settings.rs
│ ├── speech_synthesis.rs
│ ├── time.rs
│ ├── types.rs
│ ├── unit.rs
│ └── unit
│ │ ├── effect.rs
│ │ ├── eq.rs
│ │ └── time_effect.rs
├── capture.rs
├── capture
│ ├── audio_data_output.rs
│ ├── control.rs
│ ├── device.rs
│ ├── index_picker.rs
│ ├── input.rs
│ ├── metadata_output.rs
│ ├── output_base.rs
│ ├── photo_output.rs
│ ├── reactions.rs
│ ├── session.rs
│ ├── session_preset.rs
│ ├── slider.rs
│ ├── system_exposure_bias_slider.rs
│ ├── system_pressure.rs
│ ├── system_zoom_slider.rs
│ ├── video_data_output.rs
│ └── video_preview_layer.rs
├── external_storage_device.rs
├── geometry.rs
├── kit.rs
├── kit
│ ├── error.rs
│ ├── picture_in_picture_controller.rs
│ ├── picture_in_picture_controller_sample_buffer_display_layer_support.rs
│ ├── picture_in_picture_controller_video_call_support.rs
│ ├── playback_route_selecting.rs
│ ├── playback_speed.rs
│ ├── player_view_controller.rs
│ └── types.rs
├── media_format.rs
├── metadata_object.rs
├── output_settings_assistant.rs
├── player.rs
├── player
│ └── item.rs
├── player_layer.rs
├── sample_buffer.rs
├── sample_buffer
│ ├── display_layer.rs
│ ├── queued_sample_buffer_rendering.rs
│ └── video_renderer.rs
├── time.rs
├── video.rs
└── video
│ └── settings.rs
├── ax.rs
├── ax
├── action_constants.rs
├── attribute_constants.rs
├── error.rs
├── notification_constants.rs
├── role_constants.rs
├── ui_element.rs
└── value.rs
├── blocks.rs
├── ca.rs
├── ca
├── animation.rs
├── base.rs
├── display_link.rs
├── edr_metadata.rs
├── frame_rate_range.rs
├── layer.rs
├── media_timing_function.rs
├── metal_layer.rs
├── renderer.rs
├── transaction.rs
└── transform3d.rs
├── cat.rs
├── cat
├── audio.rs
└── audio
│ ├── base_types.rs
│ └── session_types.rs
├── cf.rs
├── cf
├── array.rs
├── attributed_string.rs
├── base.rs
├── bundle.rs
├── data.rs
├── date.rs
├── date_formatter.rs
├── dictionary.rs
├── error.rs
├── locale.rs
├── mach_port.rs
├── notification_center.rs
├── number.rs
├── number_formatter.rs
├── property_list.rs
├── run_loop.rs
├── runtime.rs
├── set.rs
├── socket.rs
├── string.rs
├── url.rs
└── uuid.rs
├── cg.rs
├── cg
├── affine_transform.rs
├── color.rs
├── color_space.rs
├── direct_display.rs
├── direct_display_configuration.rs
├── display_stream.rs
├── error.rs
├── event.rs
├── event_source.rs
├── event_types.rs
├── font.rs
├── geometry.rs
├── image.rs
├── image
│ ├── animation.rs
│ ├── destination.rs
│ └── source.rs
├── image_properties.rs
├── path.rs
├── remote_operation.rs
├── window.rs
└── window_level.rs
├── ci.rs
├── ci
├── barcode_descriptor.rs
├── context.rs
├── image.rs
└── vector.rs
├── cl.rs
├── cl
├── beacon_region.rs
├── heading.rs
├── location.rs
├── location_manager.rs
└── region.rs
├── cm.rs
├── cm
├── attachment.rs
├── base.rs
├── block_buffer.rs
├── format_description.rs
├── format_description_bridge.rs
├── io.rs
├── io
│ ├── extension.rs
│ ├── hardware.rs
│ └── hardware
│ │ ├── object.rs
│ │ └── system.rs
├── memory_pool.rs
├── sample_buffer.rs
├── simple_queue.rs
├── sync.rs
├── tag.rs
├── tag_collection.rs
├── tagged_buffer_group.rs
├── time.rs
└── time
│ └── range.rs
├── compression.rs
├── core_audio.rs
├── core_audio
├── hardware.rs
├── hardware_base.rs
├── hardware_tapping.rs
└── tap_description.rs
├── core_motion.rs
├── core_motion
├── absolute_altitude.rs
├── accelerometer.rs
├── altimeter.rs
├── altitude.rs
├── attitude.rs
├── authorization.rs
├── device_motion.rs
├── gyro.rs
├── headphone_motion_manager.rs
├── log_item.rs
├── magnetometer.rs
├── motion_manager.rs
├── pedometer.rs
└── rotation_rate_data.rs
├── ct.rs
├── ct
├── font.rs
├── font_descriptor.rs
├── font_manager.rs
├── font_traits.rs
├── line.rs
├── paragraph_style.rs
├── run.rs
└── string_attributes.rs
├── cv.rs
├── cv
├── _return.rs
├── base.rs
├── buffer.rs
├── display_link.rs
├── host_time.rs
├── image_buffer.rs
├── metal.rs
├── metal
│ ├── texture.rs
│ └── texture_cache.rs
├── pixel_buffer.rs
├── pixel_buffer_pool.rs
└── pixel_format_description.rs
├── da.rs
├── da
├── disk.rs
└── session.rs
├── dispatch.rs
├── dispatch
├── base.rs
├── block.rs
├── data.rs
├── group.rs
├── object.rs
├── queue.rs
├── semaphore.rs
├── source.rs
├── time.rs
└── work_item.rs
├── dns_sd.rs
├── gc.rs
├── gc
├── color.rs
├── controller.rs
├── device.rs
└── device_light.rs
├── io.rs
├── io
├── kit.rs
├── kit
│ ├── audio.rs
│ └── audio
│ │ └── types.rs
└── surface.rs
├── lib.rs
├── mac_types.rs
├── mach.rs
├── mach
├── boolean.rs
├── kern_return.rs
├── machine.rs
├── message.rs
├── policy.rs
├── port.rs
├── task.rs
├── task_info.rs
├── time.rs
├── time_value.rs
├── types.rs
├── vm_map.rs
├── vm_statistics.rs
└── vm_types.rs
├── mc.rs
├── mc
├── advertiser_assistant.rs
├── browser_view_controller.rs
├── error.rs
├── nearby_service_advertiser.rs
├── nearby_service_browser.rs
├── peer_id.rs
└── session.rs
├── mlc.rs
├── mlc
├── activation_descriptor.rs
├── activation_layer.rs
├── adam_optimizer.rs
├── adamw_optimizer.rs
├── arithmetic_layer.rs
├── batch_normalization_layer.rs
├── device.rs
├── graph.rs
├── inference_graph.rs
├── layer.rs
├── matmul.rs
├── optimizer.rs
├── optimizer_descriptor.rs
├── tensor.rs
├── tensor_data.rs
├── tensor_descriptor.rs
├── tensor_parameter.rs
├── training_graph.rs
└── types.rs
├── mps.rs
├── mps
├── core.rs
├── core
│ ├── nd_array.rs
│ └── types.rs
├── graph.rs
└── graph
│ ├── activation_ops.rs
│ ├── arithmetic_ops.rs
│ ├── convolution_ops.rs
│ ├── core.rs
│ ├── device.rs
│ ├── executable.rs
│ ├── gather_ops.rs
│ ├── matrix_multiplication_ops.rs
│ ├── memory_ops.rs
│ ├── normalization_ops.rs
│ ├── operation.rs
│ ├── resize_ops.rs
│ ├── rnn_ops.rs
│ ├── shape_ops.rs
│ ├── tensor.rs
│ └── tensor_data.rs
├── mtk.rs
├── mtk
└── texture_loader.rs
├── mtl.rs
├── mtl
├── acceleration_structure.rs
├── acceleration_structure_types.rs
├── allocation.rs
├── argument.rs
├── argument_encoder.rs
├── blit_command_encoder.rs
├── blit_pass.rs
├── buffer.rs
├── capture_manager.rs
├── capture_scope.rs
├── command_buffer.rs
├── command_encoder.rs
├── command_queue.rs
├── compute_command_encoder.rs
├── compute_pass.rs
├── compute_pipeline.rs
├── counters.rs
├── depth_stencil.rs
├── device.rs
├── drawable.rs
├── event.rs
├── fence.rs
├── function_constant_values.rs
├── function_descriptor.rs
├── function_handle.rs
├── function_stitching.rs
├── heap.rs
├── indirect_command_buffer.rs
├── indirect_command_encoder.rs
├── intersection_function_table.rs
├── library.rs
├── parallel_render_command_encoder.rs
├── pipeline.rs
├── pixel_format.rs
├── render_command_encoder.rs
├── render_pass.rs
├── render_pipeline.rs
├── residency_set.rs
├── resource.rs
├── sampler.rs
├── stage_input_output_descriptor.rs
├── texture.rs
├── types.rs
├── vertex_descriptor.rs
└── visible_function_table.rs
├── nl.rs
├── nl
├── embedding.rs
├── language.rs
└── language_recognizer.rs
├── ns.rs
├── ns
├── app.rs
├── app
│ ├── animation.rs
│ ├── application.rs
│ ├── button.rs
│ ├── button_cell.rs
│ ├── cell.rs
│ ├── color.rs
│ ├── color_space.rs
│ ├── control.rs
│ ├── dock_tile.rs
│ ├── event.rs
│ ├── font.rs
│ ├── font_manager.rs
│ ├── gesture_recognizer.rs
│ ├── graphics.rs
│ ├── image.rs
│ ├── layout_constraint.rs
│ ├── menu.rs
│ ├── paragraph_style.rs
│ ├── responder.rs
│ ├── running_application.rs
│ ├── screen.rs
│ ├── sound.rs
│ ├── split_view.rs
│ ├── split_view_controller.rs
│ ├── split_view_item.rs
│ ├── status_bar.rs
│ ├── text.rs
│ ├── text_field.rs
│ ├── text_field_cell.rs
│ ├── text_view.rs
│ ├── titlebar_accessory_view_controller.rs
│ ├── touch.rs
│ ├── view.rs
│ ├── view_controller.rs
│ ├── window.rs
│ ├── window_controller.rs
│ └── workspace.rs
├── array.rs
├── attributed_string.rs
├── bundle.rs
├── coder.rs
├── data.rs
├── date.rs
├── date_formatter.rs
├── dictionary.rs
├── enumerator.rs
├── error.rs
├── exception.rs
├── file_manager.rs
├── formatter.rs
├── geometry.rs
├── index_set.rs
├── iso_8601_date_formatter.rs
├── key_value_coding.rs
├── key_value_observing.rs
├── keyed_archiver.rs
├── keyed_unarchiver.rs
├── locale.rs
├── notification.rs
├── null.rs
├── objc_runtime.rs
├── operation.rs
├── path_utilities.rs
├── port.rs
├── process_info.rs
├── progress.rs
├── range.rs
├── regular_expression.rs
├── run_loop.rs
├── set.rs
├── stream.rs
├── string.rs
├── text_attachment.rs
├── text_checking_result.rs
├── thread.rs
├── timer.rs
├── url.rs
├── url_cache.rs
├── url_request.rs
├── url_response.rs
├── url_session.rs
├── user_activity.rs
├── user_defaults.rs
├── uuid.rs
├── value.rs
├── xpc.rs
└── xpc
│ └── connection.rs
├── nw.rs
├── nw
├── advertise_descriptor.rs
├── browse_descriptor.rs
├── browse_result.rs
├── browser.rs
├── connection.rs
├── connection_group.rs
├── content_context.rs
├── endpoint.rs
├── error.rs
├── interface.rs
├── listener.rs
├── object.rs
├── parameters.rs
├── path.rs
├── path_monitor.rs
├── privacy_context.rs
├── protocol_options.rs
├── proxy_config.rs
├── resolver_config.rs
└── txt_record.rs
├── objc.rs
├── objc
├── autorelease_pool.rs
└── ns.rs
├── os.rs
├── os
├── lock.rs
└── proc.rs
├── sc.rs
├── sc
├── content_sharing_picker.rs
├── error.rs
├── recording_output.rs
├── screenshot_manager.rs
├── shareable_content.rs
└── stream.rs
├── sec.rs
├── sec
├── base.rs
├── certificate.rs
├── identity.rs
├── item.rs
└── policy.rs
├── simd.rs
├── simd
└── vector_types.rs
├── sn.rs
├── sn
├── analyzer.rs
├── classification_result.rs
├── classify_sound_request.rs
├── error.rs
├── result.rs
├── time_duration_constraint.rs
└── types.rs
├── sys.rs
├── sys
├── _types.rs
└── termios.rs
├── time.rs
├── ui.rs
├── ui
├── application.rs
├── blur_effect.rs
├── color.rs
├── command.rs
├── device.rs
├── event.rs
├── font.rs
├── font_descriptor.rs
├── geometry.rs
├── gesture_recognizer.rs
├── image.rs
├── interaction.rs
├── interface.rs
├── key.rs
├── key_constants.rs
├── layout_guide.rs
├── navigation_bar.rs
├── navigation_controller.rs
├── orientation.rs
├── pan_gesture_recognizer.rs
├── press.rs
├── responder.rs
├── scene.rs
├── scene_definitions.rs
├── scene_options.rs
├── scene_session.rs
├── scene_session_activation_request.rs
├── scene_windowing_behaviors.rs
├── screen.rs
├── screen_mode.rs
├── tab.rs
├── tab_bar.rs
├── tab_bar_controller.rs
├── tab_bar_controller_sidebar.rs
├── tap_gesture_recognizer.rs
├── toolbar.rs
├── touch.rs
├── trait_collection.rs
├── update_action_phase.rs
├── update_info.rs
├── update_link.rs
├── view.rs
├── view_controller.rs
├── view_controller_transition.rs
├── visual_effect.rs
├── window.rs
├── window_scene.rs
├── window_scene_activation_request_options.rs
├── window_scene_placement.rs
├── window_scene_prominent_placement.rs
├── window_scene_standard_placement.rs
└── zoom_transition_options.rs
├── un.rs
├── un
├── error.rs
├── notification.rs
├── notification_action.rs
├── notification_action_icon.rs
├── notification_attachment.rs
├── notification_content.rs
├── notification_request.rs
├── notification_response.rs
├── notification_settings.rs
├── notification_sound.rs
└── user_notification_center.rs
├── ut.rs
├── ut
├── _type.rs
└── core_types.rs
├── vdsp.rs
├── vn.rs
├── vn
├── calculate_image_aesthetics_scores_request.rs
├── classify_image_request.rs
├── detect_barcodes_request.rs
├── detect_document_segmentation_request.rs
├── detect_face_capture_quality_request.rs
├── detect_face_rectangles_request.rs
├── error.rs
├── face_landmarks.rs
├── generate_attention_based_saliency_image_request.rs
├── generate_foreground_instance_mask_request.rs
├── generate_image_feature_print_request.rs
├── generate_objectness_based_saliency_image_request.rs
├── generate_optical_flow_request.rs
├── generate_person_segmentation_request.rs
├── observation.rs
├── recognize_animal_request.rs
├── recognize_text_request.rs
├── request.rs
├── request_handler.rs
├── stateful_request.rs
├── targeted_image_request.rs
├── tracking_request.rs
├── types.rs
└── video_processor.rs
├── vt.rs
├── vt
├── compression.rs
├── compression
│ ├── properties.rs
│ └── session.rs
├── decompression.rs
├── decompression
│ ├── properties.rs
│ └── session.rs
├── errors.rs
├── pixel_rotation.rs
├── pixel_rotation
│ ├── properties.rs
│ └── session.rs
├── pixel_transfer.rs
├── pixel_transfer
│ ├── properties.rs
│ └── session.rs
├── professional_video_workflow.rs
├── session.rs
├── utilities.rs
└── video_encoder_list.rs
├── wc.rs
├── wc
├── error.rs
└── session.rs
├── wk.rs
└── wk
├── navigation.rs
├── navigation_delegate.rs
├── preferences.rs
├── process_pool.rs
├── user_content_controller.rs
├── user_script.rs
├── web_view.rs
├── web_view_configuration.rs
└── website_data_store.rs
/.cargo/config.toml:
--------------------------------------------------------------------------------
1 | [build]
2 | # target = "arm64_32-apple-watchos"
3 | # target = "aarch64-apple-ios"
4 |
5 | [target.aarch64-apple-ios]
6 | runner = "cargo-box runner"
7 |
8 | [target.arm64_32-apple-watchos]
9 | runner = "cargo-box runner"
10 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Rust
2 |
3 | on:
4 | push:
5 | branches: [ "main" ]
6 | pull_request:
7 | branches: [ "main" ]
8 |
9 | env:
10 | CARGO_TERM_COLOR: always
11 |
12 | jobs:
13 | build:
14 | strategy:
15 | matrix:
16 | os: [macos-15]
17 |
18 | runs-on: ${{ matrix.os }}
19 |
20 | steps:
21 | - uses: actions/checkout@v3
22 | - uses: dtolnay/rust-toolchain@stable
23 | - name: ls apps
24 | run: ls -la /Applications
25 | - name: os ver
26 | run: sw_vers
27 | - name: switch xcode
28 | run: sudo xcode-select -s '/Applications/Xcode_16.app'
29 | - name: list sdks
30 | run: xcodebuild -showsdks
31 | - name: macosx sdk version
32 | run: xcodebuild -version -sdk macosx
33 |
34 | - name: add targets
35 | run: >
36 | rustup target add aarch64-apple-ios &&
37 | rustup target add aarch64-apple-ios-sim &&
38 | rustup target add x86_64-apple-darwin &&
39 | rustup +nightly target add aarch64-apple-darwin &&
40 | rustup +nightly target add aarch64-apple-ios &&
41 | rustup component add rust-src --toolchain nightly-aarch64-apple-darwin
42 |
43 | - name: Build
44 | run: ./build.sh
45 |
46 | - name: Test ns
47 | run: 'cargo t --features="macos_14_0" ns::'
48 |
49 | - name: Test cf
50 | run: 'cargo t --features="macos_14_0" cf::'
51 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | xcuserdata
2 |
3 | /target
4 | .DS_Store
5 | .box
6 | Cargo.lock
7 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [workspace]
2 | resolver = "2"
3 |
4 | members = [
5 | "cidre",
6 | "cidre-macros",
7 | ]
8 |
9 | exclude = [
10 | "cargo-box"
11 | ]
12 |
13 | # [profile.dev]
14 | # opt-level = 1
15 |
16 | # [profile.dev.package."*"]
17 | # opt-level = 3
18 |
19 | [profile.release]
20 | lto = true
21 | # strip = "debuginfo"
22 | panic = "abort"
23 |
24 |
25 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Yury Korolev
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | cargo b --target aarch64-apple-ios
5 | cargo b --target aarch64-apple-ios-sim
6 | cargo +nightly b -Zbuild-std --target aarch64-apple-tvos
7 | cargo +nightly b -Zbuild-std --target aarch64-apple-tvos-sim
8 | # cargo +nightly b -Zbuild-std --target arm64_32-apple-watchos
9 | cargo b --target aarch64-apple-darwin
10 | cargo b --target x86_64-apple-darwin
11 | # cargo +nightly b -Zbuild-std --target aarch64-apple-visionos
12 | # cargo +nightly b -Zbuild-std --target aarch64-apple-visionos-sim
13 | cargo install --path ./cargo-box
14 |
15 | cargo b --no-default-features --features="macos_12_0,vt,cm,mtl,dispatch"
16 |
--------------------------------------------------------------------------------
/cargo-box/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 |
--------------------------------------------------------------------------------
/cargo-box/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "cargo-box"
3 | version = "0.1.0"
4 | edition = "2024"
5 |
6 | rust-version = "1.85"
7 |
8 | description = "iOS/macOS runner"
9 | license = "MIT"
10 |
11 | [dependencies]
12 | clap = { version = "4.5", features = ["derive"] }
13 | serde = { version = "1.0", features = ["derive"] }
14 | serde_json = "1.0"
15 | cargo_toml = "0.22"
16 | dotenv = "0.15"
17 |
18 | cidre = { path = "../cidre", default-features = false, features = ["ns", "cg", "cf", "sec"] }
19 |
--------------------------------------------------------------------------------
/cargo-box/box/box.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.files.user-selected.read-only
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/cidre-macros/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 |
--------------------------------------------------------------------------------
/cidre-macros/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "cidre-macros"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 |
8 | [lib]
9 | proc-macro = true
10 |
--------------------------------------------------------------------------------
/cidre/README.md:
--------------------------------------------------------------------------------
1 | # Cidre
2 |
3 | Apple frameworks bindings for rust
4 |
5 |
--------------------------------------------------------------------------------
/cidre/benches/array_indexing.rs:
--------------------------------------------------------------------------------
1 | use cidre::{cf, ns};
2 | use criterion::{Criterion, criterion_group, criterion_main};
3 |
4 | pub fn criterion_benchmark(c: &mut Criterion) {
5 | let cf_str = cf::str!(c"cf_string");
6 | let ns_str = ns::str!(c"ns_string");
7 | let cf_array = cf::ArrayOf::from_slice(&[cf_str]);
8 | let ns_array = ns::Array::from_slice(&[ns_str]);
9 | c.bench_function("indexing_ns_array", |b| {
10 | b.iter(|| {
11 | let _v = ns_array.get(0).unwrap();
12 | })
13 | });
14 | c.bench_function("indexing_ns_array_throws", |b| {
15 | b.iter(|| {
16 | let _v = unsafe { ns_array.get_throws(0) };
17 | })
18 | });
19 |
20 | c.bench_function("indexing_cf_array", |b| {
21 | b.iter(|| {
22 | let _v = &cf_array[0];
23 | })
24 | });
25 |
26 | c.bench_function("indexing_ns_array_with_cf_api", |b| {
27 | b.iter(|| {
28 | let _v = &ns_array.as_cf()[0];
29 | })
30 | });
31 | }
32 |
33 | criterion_group!(benches, criterion_benchmark);
34 | criterion_main!(benches);
35 |
--------------------------------------------------------------------------------
/cidre/benches/cf_string.rs:
--------------------------------------------------------------------------------
1 | use cidre::cf;
2 | use criterion::{black_box, criterion_group, criterion_main, Criterion};
3 |
4 | pub fn criterion_benchmark(c: &mut Criterion) {
5 | c.bench_function("cf::String::from_str tagged", |b| {
6 | b.iter(|| assert!(cf::String::from_str(black_box("hello")).is_tagged_ptr()))
7 | });
8 |
9 | c.bench_function("cf::String::from_str_no_copy tagged", |b| {
10 | b.iter(|| {
11 | assert!(unsafe { cf::String::from_str_no_copy(black_box("hello")) }.is_tagged_ptr())
12 | })
13 | });
14 |
15 | let string = "very long string that can't be tagged cf::String".to_string();
16 |
17 | c.bench_function("cf::String::from_str", |b| {
18 | b.iter(|| assert!(!cf::String::from_str(black_box(&string)).is_tagged_ptr()))
19 | });
20 |
21 | c.bench_function("cf::String::from_str_no_copy", |b| {
22 | b.iter(|| {
23 | assert!(!unsafe { cf::String::from_str_no_copy(black_box(&string)) }.is_tagged_ptr())
24 | })
25 | });
26 |
27 | c.bench_function("cf::String cf::str!", |b| {
28 | b.iter(|| {
29 | assert!(!cf::str!(c"very long string that can't be tagged cf::String").is_tagged_ptr())
30 | })
31 | });
32 | }
33 |
34 | criterion_group!(benches, criterion_benchmark);
35 | criterion_main!(benches);
36 |
--------------------------------------------------------------------------------
/cidre/benches/dispatch_sync.rs:
--------------------------------------------------------------------------------
1 | use std::ffi::c_void;
2 |
3 | use cidre::dispatch;
4 | use criterion::{criterion_group, criterion_main, Criterion};
5 |
6 | extern "C-unwind" fn work(_ctx: *mut u8) {}
7 |
8 | pub fn criterion_benchmark(c: &mut Criterion) {
9 | let queue = dispatch::Queue::serial_with_ar_pool();
10 |
11 | c.bench_function("dispatch::queue.barrier_sync_f", |b| {
12 | b.iter(|| queue.barrier_sync_f(std::ptr::null_mut(), work))
13 | });
14 |
15 | c.bench_function("dispatch::queue.sync_f", |b| {
16 | b.iter(|| queue.sync_f(std::ptr::null_mut(), work))
17 | });
18 |
19 | c.bench_function("dispatch::queue.sync_fn", |b| {
20 | extern "C" fn foo(_ctx: *const c_void) {}
21 | b.iter(|| queue.sync_fn(foo));
22 | });
23 |
24 | c.bench_function("dispatch::queue.barrier_async_and_wait_f", |b| {
25 | b.iter(|| queue.barrier_async_and_wait_f(std::ptr::null_mut(), work))
26 | });
27 | }
28 |
29 | criterion_group!(benches, criterion_benchmark);
30 | criterion_main!(benches);
31 |
--------------------------------------------------------------------------------
/cidre/benches/impl_call.rs:
--------------------------------------------------------------------------------
1 | use cidre::{ns, objc, objc::Obj};
2 | use criterion::{Criterion, criterion_group, criterion_main};
3 |
4 | pub fn criterion_benchmark(c: &mut Criterion) {
5 | let _str = ns::String::new();
6 | let str = ns::str!(c"hello");
7 |
8 | c.bench_function("impl_call:msg_send", |b| {
9 | b.iter(|| {
10 | let len = str.len();
11 | assert_eq!(len, 5);
12 | })
13 | });
14 |
15 | let impl_fn = unsafe {
16 | str.class()
17 | .method_impl(objc::sel_reg_name(c"length".as_ptr()))
18 | };
19 | assert!(!impl_fn.is_null());
20 |
21 | let impl_fn: extern "C-unwind" fn(ptr: *const ns::String) -> usize =
22 | unsafe { std::mem::transmute(impl_fn) };
23 |
24 | c.bench_function("impl_call:direct", |b| {
25 | b.iter(|| {
26 | let len = impl_fn(str);
27 | assert_eq!(len, 5);
28 | })
29 | });
30 |
31 | let cf_str = str.as_cf();
32 |
33 | c.bench_function("impl_call:cf_call", |b| {
34 | b.iter(|| {
35 | let len = cf_str.len();
36 | assert_eq!(len, 5);
37 | })
38 | });
39 | }
40 |
41 | criterion_group!(benches, criterion_benchmark);
42 | criterion_main!(benches);
43 |
--------------------------------------------------------------------------------
/cidre/benches/uuid.rs:
--------------------------------------------------------------------------------
1 | use cidre::{cf, ns};
2 | use criterion::{criterion_group, criterion_main, Criterion};
3 |
4 | pub fn criterion_benchmark(c: &mut Criterion) {
5 | c.bench_function("cf::uuid", |b| {
6 | b.iter(|| {
7 | cf::Uuid::new();
8 | })
9 | });
10 |
11 | c.bench_function("ns::uuid", |b| {
12 | b.iter(|| {
13 | ns::Uuid::new();
14 | })
15 | });
16 |
17 | c.bench_function("rust::uuid_v4", |b| {
18 | b.iter(|| {
19 | uuid::Uuid::new_v4();
20 | })
21 | });
22 |
23 | c.bench_function("rust::uuid_v7", |b| {
24 | b.iter(|| {
25 | uuid::Uuid::now_v7();
26 | })
27 | });
28 |
29 | c.bench_function("cf::uuid::to_cf_string", |b| {
30 | b.iter(|| {
31 | cf::Uuid::new().to_cf_string();
32 | })
33 | });
34 |
35 | c.bench_function("ns::uuid::string", |b| {
36 | b.iter(|| {
37 | ns::Uuid::new().string();
38 | })
39 | });
40 |
41 | c.bench_function("rust::uuid::to_string", |b| {
42 | b.iter(|| {
43 | uuid::Uuid::new_v4().to_string();
44 | })
45 | });
46 | }
47 |
48 | criterion_group!(benches, criterion_benchmark);
49 | criterion_main!(benches);
50 |
--------------------------------------------------------------------------------
/cidre/examples/am-device-list/main.rs:
--------------------------------------------------------------------------------
1 | #[cfg(target_os = "macos")]
2 | mod macos {
3 | use cidre::am;
4 |
5 | pub fn main() {
6 | let devices = am::Device::list().unwrap();
7 |
8 | for d in devices.iter() {
9 | let f = d.connected().expect("Failed to connect to device");
10 | println!(
11 | "uuid: {:?}, if: {:?} {:?}",
12 | f.id().to_string(),
13 | f.iface_type(),
14 | f.name().to_string()
15 | );
16 |
17 | let s = f.start_session().expect("started session");
18 | s.show();
19 | }
20 | }
21 | }
22 |
23 | #[cfg(target_os = "macos")]
24 | pub use macos::main;
25 |
26 | #[cfg(not(target_os = "macos"))]
27 | fn main() {
28 | todo!()
29 | }
30 |
--------------------------------------------------------------------------------
/cidre/examples/cg-event-tap-mouse/main.rs:
--------------------------------------------------------------------------------
1 | use cidre::{cf, cg};
2 |
3 | extern "C" fn tap_cb(
4 | _proxy: *mut cg::EventTapProxy,
5 | event_type: cg::EventType,
6 | event: &mut cg::Event,
7 | _ctx: *mut (),
8 | ) -> Option<&cg::Event> {
9 | println!("{:?} {:?}", event_type, event.location());
10 | Some(event)
11 | }
12 |
13 | fn main() {
14 | if !cg::event::access::listen_preflight() {
15 | if !cg::event::access::listen_request() {
16 | eprintln!("no access for event listen");
17 | return;
18 | }
19 | }
20 |
21 | let tap = cg::EventTap::new(
22 | cg::EventTapLocation::Hid,
23 | cg::EventTapPlacement::HeadInsert,
24 | cg::EventTapOpts::LISTEN_ONLY,
25 | cg::EventType::MOUSE_EVENTS_MASK,
26 | tap_cb,
27 | std::ptr::null_mut(),
28 | )
29 | .unwrap();
30 |
31 | let rl_src = tap.run_loop_src(0).unwrap();
32 | cf::RunLoop::main().add_src(&rl_src, Default::default());
33 | cf::RunLoop::run();
34 | }
35 |
--------------------------------------------------------------------------------
/cidre/examples/cg-image-props/main.rs:
--------------------------------------------------------------------------------
1 | use std::path::PathBuf;
2 |
3 | use cidre::{cf, cg};
4 | use clap::Parser;
5 |
6 | #[derive(Parser, Debug)]
7 | #[command(version, about, long_about = None)]
8 | struct Args {
9 | /// Image file path to analyse
10 | path: PathBuf,
11 | }
12 |
13 | fn main() {
14 | let args = Args::parse();
15 | let url = cf::Url::with_path(&args.path, false).unwrap();
16 | let src = cg::ImageSrc::with_url(&url, None).unwrap();
17 | let count = src.count();
18 | println!("images count: {count}");
19 | let props = src.props(None).unwrap();
20 | props.show();
21 |
22 | for i in 0..count {
23 | let img = src.image_at(i, None).unwrap();
24 | img.show();
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/cidre/examples/mtl-fence/main.rs:
--------------------------------------------------------------------------------
1 | use cidre::{mtl, objc::ar_pool};
2 |
3 | fn main() {
4 | ar_pool(|| {
5 | let device = mtl::Device::sys_default().unwrap();
6 |
7 | let cmd_queue = device.new_cmd_queue().unwrap();
8 | let mut cmd_buf = cmd_queue.new_cmd_buf().unwrap();
9 |
10 | let cmd_queue = cmd_buf.cmd_queue();
11 | let dev = cmd_queue.device();
12 |
13 | assert!(dev.as_type_ref().equal(device.as_type_ref()));
14 | assert!(cmd_queue.as_type_ref().equal(cmd_queue.as_type_ref()));
15 |
16 | let fence = device.new_fence().unwrap();
17 |
18 | cmd_buf.blit(|enc| enc.update_fence(&fence));
19 | cmd_buf.compute(|enc| enc.wait_for_fence(&fence));
20 |
21 | cmd_buf.commit();
22 | cmd_buf.wait_until_completed();
23 | });
24 | }
25 |
--------------------------------------------------------------------------------
/cidre/examples/ns-workspace-notifications/main.rs:
--------------------------------------------------------------------------------
1 | /// # Workspace Notifications Example
2 | ///
3 | /// This example demonstrates how to observe macOS workspace notifications using the cidre library.
4 | /// It registers observers for various application events (hiding, launching, activating, and deactivating)
5 | /// and prints information about these events when they occur.
6 | ///
7 | use cidre::{blocks, ns, ns::workspace::notification as wsn, objc::Obj};
8 |
9 | fn main() {
10 | let block = |n: &ns::Notification| {
11 | // let workspace = n.id().try_cast(ns::Workspace::cls()).unwrap();
12 | println!("{:?}", n.name());
13 | let user_info = n.user_info().unwrap();
14 |
15 | if let Some(app) = user_info.get(wsn::app_key()) {
16 | if let Some(app) = app.try_cast(ns::RunningApp::cls()) {
17 | println!("{app:?}");
18 | }
19 | }
20 | };
21 |
22 | // One block for all notifications
23 | let mut block = blocks::SyncBlock::new1(block);
24 |
25 | let notifications = [
26 | wsn::did_hide_app(),
27 | wsn::did_launch_app(),
28 | wsn::did_activate_app(),
29 | wsn::did_deactivate_app(),
30 | ];
31 | let mut observers = Vec::with_capacity(notifications.len());
32 |
33 | let mut nc = ns::Workspace::shared().notification_center();
34 |
35 | for name in notifications {
36 | observers.push(nc.add_observer_block(name, None, None, &mut block));
37 | }
38 |
39 | ns::App::shared().run();
40 | }
41 |
--------------------------------------------------------------------------------
/cidre/examples/nw-path-monitor/main.rs:
--------------------------------------------------------------------------------
1 | use cidre::{dispatch, nw};
2 |
3 | fn main() {
4 | println!("try turn on/off wifi or other interfaces");
5 | let mut monitor = nw::PathMonitor::new();
6 | monitor.set_update_handler(|path| {
7 | println!("{path:?}");
8 | });
9 | monitor.start();
10 | dispatch::main();
11 | }
12 |
--------------------------------------------------------------------------------
/cidre/examples/queue-bench/main.rs:
--------------------------------------------------------------------------------
1 | use std::{
2 | ffi::c_void,
3 | sync::{Arc, Mutex},
4 | };
5 |
6 | use cidre::{blocks, dispatch};
7 |
8 | extern "C" fn block_fn(_ctx: *const c_void) {}
9 |
10 | fn main() {
11 | let q = dispatch::Queue::global(0).unwrap();
12 | let c = Arc::new(Mutex::new(0));
13 |
14 | let cc = c.clone();
15 |
16 | let mut block = dispatch::Block::::new0(move || {
17 | let mut v = cc.lock().unwrap();
18 | *v += 1;
19 | });
20 |
21 | for _ in 0..1_000_000_000 {
22 | q.async_b(&mut block);
23 | q.async_fn(block_fn);
24 | q.sync_b(&mut block.as_noesc_mut());
25 | }
26 |
27 | println!("{:?}", c)
28 | }
29 |
--------------------------------------------------------------------------------
/cidre/examples/sc-picker/main.rs:
--------------------------------------------------------------------------------
1 | use cidre::{define_obj_type, ns, objc, sc};
2 |
3 | #[repr(C)]
4 | struct ObserverInner {}
5 |
6 | define_obj_type!(
7 | Observer + sc::ContentSharingPickerObserverImpl,
8 | ObserverInner,
9 | PICKER_OBSERVER
10 | );
11 |
12 | impl sc::ContentSharingPickerObserver for Observer {}
13 |
14 | #[objc::add_methods]
15 | impl sc::ContentSharingPickerObserverImpl for Observer {
16 | extern "C" fn impl_picker_did_cancel_for_stream(
17 | &mut self,
18 | _cmd: Option<&objc::Sel>,
19 | _picker: &mut sc::ContentSharingPicker,
20 | _stream: Option<&sc::Stream>,
21 | ) {
22 | println!("Cancel")
23 | }
24 |
25 | extern "C" fn impl_picker_did_update_with_filter_for_stream(
26 | &mut self,
27 | _cmd: Option<&objc::Sel>,
28 | _picker: &mut sc::ContentSharingPicker,
29 | filter: &sc::ContentFilter,
30 | _stream: Option<&sc::Stream>,
31 | ) {
32 | println!("Picker did update with filter: {:?}", filter);
33 | }
34 |
35 | extern "C" fn impl_picker_start_did_fail_with_err(
36 | &mut self,
37 | _cmd: Option<&objc::Sel>,
38 | err: &ns::Error,
39 | ) {
40 | println!("Error {:?}", err);
41 | }
42 | }
43 |
44 | fn main() {
45 | let observer = Observer::with(ObserverInner {});
46 | let mut picker = sc::ContentSharingPicker::shared();
47 | picker.add_observer(observer.as_ref());
48 | picker.set_active(true);
49 | picker.present();
50 | ns::App::shared().run();
51 | }
52 |
--------------------------------------------------------------------------------
/cidre/pomace/app/app.m:
--------------------------------------------------------------------------------
1 | //
2 | // app.m
3 | // app
4 | //
5 | // Created by Yury Korolev on 11/1/23.
6 | //
7 |
8 | #import "app.h"
9 |
10 |
--------------------------------------------------------------------------------
/cidre/pomace/av/av.m:
--------------------------------------------------------------------------------
1 | //
2 | // av.m
3 | // av
4 | //
5 | // Created by Yury Korolev on 02.05.2022.
6 | //
7 |
8 | #import "av.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/av_kit/av_kit.h:
--------------------------------------------------------------------------------
1 | //
2 | // av_kit.h
3 | // av_kit
4 | //
5 | // Created by Yury Korolev on 1/19/24.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class AV_PICTURE_IN_PICTURE_CONTROLLER;
13 | Class AV_PICTURE_IN_PICTURE_CONTROLLER_CONTENT_SOURCE;
14 | Class AV_PICTURE_IN_PICTURE_VIDEO_CALL_VIEW_CONTROLLER;
15 | Class AV_PLAYBACK_SPEED;
16 | Class AV_PLAYER_VIEW_CONTROLLER;
17 |
18 | __attribute__((constructor))
19 | static void av_kit_initializer(void)
20 | {
21 | static int initialized = 0;
22 | if (!initialized) {
23 | initialized = 1;
24 |
25 | AV_PICTURE_IN_PICTURE_CONTROLLER = [AVPictureInPictureController class];
26 | AV_PICTURE_IN_PICTURE_CONTROLLER_CONTENT_SOURCE = [AVPictureInPictureControllerContentSource class];
27 | AV_PICTURE_IN_PICTURE_VIDEO_CALL_VIEW_CONTROLLER = NSClassFromString(@"AVPictureInPictureVideoCallViewController");
28 | AV_PLAYBACK_SPEED = NSClassFromString(@"AVPlaybackSpeed");
29 | AV_PLAYER_VIEW_CONTROLLER = NSClassFromString(@"AVPlayerViewController");
30 | }
31 | }
32 |
33 | NS_ASSUME_NONNULL_END
34 |
--------------------------------------------------------------------------------
/cidre/pomace/av_kit/av_kit.m:
--------------------------------------------------------------------------------
1 | //
2 | // av_kit.m
3 | // av_kit
4 | //
5 | // Created by Yury Korolev on 9/10/24.
6 | //
7 |
8 | #import "av_kit.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/ca/ca.h:
--------------------------------------------------------------------------------
1 | //
2 | // ca.h
3 | // ca
4 | //
5 | // Created by Yury Korolev on 22.05.2022.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class CA_DISPLAY_LINK;
13 | Class CA_ANIMATION;
14 | Class CA_MEDIA_TIMING_FUNCTION;
15 | Class CA_LAYER;
16 | Class CA_METAL_LAYER;
17 | Class CA_RENDERER;
18 | Class CA_TRANSACTION;
19 | Class CA_EDR_METADATA;
20 |
21 | __attribute__((constructor))
22 | static void ca_initializer(void)
23 | {
24 | static int initialized = 0;
25 | if (!initialized) {
26 | initialized = 1;
27 |
28 | CA_ANIMATION = [CAAnimation class];
29 | CA_MEDIA_TIMING_FUNCTION = [CAMediaTimingFunction class];
30 | CA_DISPLAY_LINK = NSClassFromString(@"CADisplayLink");
31 | CA_LAYER = [CALayer class];
32 | CA_METAL_LAYER = [CAMetalLayer class];
33 | CA_RENDERER = [CARenderer class];
34 | CA_TRANSACTION = [CATransaction class];
35 | CA_EDR_METADATA = NSClassFromString(@"CAEDRMetadata");
36 | }
37 | }
38 |
39 |
40 | NS_ASSUME_NONNULL_END
41 |
42 |
--------------------------------------------------------------------------------
/cidre/pomace/ca/ca.m:
--------------------------------------------------------------------------------
1 | //
2 | // ca.m
3 | // ca
4 | //
5 | // Created by Yury Korolev on 22.05.2022.
6 | //
7 |
8 | #import "ca.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/ci/ci.h:
--------------------------------------------------------------------------------
1 | //
2 | // ci.h
3 | // ci
4 | //
5 | // Created by Yury Korolev on 22.05.2022.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class CI_IMAGE;
13 | Class CI_VECTOR;
14 | Class CI_CONTEXT;
15 |
16 | __attribute__((constructor))
17 | static void ci_initializer(void)
18 | {
19 | static int initialized = 0;
20 | if (!initialized) {
21 | initialized = 1;
22 |
23 | CI_IMAGE = [CIImage class];
24 | CI_VECTOR = [CIVector class];
25 | CI_CONTEXT = [CIContext class];
26 | }
27 | }
28 |
29 | NS_ASSUME_NONNULL_END
30 |
31 |
--------------------------------------------------------------------------------
/cidre/pomace/ci/ci.m:
--------------------------------------------------------------------------------
1 | //
2 | // ci.m
3 | // ci
4 | //
5 | // Created by Yury Korolev on 22.05.2022.
6 | //
7 |
8 | #import "ci.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/cl/cl.h:
--------------------------------------------------------------------------------
1 | //
2 | // cl.h
3 | // cl
4 | //
5 | // Created by Yury Korolev on 1/21/24.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class CL_LOCATION;
13 | Class CL_LOCATION_MANAGER;
14 |
15 | __attribute__((constructor))
16 | static void cl_initializer(void)
17 | {
18 | static int initialized = 0;
19 | if (!initialized) {
20 | initialized = 1;
21 |
22 | CL_LOCATION = [CLLocation class];
23 | CL_LOCATION_MANAGER = [CLLocationManager class];
24 | }
25 | }
26 |
27 | NS_ASSUME_NONNULL_END
28 |
--------------------------------------------------------------------------------
/cidre/pomace/cl/cl.m:
--------------------------------------------------------------------------------
1 | //
2 | // cl.m
3 | // cl
4 | //
5 | // Created by Yury Korolev on 1/21/24.
6 | //
7 |
8 | #import "cl.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/core_audio/core_audio.h:
--------------------------------------------------------------------------------
1 | //
2 | // core_audio.h
3 | // core_audio
4 | //
5 | // Created by Yury Korolev on 11/23/24.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class CA_TAP_DESCRIPTION;
13 |
14 | __attribute__((constructor))
15 | static void core_audio_initializer(void)
16 | {
17 | static int initialized = 0;
18 | if (!initialized) {
19 | initialized = 1;
20 |
21 | #if TARGET_OS_OSX
22 | CA_TAP_DESCRIPTION = NSClassFromString(@"CATapDescription");
23 | #endif
24 |
25 | }
26 | }
27 |
28 | NS_ASSUME_NONNULL_END
29 |
--------------------------------------------------------------------------------
/cidre/pomace/core_audio/core_audio.m:
--------------------------------------------------------------------------------
1 | //
2 | // core_audio.m
3 | // core_audio
4 | //
5 | // Created by Yury Korolev on 11/23/24.
6 | //
7 |
8 | #import "core_audio.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/core_motion/core_motion.h:
--------------------------------------------------------------------------------
1 | //
2 | // core_motion.h
3 | // core_motion
4 | //
5 | // Created by Yury Korolev on 1/19/24.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class CM_MOTION_MANAGER;
13 | Class CM_ALTIMETER;
14 | Class CM_PEDOMETER;
15 | Class CM_HEADPHONE_MOTION_MANAGER;
16 |
17 | __attribute__((constructor))
18 | static void core_motion_initializer(void)
19 | {
20 | static int initialized = 0;
21 | if (!initialized) {
22 | initialized = 1;
23 | #if TARGET_OS_IOS || TARGET_OS_WATCHOS
24 | CM_MOTION_MANAGER = [CMMotionManager class];
25 | #endif
26 | #if TARGET_OS_OSX || TARGET_OS_IOS
27 | CM_HEADPHONE_MOTION_MANAGER = [CMHeadphoneMotionManager class];
28 | #endif
29 |
30 | #if TARGET_OS_OSX
31 | CM_ALTIMETER = nil;
32 | #elif TARGET_OS_VISION
33 | CM_ALTIMETER = nil;
34 | #else
35 | CM_ALTIMETER = [CMAltimeter class];
36 | #endif
37 |
38 | #if TARGET_OS_VISION
39 | CM_PEDOMETER = nil;
40 | #else
41 | CM_PEDOMETER = [CMPedometer class];
42 | #endif
43 | }
44 | }
45 |
46 | NS_ASSUME_NONNULL_END
47 |
--------------------------------------------------------------------------------
/cidre/pomace/core_motion/core_motion.m:
--------------------------------------------------------------------------------
1 | //
2 | // core_motion.m
3 | // core_motion
4 | //
5 | // Created by Yury Korolev on 1/19/24.
6 | //
7 |
8 | #import "core_motion.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/gc/gc.h:
--------------------------------------------------------------------------------
1 | //
2 | // gc.h
3 | // gc
4 | //
5 | // Created by Yury Korolev on 1/9/24.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class GC_COLOR;
13 | Class GC_CONTROLLER;
14 |
15 | __attribute__((constructor))
16 | static void gc_initializer(void)
17 | {
18 | static int initialized = 0;
19 | if (!initialized) {
20 | initialized = 1;
21 |
22 | GC_COLOR = [GCColor class];
23 | GC_CONTROLLER = [GCController class];
24 | }
25 | }
26 |
27 |
28 | NS_ASSUME_NONNULL_END
29 |
--------------------------------------------------------------------------------
/cidre/pomace/gc/gc.m:
--------------------------------------------------------------------------------
1 | //
2 | // gc.m
3 | // gc
4 | //
5 | // Created by Yury Korolev on 1/9/24.
6 | //
7 |
8 | #import "gc.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/mc/mc.h:
--------------------------------------------------------------------------------
1 | //
2 | // mc.h
3 | // mc
4 | //
5 | // Created by Yury Korolev on 1/18/24.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class MC_PEER_ID;
13 | Class MC_NEARBY_SERVICE_ADVERTISER;
14 | Class MC_NEARBY_SERVICE_BROWSER;
15 | Class MC_SESSION;
16 | Class MC_ADVERTISER_ASSISTANT;
17 | Class MC_BROWSER_VIEW_CONTROLLER;
18 |
19 | __attribute__((constructor))
20 | static void mc_initializer(void)
21 | {
22 | static int initialized = 0;
23 | if (!initialized) {
24 | initialized = 1;
25 |
26 | MC_PEER_ID = [MCPeerID class];
27 | MC_NEARBY_SERVICE_ADVERTISER = [MCNearbyServiceAdvertiser class];
28 | MC_NEARBY_SERVICE_BROWSER = [MCNearbyServiceBrowser class];
29 | MC_SESSION = [MCSession class];
30 | MC_ADVERTISER_ASSISTANT = [MCAdvertiserAssistant class];
31 | MC_BROWSER_VIEW_CONTROLLER = [MCBrowserViewController class];
32 | }
33 | }
34 |
35 | NS_ASSUME_NONNULL_END
36 |
--------------------------------------------------------------------------------
/cidre/pomace/mc/mc.m:
--------------------------------------------------------------------------------
1 | //
2 | // mc.m
3 | // mc
4 | //
5 | // Created by Yury Korolev on 1/18/24.
6 | //
7 |
8 | #import "mc.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/mlc/mlc.m:
--------------------------------------------------------------------------------
1 | //
2 | // mlc.m
3 | // mlc
4 | //
5 | // Created by Yury Korolev on 5/9/23.
6 | //
7 |
8 | #import "mlc.h"
9 |
10 |
--------------------------------------------------------------------------------
/cidre/pomace/mps/mps.h:
--------------------------------------------------------------------------------
1 | //
2 | // mps.h
3 | // mps
4 | //
5 | // Created by Yury Korolev on 27.12.2022.
6 | //
7 |
8 | #import
9 | #if TARGET_OS_SIMULATOR
10 | #else
11 | #import
12 | #endif
13 |
14 | NS_ASSUME_NONNULL_BEGIN
15 |
16 | Class MPS_NDARRAY_DESCRIPTOR;
17 | Class MPS_NDARRAY;
18 |
19 | __attribute__((constructor))
20 | static void mps_initializer(void)
21 | {
22 | static int initialized = 0;
23 | if (!initialized) {
24 | initialized = 1;
25 |
26 | #if TARGET_OS_SIMULATOR
27 | #else
28 | MPS_NDARRAY_DESCRIPTOR = [MPSNDArrayDescriptor class];
29 | MPS_NDARRAY = [MPSNDArray class];
30 | #endif
31 |
32 |
33 | }
34 | }
35 |
36 |
37 | NS_ASSUME_NONNULL_END
38 |
--------------------------------------------------------------------------------
/cidre/pomace/mps/mps.m:
--------------------------------------------------------------------------------
1 | //
2 | // mps.m
3 | // mps
4 | //
5 | // Created by Yury Korolev on 27.12.2022.
6 | //
7 |
8 | #import "mps.h"
9 |
10 |
11 |
--------------------------------------------------------------------------------
/cidre/pomace/mpsg/mpsg.h:
--------------------------------------------------------------------------------
1 | //
2 | // mpsg.h
3 | // mpsg
4 | //
5 | // Created by Yury Korolev on 27.12.2022.
6 | //
7 |
8 | #import
9 |
10 | #if TARGET_OS_SIMULATOR
11 | #else
12 | #import
13 | #endif
14 |
15 | NS_ASSUME_NONNULL_BEGIN
16 |
17 | Class MPS_GRAPH_DEVICE;
18 | Class MPS_GRAPH;
19 | Class MPS_GRAPH_CONVOLUTION_2D_OP_DESCRIPTOR;
20 | Class MPS_GRAPH_SINGLE_GATE_RNN_DESCRIPTOR;
21 | Class MPS_GRAPH_LSTM_DESCRIPTOR;
22 | Class MPS_GRAPH_GRU_DESCRIPTOR;
23 |
24 | __attribute__((constructor))
25 | static void mpsg_initializer(void)
26 | {
27 | static int initialized = 0;
28 | if (!initialized) {
29 | initialized = 1;
30 |
31 | #if TARGET_OS_SIMULATOR
32 | #else
33 |
34 | MPS_GRAPH_DEVICE = [MPSGraphDevice class];
35 | MPS_GRAPH = [MPSGraph class];
36 | MPS_GRAPH_CONVOLUTION_2D_OP_DESCRIPTOR = [MPSGraphConvolution2DOpDescriptor class];
37 | MPS_GRAPH_SINGLE_GATE_RNN_DESCRIPTOR = [MPSGraphSingleGateRNNDescriptor class];
38 | MPS_GRAPH_GRU_DESCRIPTOR = [MPSGraphGRUDescriptor class];
39 | MPS_GRAPH_LSTM_DESCRIPTOR = [MPSGraphLSTMDescriptor class];
40 | #endif
41 |
42 |
43 | }
44 | }
45 |
46 | NS_ASSUME_NONNULL_END
47 |
--------------------------------------------------------------------------------
/cidre/pomace/mpsg/mpsg.m:
--------------------------------------------------------------------------------
1 | //
2 | // mpsg.m
3 | // mpsg
4 | //
5 | // Created by Yury Korolev on 27.12.2022.
6 | //
7 |
8 | #import "mpsg.h"
9 |
10 |
--------------------------------------------------------------------------------
/cidre/pomace/mtk/mtk.h:
--------------------------------------------------------------------------------
1 | //
2 | // mtk.h
3 | // mtk
4 | //
5 | // Created by Yury Korolev on 10/28/24.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class MTK_TEXTURE_LOADER;
13 |
14 | __attribute__((constructor))
15 | static void mtk_initializer(void)
16 | {
17 | static int initialized = 0;
18 | if (!initialized) {
19 | initialized = 1;
20 |
21 | MTK_TEXTURE_LOADER = [MTKTextureLoader class];
22 | }
23 | }
24 |
25 |
26 | NS_ASSUME_NONNULL_END
27 |
--------------------------------------------------------------------------------
/cidre/pomace/mtk/mtk.m:
--------------------------------------------------------------------------------
1 | //
2 | // mtk.m
3 | // mtk
4 | //
5 | // Created by Yury Korolev on 10/28/24.
6 | //
7 |
8 | #import "mtk.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/mtl/mtl.m:
--------------------------------------------------------------------------------
1 | //
2 | // mtl.m
3 | // mtl
4 | //
5 | // Created by Yury Korolev on 27.02.2022.
6 | //
7 |
8 | #import "mtl.h"
9 |
10 |
--------------------------------------------------------------------------------
/cidre/pomace/nl/nl.h:
--------------------------------------------------------------------------------
1 | //
2 | // vn.h
3 | // vn
4 | //
5 | // Created by Yury Korolev on 13.10.2022.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class NL_LANGUAGE_RECOGNIZER;
13 | Class NL_EMBEDDING;
14 |
15 |
16 | __attribute__((constructor))
17 | static void nl_initializer(void)
18 | {
19 | static int initialized = 0;
20 | if (!initialized) {
21 | initialized = 1;
22 |
23 | NL_LANGUAGE_RECOGNIZER = [NLLanguageRecognizer class];
24 | NL_EMBEDDING = [NLEmbedding class];
25 | }
26 | }
27 |
28 |
29 |
30 | NS_ASSUME_NONNULL_END
31 |
32 |
--------------------------------------------------------------------------------
/cidre/pomace/nl/nl.m:
--------------------------------------------------------------------------------
1 | //
2 | // nl.m
3 | // nl
4 | //
5 | // Created by Yury Korolev on 4/15/24.
6 | //
7 |
8 | #import "nl.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/ns/ns.m:
--------------------------------------------------------------------------------
1 | //
2 | // ns.m
3 | // ns
4 | //
5 | // Created by Yury Korolev on 07.07.2022.
6 | //
7 |
8 | #import "ns.h"
9 |
10 |
11 | @implementation CidreObserver {
12 | __weak NSObject * _obj;
13 | NSString *_keyPath;
14 | void * _context;
15 | cidre_change * _fn_ptr;
16 | }
17 |
18 | - (instancetype)initWithObject: (NSObject *)obj
19 | keyPath: (NSString *)keyPath
20 | options: (NSKeyValueObservingOptions)options
21 | context: (void *)context
22 | fnPtr: (cidre_change *)fn_ptr
23 | {
24 | if (self = [super init]) {
25 | _obj = obj;
26 | _keyPath = keyPath;
27 | _context = context;
28 | _fn_ptr = fn_ptr;
29 | [_obj addObserver:self forKeyPath:keyPath options:options context:context];
30 | }
31 | return self;
32 | }
33 |
34 | - (void)observeValueForKeyPath:(nullable NSString *)keyPath ofObject:(nullable id)object change:(nullable NSDictionary *)change context:(nullable void *)context {
35 | _fn_ptr(context, keyPath, object, change);
36 | }
37 |
38 | - (void)invalidate {
39 | [_obj removeObserver:self forKeyPath:_keyPath context:_context];
40 | }
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/cidre/pomace/pomace.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/cidre/pomace/pomace.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/cidre/pomace/sc/sc.h:
--------------------------------------------------------------------------------
1 | //
2 | // sc.h
3 | // sc
4 | //
5 | // Created by Yury Korolev on 17.04.2022.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class SC_STREAM_CONFIGURATION;
13 | Class SC_CONTENT_FILTER;
14 | Class SC_STREAM;
15 | Class SC_SHAREABLE_CONTENT;
16 |
17 | Class SC_RECORDING_OUTPUT_CONFIGURATION;
18 | Class SC_RECORDING_OUTPUT;
19 | Class SC_CONTENT_SHARING_PICKER_CONFIGURATION;
20 | Class SC_CONTENT_SHARING_PICKER;
21 | Class SC_SCREENSHOT_MANAGER;
22 |
23 | __attribute__((constructor))
24 | static void sc_initializer(void)
25 | {
26 | static int initialized = 0;
27 | if (!initialized) {
28 | initialized = 1;
29 |
30 | SC_STREAM_CONFIGURATION = NSClassFromString(@"SCStreamConfiguration");
31 | SC_CONTENT_FILTER = NSClassFromString(@"SCContentFilter");
32 | SC_STREAM = NSClassFromString(@"SCStream");
33 | SC_SHAREABLE_CONTENT = NSClassFromString(@"SCShareableContent");
34 |
35 | SC_RECORDING_OUTPUT_CONFIGURATION = NSClassFromString(@"SCRecordingOutputConfiguration");
36 | SC_RECORDING_OUTPUT = NSClassFromString(@"SCRecordingOutput");
37 | SC_CONTENT_SHARING_PICKER_CONFIGURATION = NSClassFromString(@"SCContentSharingPickerConfiguration");
38 | SC_CONTENT_SHARING_PICKER = NSClassFromString(@"SCContentSharingPicker");
39 | SC_SCREENSHOT_MANAGER = NSClassFromString(@"SCScreenshotManager");
40 |
41 | }
42 | }
43 |
44 | NS_ASSUME_NONNULL_END
45 |
--------------------------------------------------------------------------------
/cidre/pomace/sc/sc.m:
--------------------------------------------------------------------------------
1 | //
2 | // sc.m
3 | // sc
4 | //
5 | // Created by Yury Korolev on 17.04.2022.
6 | //
7 |
8 | #import "sc.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/sn/sn.h:
--------------------------------------------------------------------------------
1 | //
2 | // sn.h
3 | // sn
4 | //
5 | // Created by Yury Korolev on 25.12.2022.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class SN_AUDIO_STREAM_ANALYZER;
13 | Class SN_AUDIO_FILE_ANALYZER;
14 | Class SN_TIME_DURATION_CONSTRAINT;
15 | Class SN_CLASSIFY_SOUND_REQUEST;
16 | Class SN_CLASSIFICATION_RESULT;
17 |
18 | __attribute__((constructor))
19 | static void sn_initializer(void)
20 | {
21 | static int initialized = 0;
22 | if (!initialized) {
23 | initialized = 1;
24 |
25 | SN_AUDIO_STREAM_ANALYZER = [SNAudioStreamAnalyzer class];
26 | SN_AUDIO_FILE_ANALYZER = [SNAudioFileAnalyzer class];
27 | SN_TIME_DURATION_CONSTRAINT = [SNTimeDurationConstraint class];
28 | SN_CLASSIFY_SOUND_REQUEST = [SNClassifySoundRequest class];
29 | SN_CLASSIFICATION_RESULT = [SNClassificationResult class];
30 | }
31 | }
32 |
33 |
34 | NS_ASSUME_NONNULL_END
35 |
--------------------------------------------------------------------------------
/cidre/pomace/sn/sn.m:
--------------------------------------------------------------------------------
1 | //
2 | // sn.m
3 | // sn
4 | //
5 | // Created by Yury Korolev on 25.12.2022.
6 | //
7 |
8 | #import "sn.h"
9 |
10 |
--------------------------------------------------------------------------------
/cidre/pomace/ui/ui.m:
--------------------------------------------------------------------------------
1 | //
2 | // ui.m
3 | // ui
4 | //
5 | // Created by Yury Korolev on 25.05.2022.
6 | //
7 |
8 | #import "ui.h"
9 |
10 |
--------------------------------------------------------------------------------
/cidre/pomace/un/un.m:
--------------------------------------------------------------------------------
1 | //
2 | // un.m
3 | // un
4 | //
5 | // Created by Yury Korolev on 1/21/24.
6 | //
7 |
8 | #import "un.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/ut/ut.h:
--------------------------------------------------------------------------------
1 | //
2 | // ut.h
3 | // ut
4 | //
5 | // Created by Yury Korolev on 12/11/23.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class UT_TYPE;
13 |
14 | __attribute__((constructor))
15 | static void ut_initializer(void)
16 | {
17 | static int initialized = 0;
18 | if (!initialized) {
19 | initialized = 1;
20 |
21 | UT_TYPE = [UTType class];
22 | }
23 | }
24 |
25 | NS_ASSUME_NONNULL_END
26 |
27 |
--------------------------------------------------------------------------------
/cidre/pomace/ut/ut.m:
--------------------------------------------------------------------------------
1 | //
2 | // ut.m
3 | // ut
4 | //
5 | // Created by Yury Korolev on 12/11/23.
6 | //
7 |
8 | #import "ut.h"
9 |
10 |
--------------------------------------------------------------------------------
/cidre/pomace/vn/vn.m:
--------------------------------------------------------------------------------
1 | //
2 | // vn.m
3 | // vn
4 | //
5 | // Created by Yury Korolev on 13.10.2022.
6 | //
7 |
8 | #import "vn.h"
9 |
10 |
--------------------------------------------------------------------------------
/cidre/pomace/wc/wc.h:
--------------------------------------------------------------------------------
1 | //
2 | // wc.h
3 | // wc
4 | //
5 | // Created by Yury Korolev on 2/11/24.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class WC_SESSION;
13 | Class WC_SESSION_FILE;
14 | Class WC_SESSION_FILE_TRANSFER;
15 | Class WC_SESSION_USER_INFO_TRANSFER;
16 |
17 | __attribute__((constructor))
18 | static void cl_initializer(void)
19 | {
20 | static int initialized = 0;
21 | if (!initialized) {
22 | initialized = 1;
23 |
24 | WC_SESSION = [WCSession class];
25 | WC_SESSION_FILE = [WCSessionFile class];
26 | WC_SESSION_FILE_TRANSFER = [WCSessionFileTransfer class];
27 | WC_SESSION_USER_INFO_TRANSFER = [WCSessionUserInfoTransfer class];
28 | }
29 | }
30 |
31 | NS_ASSUME_NONNULL_END
32 |
--------------------------------------------------------------------------------
/cidre/pomace/wc/wc.m:
--------------------------------------------------------------------------------
1 | //
2 | // wc.m
3 | // wc
4 | //
5 | // Created by Yury Korolev on 2/11/24.
6 | //
7 |
8 | #import "wc.h"
9 |
--------------------------------------------------------------------------------
/cidre/pomace/wk/wk.h:
--------------------------------------------------------------------------------
1 | //
2 | // wk.h
3 | // wk
4 | //
5 | // Created by Yury Korolev on 11/1/23.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | Class WK_WEB_VIEW;
13 | Class WK_WEB_VIEW_CONFIGURATION;
14 | Class WK_PROCESS_POOL;
15 | Class WK_PREFERENCES;
16 | Class WK_USER_CONTENT_CONTROLLER;
17 | Class WK_USER_SCRIPT;
18 | Class WK_WEBSITE_DATA_STORE;
19 |
20 | __attribute__((constructor))
21 | static void wk_initializer(void)
22 | {
23 | static int initialized = 0;
24 | if (!initialized) {
25 | initialized = 1;
26 | WK_WEB_VIEW = [WKWebView class];
27 | WK_WEB_VIEW_CONFIGURATION = [WKWebViewConfiguration class];
28 | WK_PROCESS_POOL = [WKProcessPool class];
29 | WK_PREFERENCES = [WKPreferences class];
30 | WK_USER_CONTENT_CONTROLLER = [WKUserContentController class];
31 | WK_USER_SCRIPT = [WKUserScript class];
32 | WK_WEBSITE_DATA_STORE = [WKWebsiteDataStore class];
33 | }
34 | }
35 |
36 | NS_ASSUME_NONNULL_END
37 |
--------------------------------------------------------------------------------
/cidre/pomace/wk/wk.m:
--------------------------------------------------------------------------------
1 | //
2 | // wk.m
3 | // wk
4 | //
5 | // Created by Yury Korolev on 11/1/23.
6 | //
7 |
8 | #import "wk.h"
9 |
10 |
--------------------------------------------------------------------------------
/cidre/src/am.rs:
--------------------------------------------------------------------------------
1 | pub mod device;
2 | pub use device::Action as DeviceAction;
3 | pub use device::Device;
4 | pub use device::IfaceConnectionType as DeviceIfaceConnectionType;
5 | pub use device::Notification as DeviceNotification;
6 | pub use device::QueryBuilder as DeviceQueryBuilder;
7 | pub use device::Speed as DeviceSpeed;
8 |
9 | pub mod service_connection;
10 | pub use service_connection::InvalidSocketError;
11 | pub use service_connection::ServiceConnection;
12 |
--------------------------------------------------------------------------------
/cidre/src/am/device/base.rs:
--------------------------------------------------------------------------------
1 | use crate::{cf, define_cf_type};
2 |
3 | #[derive(PartialEq, Eq, Copy, Clone)]
4 | #[repr(transparent)]
5 | pub struct Error(pub i32);
6 |
7 | define_cf_type!(Device(cf::Type));
8 | define_cf_type!(ServiceConnection(cf::Type));
9 |
10 | unsafe impl Send for ServiceConnection {}
11 | unsafe impl Sync for ServiceConnection {}
12 |
13 | define_cf_type!(Notification(cf::Type));
14 |
15 | define_cf_type!(PreflightOperation(cf::Type));
16 |
--------------------------------------------------------------------------------
/cidre/src/am/device/log.rs:
--------------------------------------------------------------------------------
1 | use std::os::unix::prelude::RawFd;
2 |
3 | use super::Error;
4 |
5 | pub fn add_file_descriptor(fd: RawFd) -> Error {
6 | unsafe { AMDAddLogFileDescriptor(fd) }
7 | }
8 |
9 | pub fn remove_file_descriptor(fd: RawFd) -> Error {
10 | unsafe { AMDRemoveLogFileDescriptor(fd) }
11 | }
12 |
13 | pub fn set_level(level: i32) {
14 | unsafe { AMDSetLogLevel(level) }
15 | }
16 |
17 | unsafe extern "C" {
18 | fn AMDAddLogFileDescriptor(fd: RawFd) -> Error;
19 | fn AMDRemoveLogFileDescriptor(fd: RawFd) -> Error;
20 | fn AMDSetLogLevel(level: i32);
21 | }
22 |
--------------------------------------------------------------------------------
/cidre/src/at.rs:
--------------------------------------------------------------------------------
1 | pub mod audio;
2 | pub use audio::BalanceFade as AudioBalanceFade;
3 | pub use audio::Buf as AudioBuf;
4 | pub use audio::BufList as AudioBufList;
5 | pub use audio::BufListN as AudioBufListN;
6 | pub use audio::ChannelBitmap as AudioChannelBitmap;
7 | pub use audio::ChannelCoordinateIndex as AudioChannelCoordinateIndex;
8 | pub use audio::ChannelDesc as AudioChannelDesc;
9 | pub use audio::ChannelFlags as AudioChannelFlags;
10 | pub use audio::ChannelLabel as AudioChannelLabel;
11 | pub use audio::ChannelLayout as AudioChannelLayout;
12 | pub use audio::ChannelLayoutTag as AudioChannelLayoutTag;
13 | pub use audio::ClassDesc as AudioClassDesc;
14 | pub use audio::Converter as AudioConverter;
15 | pub use audio::ConverterRef as AudioConverterRef;
16 | pub use audio::FileId as AudioFileId;
17 | pub use audio::FormatPropId as AudioFormatPropId;
18 |
19 | pub use audio::TimeStamp as AudioTimeStamp;
20 |
21 | pub use audio::unit as au;
22 |
23 | pub use audio::UnitElement as AudioUnitElement;
24 | pub use audio::UnitManufacturer as AudioUnitManufacturer;
25 | pub use audio::UnitParam as AudioUnitParam;
26 | pub use audio::UnitParamId as AudioUnitParamId;
27 | pub use audio::UnitParamValue as AudioUnitParamValue;
28 |
29 | pub use audio::Codec as AudioCodec;
30 | pub use audio::CodecGlobalPropId as AudioCodecGlobalPropId;
31 | pub use audio::CodecRef as AudioCodecRef;
32 |
--------------------------------------------------------------------------------
/cidre/src/av/animation.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, ns};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "AVLayerVideoGravity")]
5 | pub LayerVideoGravity(ns::String)
6 | );
7 |
8 | impl LayerVideoGravity {
9 | #[doc(alias = "AVLayerVideoGravityResizeAspect")]
10 | #[inline]
11 | pub fn resize_aspect() -> &'static Self {
12 | unsafe { AVLayerVideoGravityResizeAspect }
13 | }
14 |
15 | #[doc(alias = "AVLayerVideoGravityResizeAspectFill")]
16 | #[inline]
17 | pub fn resize_aspect_fill() -> &'static Self {
18 | unsafe { AVLayerVideoGravityResizeAspectFill }
19 | }
20 |
21 | #[doc(alias = "AVLayerVideoGravityResize")]
22 | #[inline]
23 | pub fn resize() -> &'static Self {
24 | unsafe { AVLayerVideoGravityResize }
25 | }
26 | }
27 |
28 | #[link(name = "AVFoundation", kind = "framework")]
29 | unsafe extern "C" {
30 | static AVLayerVideoGravityResizeAspect: &'static LayerVideoGravity;
31 | static AVLayerVideoGravityResizeAspectFill: &'static LayerVideoGravity;
32 | static AVLayerVideoGravityResize: &'static LayerVideoGravity;
33 | }
34 |
--------------------------------------------------------------------------------
/cidre/src/av/asset/cache.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "AVAssetCache")]
5 | pub Cache(ns::Id)
6 | );
7 |
8 | impl Cache {
9 | #[objc::msg_send(isPlayableOffline)]
10 | pub fn is_playable_offline(&self) -> bool;
11 | }
12 |
--------------------------------------------------------------------------------
/cidre/src/av/audio/connection_point.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, av::audio, define_cls, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(pub ConnectionPoint(ns::Id));
4 |
5 | impl arc::A {
6 | #[objc::msg_send(initWithNode:bus:)]
7 | pub fn init_with_node_bus(
8 | self,
9 | node: &audio::Node,
10 | bus: audio::NodeBus,
11 | ) -> arc::R;
12 | }
13 |
14 | impl ConnectionPoint {
15 | define_cls!(AV_AUDIO_CONNECTION_POINT);
16 |
17 | pub fn with_node_bus(node: &audio::Node, bus: audio::NodeBus) -> arc::R {
18 | Self::alloc().init_with_node_bus(node, bus)
19 | }
20 |
21 | #[objc::msg_send(node)]
22 | pub fn node(&self) -> &audio::Node;
23 |
24 | #[objc::msg_send(bus)]
25 | pub fn bus(&self) -> audio::NodeBus;
26 | }
27 |
28 | unsafe extern "C" {
29 | static AV_AUDIO_CONNECTION_POINT: &'static objc::Class;
30 | }
31 |
--------------------------------------------------------------------------------
/cidre/src/av/audio/mixer_node.rs:
--------------------------------------------------------------------------------
1 | use crate::{av::audio, define_obj_type, objc};
2 |
3 | // AVAudioMixerNode
4 | define_obj_type!(pub MixerNode(audio::Node));
5 | impl MixerNode {
6 | /// The mixer's output volume.
7 | ///
8 | /// This accesses the mixer's output volume (0.0-1.0, inclusive).
9 | #[objc::msg_send(outputVolume)]
10 | pub fn output_volume(&self) -> f32;
11 |
12 | #[objc::msg_send(setOutputVolume:)]
13 | pub fn set_output_volume(&mut self, value: f32);
14 |
15 | /// Find an unused input bus.
16 | ///
17 | /// This will find and return the first input bus to which no other node is connected.
18 | #[objc::msg_send(nextAvailableInputBus)]
19 | pub fn next_available_input_bus(&self) -> audio::NodeBus;
20 | }
21 |
--------------------------------------------------------------------------------
/cidre/src/av/audio/mixing.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, av, define_obj_type, ns, objc};
2 |
3 | #[objc::protocol(AVStereoMixing)]
4 | pub trait StereoMixing {
5 | #[objc::msg_send(pan)]
6 | fn pan(&self) -> f32;
7 |
8 | #[objc::msg_send(setPan:)]
9 | fn set_pan(&mut self, value: f32);
10 | }
11 |
12 | define_obj_type!(
13 | #[doc(alias = "AVAudioMixingDestination")]
14 | pub MixingDst(ns::Id)
15 | );
16 |
17 | impl MixingDst {
18 | #[objc::msg_send(connectionPoint)]
19 | pub fn connection_point(&self) -> arc::R;
20 | }
21 |
22 | impl av::audio::StereoMixing for MixingDst {}
23 | impl av::audio::Mixing for MixingDst {}
24 |
25 | #[objc::protocol(AVAudioMixing)]
26 | pub trait Mixing: StereoMixing {
27 | #[objc::msg_send(destinationForMixer:bus:)]
28 | fn destination_for_mixer(
29 | &self,
30 | mixer: av::AudioNode,
31 | bus: av::AudioNodeBus,
32 | ) -> Option>;
33 |
34 | #[objc::msg_send(volume)]
35 | fn volume(&self) -> f32;
36 |
37 | #[objc::msg_send(setVolume:)]
38 | fn set_volume(&mut self, value: f32);
39 | }
40 |
--------------------------------------------------------------------------------
/cidre/src/av/audio/types.rs:
--------------------------------------------------------------------------------
1 | #[cfg(feature = "blocks")]
2 | use crate::blocks;
3 |
4 | #[doc(alias = "AVAudioFramePosition")]
5 | pub type FramePos = i64;
6 |
7 | #[doc(alias = "AVAudioFrameCount")]
8 | pub type FrameCount = u32;
9 |
10 | #[doc(alias = "AVAudioPacketCount")]
11 | pub type PacketCount = u32;
12 |
13 | #[doc(alias = "AVAudioChannelCount")]
14 | pub type ChannelCount = u32;
15 |
16 | /// AVAudioNode objects potentially have multiple input and/or output busses.
17 | /// AVAudioNodeBus represents a bus as a zero-based index.
18 | #[doc(alias = "AVAudioNodeBus")]
19 | pub type NodeBus = usize;
20 |
21 | #[doc(alias = "AVAudioNodeCompletionHandler")]
22 | #[cfg(feature = "blocks")]
23 | pub type NodeCh = blocks::Block;
24 |
25 | #[derive(Copy, Clone, Debug, PartialEq)]
26 | #[repr(C)]
27 | pub struct Point3d {
28 | pub x: f32,
29 | pub y: f32,
30 | pub z: f32,
31 | }
32 |
33 | #[doc(alias = "AVAudio3DVector")]
34 | pub type Vec3d = Point3d;
35 |
36 | #[doc(alias = "AVAudio3DVectorOrientation")]
37 | #[derive(Copy, Clone, Debug, PartialEq)]
38 | #[repr(C)]
39 | pub struct Vec3dOrientation {
40 | pub forward: Vec3d,
41 | pub up: Vec3d,
42 | }
43 |
44 | #[derive(Copy, Clone, Debug, PartialEq)]
45 | #[repr(C)]
46 | pub struct Angular3dOrientation {
47 | pub yaw: f32,
48 | pub pitch: f32,
49 | pub roll: f32,
50 | }
51 |
--------------------------------------------------------------------------------
/cidre/src/av/audio/unit.rs:
--------------------------------------------------------------------------------
1 | use crate::{av::audio, define_obj_type};
2 |
3 | mod effect;
4 | pub use effect::Effect as UnitEffect;
5 |
6 | mod eq;
7 | pub use eq::Eq;
8 | pub use eq::FilterParameters as EqFilterParameters;
9 | pub use eq::FilterType as EqFilterType;
10 | pub use eq::UnitEq;
11 |
12 | mod time_effect;
13 | pub use time_effect::TimeEffect as UnitTimeEffect;
14 |
15 | define_obj_type!(pub Unit(audio::Node));
16 |
--------------------------------------------------------------------------------
/cidre/src/av/audio/unit/effect.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, at, av::audio, define_cls, define_obj_type, objc};
2 |
3 | define_obj_type!(pub Effect(audio::Unit));
4 |
5 | impl arc::A {
6 | #[objc::msg_send(initWithAudioComponentDescription:)]
7 | pub fn init_with_audio_component_desc(
8 | self,
9 | description: at::audio::ComponentDesc,
10 | ) -> arc::R;
11 | }
12 |
13 | impl Effect {
14 | define_cls!(AV_AUDIO_UNIT_EFFECT);
15 |
16 | pub fn with_component_desc(description: at::audio::ComponentDesc) -> arc::R {
17 | Self::alloc().init_with_audio_component_desc(description)
18 | }
19 |
20 | #[objc::msg_send(bypass)]
21 | pub fn bypass(&self) -> bool;
22 |
23 | #[objc::msg_send(setBypass:)]
24 | pub fn set_bypass(&mut self, value: bool);
25 | }
26 |
27 | #[link(name = "av", kind = "static")]
28 | unsafe extern "C" {
29 | static AV_AUDIO_UNIT_EFFECT: &'static objc::Class;
30 | }
31 |
--------------------------------------------------------------------------------
/cidre/src/av/audio/unit/time_effect.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, at, av::audio, define_cls, define_obj_type, objc};
2 |
3 | define_obj_type!(pub TimeEffect(audio::Unit));
4 |
5 | impl arc::A {
6 | #[objc::msg_send(initWithAudioComponentDescription:)]
7 | pub fn init_with_audio_component_desc(
8 | self,
9 | description: at::audio::ComponentDesc,
10 | ) -> arc::R;
11 | }
12 |
13 | /// Unit that processes audio in non real-time
14 | ///
15 | /// An TimeEffect represents an audio unit of type `aufc`.
16 | /// These effects do not process audio in real-time. The varispeed
17 | /// unit is an example of a time effect unit.
18 | ///
19 | /// AVAudioUnitTimeEffect
20 | impl TimeEffect {
21 | define_cls!(AV_AUDIO_UNIT_TIME_EFFECT);
22 |
23 | #[objc::msg_send(bypass)]
24 | pub fn bypass(&self) -> bool;
25 |
26 | #[objc::msg_send(setBypass:)]
27 | pub fn set_bypass(&mut self, value: bool);
28 |
29 | pub fn with_component_desc(description: at::audio::ComponentDesc) -> arc::R {
30 | Self::alloc().init_with_audio_component_desc(description)
31 | }
32 | }
33 |
34 | #[link(name = "av", kind = "static")]
35 | unsafe extern "C" {
36 | static AV_AUDIO_UNIT_TIME_EFFECT: &'static objc::Class;
37 | }
38 |
--------------------------------------------------------------------------------
/cidre/src/av/capture/control.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "AVCaptureControl")]
5 | pub Control(ns::Id)
6 | );
7 |
8 | impl Control {
9 | #[objc::msg_send(isEnabled)]
10 | #[objc::available(macos = 15.0, ios = 18.0, maccatalyst = 18.0, tvos = 18.0)]
11 | pub fn is_enabled(&self) -> bool;
12 |
13 | #[objc::msg_send(setEnabled:)]
14 | #[objc::available(macos = 15.0, ios = 18.0, maccatalyst = 18.0, tvos = 18.0)]
15 | pub fn set_enabled(&mut self, val: bool);
16 | }
17 |
--------------------------------------------------------------------------------
/cidre/src/av/capture/output_base.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, av, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(pub Output(ns::Id));
4 |
5 | impl Output {
6 | #[objc::msg_send(connections)]
7 | pub fn connections(&self) -> arc::R>;
8 |
9 | #[objc::msg_send(connectionWithMediaType:)]
10 | pub fn connection_with_media_type(
11 | &self,
12 | media_type: av::MediaType,
13 | ) -> Option>;
14 | }
15 |
16 | #[derive(Debug, PartialEq, Eq)]
17 | #[repr(isize)]
18 | pub enum DataDroppedReason {
19 | None = 0,
20 | LateData = 1,
21 | OutOfBuffers = 2,
22 | Discontinuity = 3,
23 | }
24 |
--------------------------------------------------------------------------------
/cidre/src/av/kit/error.rs:
--------------------------------------------------------------------------------
1 | use crate::ns;
2 |
3 | impl ns::ErrorDomain {
4 | #[doc(alias = "AVKitErrorDomain")]
5 | pub fn av_kit() -> &'static Self {
6 | unsafe { AVKitErrorDomain }
7 | }
8 | }
9 |
10 | #[link(name = "AVKit", kind = "framework")]
11 | unsafe extern "C" {
12 | static AVKitErrorDomain: &'static ns::ErrorDomain;
13 | }
14 |
15 | #[derive(Debug, PartialEq, Eq, Clone, Copy)]
16 | #[repr(isize)]
17 | pub enum Code {
18 | /// Unknown error.
19 | #[doc(alias = "AVKitErrorUnknown")]
20 | Unknown = -1000,
21 |
22 | /// Failed to start Picture in Picture.
23 | #[doc(alias = "AVKitErrorPictureInPictureStartFailed")]
24 | PipStartFailed = -1001,
25 |
26 | /// Media content rating missing or unrecognized.
27 | #[doc(alias = "AVKitErrorContentRatingUnknown")]
28 | ContentRatingUnknown = -1100,
29 |
30 | /// Restriction settings disallow access to this content, but the user can override by entering the passcode.
31 | #[doc(alias = "AVKitErrorContentDisallowedByPasscode")]
32 | ContentDisallowedByPasscode = -1101,
33 |
34 | /// An installed profile sets restriction settings that disallow access to this content;
35 | /// the user cannot override by entering the passcode (they may be able to override in Settings).
36 | #[doc(alias = "AVKitErrorContentDisallowedByProfile")]
37 | ContentDisallowedByProfile = -1102,
38 |
39 | /// The recording failed.
40 | #[doc(alias = "AVKitErrorRecordingFailed")]
41 | RecordingFailed = -1200,
42 | }
43 |
--------------------------------------------------------------------------------
/cidre/src/av/kit/playback_route_selecting.rs:
--------------------------------------------------------------------------------
1 | #[cfg(any(target_os = "ios", target_os = "visionos"))]
2 | use crate::{av, blocks, objc};
3 |
4 | #[doc(alias = "AVAudioSessionRouteSelection")]
5 | #[derive(Debug, Copy, Clone, Eq, PartialEq)]
6 | #[repr(isize)]
7 | pub enum AudioSessionRouteSelection {
8 | /// Indicates no route was selected.i
9 | #[doc(alias = "AVAudioSessionRouteSelectionNone")]
10 | None = 0,
11 |
12 | /// Indicates that the local device was selected.
13 | #[doc(alias = "AVAudioSessionRouteSelectionLocal")]
14 | Local = 1,
15 |
16 | /// Indicates that an external device was selected.
17 | #[doc(alias = "AVAudioSessionRouteSelectionExternal")]
18 | External = 2,
19 | }
20 |
21 | #[cfg(any(target_os = "ios", target_os = "visionos"))]
22 | impl av::AudioSession {
23 | #[objc::msg_send(prepareRouteSelectionForPlaybackWithCompletionHandler:)]
24 | #[objc::available(ios = 13.0, visionos = 1.0)]
25 | pub fn prepare_route_selection_for_playback_with_ch(
26 | &self,
27 | ch: &mut blocks::EscBlock<
28 | fn(should_start_playback: bool, route_selection: av::AudioSessionRouteSelection),
29 | >,
30 | );
31 | }
32 |
--------------------------------------------------------------------------------
/cidre/src/av/kit/types.rs:
--------------------------------------------------------------------------------
1 | use crate::define_opts;
2 |
3 | define_opts!(
4 | #[doc(alias = "AVVideoFrameAnalysisType")]
5 | pub VideoFrameAnalysisType(usize)
6 | );
7 |
8 | /// The types of items that AVPlayerViewController analyzes in a paused video frame.
9 | impl VideoFrameAnalysisType {
10 | /// Defines no items to be analyzed by the analyzer.
11 | #[doc(alias = "AVVideoFrameAnalysisTypeNone")]
12 | pub const NONE: Self = Self(0);
13 |
14 | /// Defines the default set of analysis types.
15 | #[doc(alias = "AVVideoFrameAnalysisTypeDefault")]
16 | pub const DEFAULT: Self = Self(1 << 0);
17 |
18 | /// Text that appears in a paused video frame.
19 | #[doc(alias = "AVVideoFrameAnalysisTypeText")]
20 | pub const TEXT: Self = Self(1 << 1);
21 |
22 | /// Subject that the user can copy out of frame.
23 | #[doc(alias = "AVVideoFrameAnalysisTypeSubject")]
24 | pub const SUBJECT: Self = Self(1 << 2);
25 |
26 | /// Objects, landmarks, art, etc. recognized visually in a paused video frame.
27 | #[doc(alias = "AVVideoFrameAnalysisTypeVisualSearch")]
28 | pub const VISUAL_SEARCH: Self = Self(1 << 3);
29 |
30 | /// Machine-readable codes, such as QR codes, that appear in a paused video frame.
31 | #[doc(alias = "AVVideoFrameAnalysisTypeMachineReadableCode")]
32 | pub const READABLE_CODE: Self = Self(1 << 4);
33 | }
34 |
--------------------------------------------------------------------------------
/cidre/src/av/sample_buffer.rs:
--------------------------------------------------------------------------------
1 | mod display_layer;
2 | pub use display_layer::DisplayLayer;
3 |
4 | mod video_renderer;
5 | pub use video_renderer::VideoRenderer;
6 |
7 | mod queued_sample_buffer_rendering;
8 | #[cfg(all(feature = "blocks", feature = "dispatch"))]
9 | pub use queued_sample_buffer_rendering::QueuedSampleBufRendering;
10 | pub use queued_sample_buffer_rendering::Status as QueuedSampleBufRenderingStatus;
11 |
--------------------------------------------------------------------------------
/cidre/src/av/sample_buffer/queued_sample_buffer_rendering.rs:
--------------------------------------------------------------------------------
1 | #[cfg(all(feature = "blocks", feature = "dispatch"))]
2 | use crate::{blocks, cm, dispatch, objc};
3 |
4 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
5 | #[repr(isize)]
6 | pub enum Status {
7 | Unknown = 0,
8 | Rendering = 1,
9 | Failed = 2,
10 | }
11 |
12 | #[cfg(all(feature = "blocks", feature = "dispatch"))]
13 | #[objc::protocol(AVQueuedSampleBufferRendering)]
14 | pub trait QueuedSampleBufRendering: objc::Obj {
15 | #[objc::msg_send(timebase)]
16 | fn timebase(&self) -> &cm::Timebase;
17 |
18 | #[objc::msg_send(enqueueSampleBuffer:)]
19 | fn enqueue_sample_buf(&mut self, buf: &cm::SampleBuf);
20 |
21 | #[objc::msg_send(flush)]
22 | fn flush(&mut self);
23 |
24 | #[objc::msg_send(readyForMoreMediaData)]
25 | fn ready_for_more_media_data(&mut self);
26 |
27 | #[objc::msg_send(requestMediaDataWhenReadyOnQueue:usingBlock:)]
28 | fn request_media_data_when_ready_on_queue_block(
29 | &mut self,
30 | queue: &dispatch::Queue,
31 | block: &blocks::WorkBlock,
32 | );
33 |
34 | #[objc::msg_send(stopRequestingMediaData)]
35 | fn stop_requesting_media_data(&mut self);
36 |
37 | #[objc::msg_send(hasSufficientMediaDataForReliablePlaybackStart)]
38 | fn has_sufficient_media_data_for_reliable_playback_start(&self) -> bool;
39 | }
40 |
--------------------------------------------------------------------------------
/cidre/src/av/time.rs:
--------------------------------------------------------------------------------
1 | #[cfg(feature = "cm")]
2 | use crate::{arc, cm, ns, objc};
3 |
4 | /// NSValueAVFoundationExtensions
5 | #[cfg(feature = "cm")]
6 | impl ns::Value {
7 | #[objc::msg_send(valueWithCMTime:)]
8 | #[objc::available(macos = 10.7, ios = 4.0, tvos = 9.0, watchos = 1.0, visionos = 1.0)]
9 | pub fn with_cm_time(range: &cm::Time) -> arc::R;
10 |
11 | #[objc::msg_send(CMTimeValue)]
12 | #[objc::available(macos = 10.7, ios = 4.0, tvos = 9.0, watchos = 1.0, visionos = 1.0)]
13 | pub fn cm_time_value(&self) -> cm::Time;
14 |
15 | #[objc::msg_send(valueWithCMTimeRange:)]
16 | #[objc::available(macos = 10.7, ios = 4.0, tvos = 9.0, watchos = 1.0, visionos = 1.0)]
17 | pub fn with_cm_time_range(range: &cm::TimeRange) -> arc::R;
18 |
19 | #[objc::msg_send(CMTimeRangeValue)]
20 | #[objc::available(macos = 10.7, ios = 4.0, tvos = 9.0, watchos = 1.0, visionos = 1.0)]
21 | pub fn cm_time_range_value(&self) -> cm::TimeRange;
22 |
23 | #[objc::msg_send(valueWithCMTimeMapping:)]
24 | #[objc::available(macos = 10.7, ios = 4.0, tvos = 9.0, watchos = 1.0, visionos = 1.0)]
25 | pub fn with_cm_time_mapping(range: &cm::TimeMapping) -> arc::R;
26 |
27 | #[objc::msg_send(CMTimeMapping)]
28 | #[objc::available(macos = 10.7, ios = 4.0, tvos = 9.0, watchos = 1.0, visionos = 1.0)]
29 | pub fn cm_time_mapping_value(&self) -> cm::TimeMapping;
30 | }
31 |
--------------------------------------------------------------------------------
/cidre/src/av/video.rs:
--------------------------------------------------------------------------------
1 | pub mod settings;
2 | pub use settings::keys as settings_keys;
3 | pub use settings::Codec;
4 |
--------------------------------------------------------------------------------
/cidre/src/ax.rs:
--------------------------------------------------------------------------------
1 | mod action_constants;
2 | pub use action_constants::Action;
3 | pub use action_constants::action;
4 |
5 | mod attribute_constants;
6 | pub use attribute_constants::Attr;
7 | pub use attribute_constants::MenuItemModifiers;
8 | pub use attribute_constants::ParamAttr;
9 | pub use attribute_constants::attr;
10 | pub use attribute_constants::param_attr;
11 |
12 | mod error;
13 | pub use error::Error;
14 | pub use error::err;
15 |
16 | mod notification_constants;
17 | pub use notification_constants::Notification;
18 | pub use notification_constants::Priority;
19 | pub use notification_constants::notification;
20 |
21 | mod role_constants;
22 | pub use role_constants::Role;
23 | pub use role_constants::SubRole;
24 | pub use role_constants::role;
25 | pub use role_constants::sub_role;
26 |
27 | mod ui_element;
28 | pub use ui_element::Observer;
29 | pub use ui_element::ObserverCb;
30 | pub use ui_element::ObserverInfoCb;
31 | pub use ui_element::TextMarker;
32 | pub use ui_element::TextMarkerRange;
33 | pub use ui_element::UiElement;
34 | pub use ui_element::is_process_trusted;
35 | pub use ui_element::is_process_trusted_with_opts;
36 | pub use ui_element::is_process_trusted_with_prompt;
37 | pub use ui_element::trusted_check_option_prompt;
38 |
39 | mod value;
40 | pub use value::Value;
41 | pub use value::ValueType;
42 |
--------------------------------------------------------------------------------
/cidre/src/ca.rs:
--------------------------------------------------------------------------------
1 | pub mod display_link;
2 | pub use display_link::DisplayLink;
3 | pub use display_link::Target as DisplayLinkTarget;
4 | pub use display_link::TargetImpl as DisplayLinkTargetImpl;
5 |
6 | mod edr_metadata;
7 | pub use edr_metadata::EdrMetadata;
8 |
9 | mod frame_rate_range;
10 | pub use frame_rate_range::FrameRateRange;
11 |
12 | mod base;
13 | pub use base::current_media_time;
14 |
15 | mod animation;
16 | pub use animation::Animation;
17 |
18 | mod media_timing_function;
19 | pub use media_timing_function::MediaTimingFn;
20 | pub use media_timing_function::Name as MediaTimingFnName;
21 |
22 | mod transform3d;
23 | pub use transform3d::Transform3d;
24 |
25 | mod layer;
26 | pub use layer::AutoresizingMask;
27 | pub use layer::ContentsFilter as LayerContentsFilter;
28 | pub use layer::ContentsFormat as LayerContentsFormat;
29 | pub use layer::ContentsGravity as LayerContentsGravity;
30 | pub use layer::CornerCurve as LayerCornerCurve;
31 | pub use layer::CornerMask;
32 | pub use layer::EdgeAntialiasingMask;
33 | pub use layer::Layer;
34 | pub use layer::ToneMapMode;
35 |
36 | #[cfg(feature = "mtl")]
37 | mod metal_layer;
38 | #[cfg(feature = "mtl")]
39 | pub use metal_layer::AnyMetalDrawable;
40 | #[cfg(feature = "mtl")]
41 | pub use metal_layer::MetalDrawable;
42 | #[cfg(feature = "mtl")]
43 | pub use metal_layer::MetalLayer;
44 |
45 | mod renderer;
46 | pub use renderer::OptKey as RendererOptKey;
47 | pub use renderer::Renderer;
48 |
49 | mod transaction;
50 | pub use transaction::Transaction;
51 |
--------------------------------------------------------------------------------
/cidre/src/ca/animation.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, ca, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(pub Animation(ns::Id), CA_ANIMATION);
4 | impl Animation {
5 | #[objc::msg_send(timingFunction)]
6 | pub fn timing_fn(&self) -> Option<&ca::MediaTimingFn>;
7 |
8 | #[objc::msg_send(setTimingFunction:)]
9 | pub fn set_timing_fn(&mut self, val: Option<&ca::MediaTimingFn>);
10 | }
11 |
12 | #[link(name = "ca", kind = "static")]
13 | unsafe extern "C" {
14 | static CA_ANIMATION: &'static objc::Class;
15 | }
16 |
--------------------------------------------------------------------------------
/cidre/src/ca/base.rs:
--------------------------------------------------------------------------------
1 | use crate::cf;
2 |
3 | /// cf::TimeInterval derived by calling mach_absolute_time()
4 | /// and converting the result to seconds.
5 | /// ```
6 | /// use cidre::ca;
7 | ///
8 | /// println!("{:?}", ca::current_media_time());
9 | /// ```
10 | #[inline]
11 | pub fn current_media_time() -> cf::TimeInterval {
12 | unsafe { CACurrentMediaTime() }
13 | }
14 |
15 | #[link(name = "QuartzCore", kind = "framework")]
16 | unsafe extern "C-unwind" {
17 | fn CACurrentMediaTime() -> cf::TimeInterval;
18 | }
19 |
--------------------------------------------------------------------------------
/cidre/src/ca/edr_metadata.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "CAEDRMetadata")]
5 | pub EdrMetadata(ns::Id)
6 | );
7 |
8 | impl EdrMetadata {
9 | define_cls!(CA_EDR_METADATA);
10 |
11 | #[objc::msg_send(HDR10MetadataWithDisplayInfo:contentInfo:opticalOutputScale:)]
12 | pub fn hdr_10_with_display_info(
13 | display_data: Option<&ns::Data>,
14 | content_data: Option<&ns::Data>,
15 | optical_output_scale: f32,
16 | ) -> arc::R;
17 |
18 | #[objc::msg_send(HDR10MetadataWithDisplayInfo:contentInfo:opticalOutputScale:)]
19 | pub fn hdr_10_with_lum(min_nits: f32, max_nits: f32, optical_output_scale: f32)
20 | -> arc::R;
21 |
22 | #[objc::msg_send(HLGMetadata)]
23 | pub fn hlg() -> arc::R;
24 |
25 | #[objc::msg_send(HLGMetadataWithAmbientViewingEnvironment:)]
26 | #[objc::available(macos = 14.0, ios = 17.0)]
27 | pub fn hlg_with_ambient_viewing_env(env: &ns::Data) -> arc::R;
28 |
29 | #[objc::msg_send(isAvailable)]
30 | pub fn is_available() -> bool;
31 | }
32 |
33 | #[link(name = "ca", kind = "static")]
34 | unsafe extern "C" {
35 | static CA_EDR_METADATA: &'static objc::Class;
36 | }
37 |
38 | #[cfg(test)]
39 | mod tests {
40 | use crate::ca;
41 |
42 | #[test]
43 | fn basics() {
44 | let meta = ca::EdrMetadata::hdr_10_with_display_info(None, None, 1.0);
45 | dbg!(meta);
46 | let hlg = ca::EdrMetadata::hlg();
47 | dbg!(hlg);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/cidre/src/ca/frame_rate_range.rs:
--------------------------------------------------------------------------------
1 | /// ```
2 | /// use cidre::ca;
3 | ///
4 | /// let frr = ca::FrameRateRange::default();
5 | /// let zero = ca::FrameRateRange { minium: 0.0, maximum: 0.0, preferred: 0.0 };
6 | ///
7 | /// // assert_ne!(frr, zero);
8 | /// ```
9 | #[derive(Debug, Copy, Clone)]
10 | #[repr(C)]
11 | pub struct FrameRateRange {
12 | pub minium: f32,
13 | pub maximum: f32,
14 | pub preferred: f32,
15 | }
16 |
17 | impl Default for FrameRateRange {
18 | fn default() -> Self {
19 | unsafe { CAFrameRateRangeDefault }
20 | }
21 | }
22 |
23 | impl PartialEq for FrameRateRange {
24 | #[inline]
25 | fn eq(&self, other: &Self) -> bool {
26 | unsafe { CAFrameRateRangeIsEqualToRange(*self, *other) }
27 | }
28 | }
29 |
30 | #[link(name = "QuartzCore", kind = "framework")]
31 | unsafe extern "C-unwind" {
32 | static CAFrameRateRangeDefault: FrameRateRange;
33 | fn CAFrameRateRangeIsEqualToRange(range: FrameRateRange, other: FrameRateRange) -> bool;
34 | }
35 |
--------------------------------------------------------------------------------
/cidre/src/ca/transaction.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "CATransaction")]
5 | pub Transaction(ns::Id),
6 | CA_TRANSACTION
7 | );
8 |
9 | impl Transaction {
10 | #[objc::msg_send(begin)]
11 | pub fn begin();
12 |
13 | #[objc::msg_send(commit)]
14 | pub fn commit();
15 |
16 | #[objc::msg_send(flush)]
17 | pub fn flush();
18 |
19 | #[objc::msg_send(lock)]
20 | pub fn lock();
21 |
22 | #[objc::msg_send(unlock)]
23 | pub fn unlock();
24 |
25 | #[objc::msg_send(disableActions)]
26 | pub fn disable_actions() -> bool;
27 |
28 | #[objc::msg_send(setDisableActions:)]
29 | pub fn set_disable_actions(val: bool);
30 |
31 | #[inline]
32 | pub fn perform R>(mut f: F) -> R {
33 | Self::begin();
34 | let r = f();
35 | Self::commit();
36 | r
37 | }
38 |
39 | #[inline]
40 | pub fn perform_with_disabled_actions R>(mut f: F) -> R {
41 | Self::perform(|| {
42 | Self::set_disable_actions(true);
43 | f()
44 | })
45 | }
46 | }
47 |
48 | #[link(name = "ca", kind = "static")]
49 | unsafe extern "C" {
50 | static CA_TRANSACTION: &'static objc::Class;
51 | }
52 |
--------------------------------------------------------------------------------
/cidre/src/cat.rs:
--------------------------------------------------------------------------------
1 | pub mod audio;
2 |
3 | pub use audio::Buf as AudioBuf;
4 | pub use audio::BufList as AudioBufList;
5 | pub use audio::BufListN as AudioBufListN;
6 | pub use audio::ChannelBitmap as AudioChannelBitmap;
7 | pub use audio::ChannelCoordinateIndex;
8 | pub use audio::ChannelDesc as AudioChannelDesc;
9 | pub use audio::ChannelFlags as AudioChannelFlags;
10 | pub use audio::ChannelLabel as AudioChannelLabel;
11 | pub use audio::ChannelLayout as AudioChannelLayout;
12 | pub use audio::ChannelLayoutTag as AudioChannelLayoutTag;
13 | pub use audio::ClassDesc as AudioClassDesc;
14 | pub use audio::Format as AudioFormat;
15 | pub use audio::FormatFlags as AudioFormatFlags;
16 | pub use audio::Integer as AudioInteger;
17 | pub use audio::TimeStamp as AudioTimeStamp;
18 | pub use audio::TimeStampFlags as AudioTimeStampFlags;
19 | pub use audio::UInteger as AudioUInteger;
20 |
21 | pub use audio::SessionErrorCode as AudioSessionErrorCode;
22 | pub use audio::SessionId as AudioSessionId;
23 | pub use audio::StreamBasicDesc as AudioBasicStreamDesc;
24 |
--------------------------------------------------------------------------------
/cidre/src/cat/audio.rs:
--------------------------------------------------------------------------------
1 | pub type Integer = isize;
2 | pub type UInteger = usize;
3 |
4 | mod base_types;
5 | pub use base_types::*;
6 |
7 | mod session_types;
8 | pub use session_types::ErrorCode as SessionErrorCode;
9 | pub use session_types::SessionId;
10 |
--------------------------------------------------------------------------------
/cidre/src/cf/locale.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, cf, define_cf_type};
2 |
3 | pub type Id = cf::String;
4 |
5 | define_cf_type!(Locale(cf::Type));
6 |
7 | impl Locale {
8 | #[inline]
9 | pub fn type_id() -> cf::TypeId {
10 | unsafe { CFLocaleGetTypeID() }
11 | }
12 | /// ```
13 | /// use cidre::cf;
14 | ///
15 | /// let system_loc = cf::Locale::system();
16 | ///
17 | /// let id = system_loc.id();
18 | ///
19 | ///
20 | /// ```
21 | pub fn system() -> &'static Locale {
22 | unsafe { CFLocaleGetSystem() }
23 | }
24 |
25 | /// ```
26 | /// use cidre::cf;
27 | ///
28 | /// let loc = cf::Locale::current();
29 | ///
30 | /// let id = loc.id();
31 | /// ```
32 | pub fn current() -> arc::R {
33 | unsafe { CFLocaleCopyCurrent() }
34 | }
35 |
36 | pub fn id(&self) -> &Id {
37 | unsafe { CFLocaleGetIdentifier(self) }
38 | }
39 | }
40 |
41 | #[link(name = "CoreFoundation", kind = "framework")]
42 | unsafe extern "C-unwind" {
43 | fn CFLocaleGetSystem() -> &'static Locale;
44 | fn CFLocaleGetIdentifier(locale: &Locale) -> &Id;
45 | fn CFLocaleCopyCurrent() -> arc::R;
46 | fn CFLocaleGetTypeID() -> cf::TypeId;
47 | }
48 |
--------------------------------------------------------------------------------
/cidre/src/cf/mach_port.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, cf, define_cf_type};
2 |
3 | define_cf_type!(
4 | #[doc(alias = "CFMachPortRef")]
5 | MachPort(cf::Type)
6 | );
7 |
8 | impl MachPort {
9 | #[inline]
10 | pub fn invalidate(&self) {
11 | unsafe { CFMachPortInvalidate(self) }
12 | }
13 |
14 | #[inline]
15 | pub fn is_valid(&self) -> bool {
16 | unsafe { CFMachPortIsValid(self) }
17 | }
18 |
19 | #[inline]
20 | pub fn run_loop_src_in(
21 | &self,
22 | index: cf::Index,
23 | allocator: Option<&cf::Allocator>,
24 | ) -> Option> {
25 | unsafe { CFMachPortCreateRunLoopSource(allocator, self, index) }
26 | }
27 |
28 | #[inline]
29 | pub fn run_loop_src(&self, index: cf::Index) -> Option> {
30 | unsafe { CFMachPortCreateRunLoopSource(None, self, index) }
31 | }
32 |
33 | #[inline]
34 | pub fn port(&self) -> crate::mach::Port {
35 | unsafe { CFMachPortGetPort(self) }
36 | }
37 | }
38 |
39 | #[link(name = "CoreFoundation", kind = "framework")]
40 | unsafe extern "C-unwind" {
41 | fn CFMachPortInvalidate(port: &MachPort);
42 | fn CFMachPortIsValid(port: &MachPort) -> bool;
43 | fn CFMachPortCreateRunLoopSource(
44 | allocator: Option<&cf::Allocator>,
45 | port: &MachPort,
46 | index: cf::Index,
47 | ) -> Option>;
48 |
49 | fn CFMachPortGetPort(port: &MachPort) -> crate::mach::Port;
50 | }
51 |
--------------------------------------------------------------------------------
/cidre/src/cg/direct_display_configuration.rs:
--------------------------------------------------------------------------------
1 | use crate::cg;
2 |
3 | #[cfg(target_os = "macos")]
4 | impl cg::DirectDisplayId {
5 | /// Return true if the display is connected, awake, and available for
6 | /// drawing; false otherwise.
7 | pub fn is_active(self) -> bool {
8 | unsafe { CGDisplayIsActive(self) }
9 | }
10 |
11 | /// Return true if the display is asleep (and is therefore not drawable);
12 | /// false otherwise.
13 | pub fn is_asleep(self) -> bool {
14 | unsafe { CGDisplayIsAsleep(self) }
15 | }
16 |
17 | /// Return true if the display is connected or online; false otherwise.
18 | pub fn is_online(self) -> bool {
19 | unsafe { CGDisplayIsOnline(self) }
20 | }
21 |
22 | /// Return true if the display is the current main display; false
23 | /// otherwise
24 | pub fn is_main(self) -> bool {
25 | unsafe { CGDisplayIsMain(self) }
26 | }
27 |
28 | /// Return true if the display is built-in, such as the internal display in
29 | /// portable systems; false otherwise.
30 | pub fn is_builtin(self) -> bool {
31 | unsafe { CGDisplayIsBuiltin(self) }
32 | }
33 | }
34 |
35 | #[cfg(target_os = "macos")]
36 | unsafe extern "C-unwind" {
37 | fn CGDisplayIsActive(display: cg::DirectDisplayId) -> bool;
38 | fn CGDisplayIsAsleep(display: cg::DirectDisplayId) -> bool;
39 | fn CGDisplayIsOnline(display: cg::DirectDisplayId) -> bool;
40 | fn CGDisplayIsMain(display: cg::DirectDisplayId) -> bool;
41 | fn CGDisplayIsBuiltin(display: cg::DirectDisplayId) -> bool;
42 | }
43 |
--------------------------------------------------------------------------------
/cidre/src/cg/window.rs:
--------------------------------------------------------------------------------
1 | // typedef uint32_t CGWindowID;
2 | pub type Id = u32;
3 |
--------------------------------------------------------------------------------
/cidre/src/ci.rs:
--------------------------------------------------------------------------------
1 | mod context;
2 | pub use context::Context;
3 |
4 | mod image;
5 | pub use image::Format;
6 | pub use image::Image;
7 | pub use image::ImageOpt;
8 |
9 | mod vector;
10 | pub use vector::Vec;
11 |
12 | mod barcode_descriptor;
13 | pub use barcode_descriptor::BarcodeDesc;
14 |
--------------------------------------------------------------------------------
/cidre/src/ci/barcode_descriptor.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, ns};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "CIBarcodeDescriptor")]
5 | pub BarcodeDesc(ns::Id)
6 | );
7 |
--------------------------------------------------------------------------------
/cidre/src/cl.rs:
--------------------------------------------------------------------------------
1 | mod beacon_region;
2 | pub use beacon_region::Beacon;
3 | pub use beacon_region::BeaconRegion;
4 |
5 | mod region;
6 | // #[cfg(any(target_os = "ios", target_os = "macos"))]
7 | pub use region::Proximity;
8 | pub use region::Region;
9 | // #[cfg(any(target_os = "ios", target_os = "macos"))]
10 | pub use region::RegionState;
11 |
12 | mod location_manager;
13 | pub use location_manager::AccuracyAuthorization;
14 | pub use location_manager::ActivityType;
15 | pub use location_manager::AuthorizationStatus;
16 | pub use location_manager::Delegate as LocationManagerDelegate;
17 | pub use location_manager::DelegateImpl as LocationManagerDelegateImpl;
18 | pub use location_manager::LocationManager;
19 |
20 | mod location;
21 | pub use location::accuracy as location_accuracy;
22 | pub use location::Accuracy as LocationAccuracy;
23 | pub use location::Coordinate2d as LocationCoordinate2d;
24 | pub use location::Degrees as LocationDegrees;
25 | pub use location::Direction as LocationDirection;
26 | pub use location::DirectionAccuracy as LocationDirectionAccuracy;
27 | pub use location::Distance as LocationDistance;
28 | pub use location::Floor;
29 | pub use location::Location;
30 | pub use location::Speed as LocationSpeed;
31 | pub use location::SpeedAccuracy as LocationSpeedAccuracy;
32 | pub use location::SrcInfo as LocationSrcInfo;
33 |
34 | mod heading;
35 | pub use heading::Heading;
36 |
--------------------------------------------------------------------------------
/cidre/src/cl/beacon_region.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, cl, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | pub BeaconRegion(cl::Region)
5 | );
6 |
7 | define_obj_type!(
8 | pub Beacon(ns::Id)
9 | );
10 |
11 | impl Beacon {
12 | #[objc::msg_send(timestamp)]
13 | pub fn timestamp(&self) -> arc::R;
14 |
15 | #[objc::msg_send(UUID)]
16 | pub fn uuid(&self) -> arc::R;
17 |
18 | #[objc::msg_send(major)]
19 | pub fn major(&self) -> arc::R;
20 |
21 | #[objc::msg_send(minor)]
22 | pub fn minor(&self) -> arc::R;
23 |
24 | #[objc::msg_send(proximity)]
25 | pub fn proximity(&self) -> cl::Proximity;
26 |
27 | #[objc::msg_send(accuracy)]
28 | pub fn accuracy(&self) -> cl::LocationAccuracy;
29 |
30 | #[objc::msg_send(rssi)]
31 | pub fn rssi(&self) -> isize;
32 | }
33 |
--------------------------------------------------------------------------------
/cidre/src/cl/heading.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, ns};
2 |
3 | define_obj_type!(
4 | pub Heading(ns::Id)
5 | );
6 |
--------------------------------------------------------------------------------
/cidre/src/cl/region.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, ns};
2 |
3 | /// Represents the current state of the device with reference to a region.
4 | #[doc(alias = "CLRegionState")]
5 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
6 | #[repr(isize)]
7 | pub enum RegionState {
8 | Unknown,
9 | Inside,
10 | Outside,
11 | }
12 |
13 | /// Represents the current proximity of an entity.
14 | #[doc(alias = "CLProximity")]
15 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
16 | #[repr(isize)]
17 | pub enum Proximity {
18 | Unknown,
19 | Immediate,
20 | Near,
21 | Far,
22 | }
23 |
24 | define_obj_type!(
25 | #[doc(alias = "CLRegion")]
26 | pub Region(ns::Id)
27 | );
28 |
--------------------------------------------------------------------------------
/cidre/src/cm/base.rs:
--------------------------------------------------------------------------------
1 | #[doc(alias = "CMItemCount")]
2 | pub type ItemCount = crate::cf::Index;
3 |
4 | #[doc(alias = "CMItemIndex")]
5 | pub type ItemIndex = crate::cf::Index;
6 |
7 | #[doc(alias = "CMPersistentTrackID")]
8 | #[derive(Debug, Clone, Copy, Eq, PartialEq)]
9 | #[repr(transparent)]
10 | pub struct PersistentTrackId(pub i32);
11 |
12 | impl PersistentTrackId {
13 | #[doc(alias = "kCMPersistentTrackID_Invalid")]
14 | pub const INVALID: Self = Self(0);
15 | }
16 |
17 | impl PartialEq for PersistentTrackId {
18 | fn eq(&self, other: &i32) -> bool {
19 | self.0 == *other
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/cidre/src/cm/io.rs:
--------------------------------------------------------------------------------
1 | pub mod extension;
2 |
3 | pub mod hardware;
4 | pub use hardware::err;
5 | pub use hardware::Class;
6 | pub use hardware::Obj;
7 | pub use hardware::PlugIn;
8 | pub use hardware::PlugInProp;
9 | pub use hardware::PropAddr;
10 | pub use hardware::PropElement;
11 | pub use hardware::PropScope;
12 | pub use hardware::PropSelector;
13 |
--------------------------------------------------------------------------------
/cidre/src/cm/io/extension.rs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yury/cidre/89211ec51ef0c2052baa0a5669c3b14ec3d4ca1f/cidre/src/cm/io/extension.rs
--------------------------------------------------------------------------------
/cidre/src/core_audio.rs:
--------------------------------------------------------------------------------
1 | mod hardware_base;
2 | pub use hardware_base::*;
3 |
4 | pub mod hardware;
5 |
6 | pub use hardware::aggregate_device_keys;
7 | pub use hardware::device_start;
8 | pub use hardware::sub_device_keys;
9 | pub use hardware::AggregateDevice;
10 | pub use hardware::Device;
11 | #[cfg(all(feature = "blocks", feature = "dispatch"))]
12 | pub use hardware::DeviceIoBlock;
13 | pub use hardware::DeviceIoProc;
14 | pub use hardware::DeviceIoProcId;
15 | pub use hardware::Process;
16 | #[cfg(all(feature = "blocks", feature = "dispatch"))]
17 | pub use hardware::PropListenerBlock;
18 | pub use hardware::PropListenerFn;
19 | pub use hardware::System;
20 |
21 | mod tap_description;
22 | pub use tap_description::TapDesc;
23 | pub use tap_description::TapMuteBehavior;
24 |
25 | #[cfg(feature = "macos_14_2")]
26 | pub mod hardware_tapping;
27 | #[cfg(feature = "macos_14_2")]
28 | pub use hardware_tapping::Tap;
29 | #[cfg(feature = "macos_14_2")]
30 | pub use hardware_tapping::TapGuard;
31 |
--------------------------------------------------------------------------------
/cidre/src/core_motion/absolute_altitude.rs:
--------------------------------------------------------------------------------
1 | use crate::{core_motion as cm, define_obj_type, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "CMAbsoluteAltitudeData")]
5 | pub AbsAltitudeData(cm::LogItem)
6 | );
7 |
8 | impl AbsAltitudeData {
9 | /// The absolute altitude of the device in meters relative to sea level; could be positive or negative.
10 | #[objc::msg_send(altitude)]
11 | pub fn altitude(&self) -> f64;
12 |
13 | /// The accuracy of the altitude estimate, in meters.
14 | #[objc::msg_send(accuracy)]
15 | pub fn accuracy(&self) -> f64;
16 |
17 | /// The precision of the altitude estimate, in meters.
18 | #[objc::msg_send(precision)]
19 | pub fn precision(&self) -> f64;
20 | }
21 |
--------------------------------------------------------------------------------
/cidre/src/core_motion/accelerometer.rs:
--------------------------------------------------------------------------------
1 | use crate::{core_motion as cm, define_obj_type, objc};
2 |
3 | #[doc(alias = "CMAcceleration")]
4 | #[derive(Debug, Copy, Clone, PartialEq)]
5 | #[repr(C)]
6 | pub struct Acceleration {
7 | pub x: f64,
8 | pub y: f64,
9 | pub z: f64,
10 | }
11 |
12 | define_obj_type!(
13 | #[doc(alias = "CMAccelerometerData")]
14 | pub AccelerometerData(cm::LogItem)
15 | );
16 |
17 | impl AccelerometerData {
18 | #[objc::msg_send(acceleration)]
19 | pub fn acceleration(&self) -> cm::Acceleration;
20 | }
21 |
--------------------------------------------------------------------------------
/cidre/src/core_motion/altitude.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, core_motion as cm, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "CMAltitudeData")]
5 | pub AltitudeData(cm::LogItem)
6 | );
7 |
8 | impl AltitudeData {
9 | /// The relative altitude in meters to the starting altitude.
10 | #[objc::msg_send(relativeAltitude)]
11 | pub fn relative_altitude(&self) -> arc::R;
12 |
13 | /// The pressure in kPa.
14 | #[objc::msg_send(pressure)]
15 | pub fn pressure(&self) -> arc::R;
16 | }
17 |
--------------------------------------------------------------------------------
/cidre/src/core_motion/authorization.rs:
--------------------------------------------------------------------------------
1 | #[doc(alias = "CMAuthorizationStatus")]
2 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
3 | #[repr(isize)]
4 | pub enum AuthorizationStatus {
5 | NotDetermined = 0,
6 | Restricted,
7 | Denied,
8 | Authorized,
9 | }
10 |
--------------------------------------------------------------------------------
/cidre/src/core_motion/gyro.rs:
--------------------------------------------------------------------------------
1 | use crate::{core_motion as cm, define_obj_type, objc};
2 |
3 | #[doc(alias = "CMRotationRate")]
4 | #[derive(Debug, Copy, Clone)]
5 | #[repr(C)]
6 | pub struct RotationRate {
7 | /// X-axis rotation rate in radians/second. The sign follows the right hand
8 | /// rule (i.e. if the right hand is wrapped around the X axis such that the
9 | /// tip of the thumb points toward positive X, a positive rotation is one
10 | /// toward the tips of the other 4 fingers).
11 | pub x: f64,
12 |
13 | /// Y-axis rotation rate in radians/second. The sign follows the right hand
14 | /// rule (i.e. if the right hand is wrapped around the Y axis such that the
15 | /// tip of the thumb points toward positive Y, a positive rotation is one
16 | /// toward the tips of the other 4 fingers).
17 | pub y: f64,
18 |
19 | /// Z-axis rotation rate in radians/second. The sign follows the right hand
20 | /// rule (i.e. if the right hand is wrapped around the Z axis such that the
21 | /// tip of the thumb points toward positive Z, a positive rotation is one
22 | /// toward the tips of the other 4 fingers).
23 | pub z: f64,
24 | }
25 |
26 | define_obj_type!(
27 | /// Contains a single gyro measurement.
28 | #[doc(alias = "CMGyroData")]
29 | pub GyroData(cm::LogItem)
30 | );
31 |
32 | impl GyroData {
33 | /// The rotation rate as measured by the gyro.
34 | #[objc::msg_send(rotationRate)]
35 | pub fn rotation_rate(&self) -> cm::RotationRate;
36 | }
37 |
--------------------------------------------------------------------------------
/cidre/src/core_motion/log_item.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "CMLogItem")]
5 | pub LogItem(ns::Id)
6 | );
7 |
8 | impl LogItem {
9 | #[objc::msg_send(timestamp)]
10 | pub fn timestamp(&self) -> ns::TimeInterval;
11 | }
12 |
--------------------------------------------------------------------------------
/cidre/src/core_motion/magnetometer.rs:
--------------------------------------------------------------------------------
1 | use crate::{core_motion as cm, define_obj_type, objc};
2 |
3 | #[derive(Debug, Copy, Clone)]
4 | #[repr(C)]
5 | pub struct MagneticField {
6 | /// X-axis magnetic field in microteslas.
7 | pub x: f64,
8 |
9 | /// Y-axis magnetic field in microteslas.
10 | pub y: f64,
11 |
12 | /// Z-axis magnetic field in microteslas.
13 | pub z: f64,
14 | }
15 |
16 | define_obj_type!(
17 | #[doc(alias = "CMMagnetometerData")]
18 | pub MagnetometerData(cm::LogItem)
19 | );
20 |
21 | impl MagnetometerData {
22 | #[objc::msg_send(magneticField)]
23 | pub fn magnetic_field(&self) -> cm::MagneticField;
24 | }
25 |
--------------------------------------------------------------------------------
/cidre/src/core_motion/rotation_rate_data.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, core_motion as cm, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "CMRotationRateData")]
5 | pub RotationRateData(cm::LogItem)
6 | );
7 |
8 | impl RotationRateData {
9 | #[objc::msg_send(rotationRate)]
10 | pub fn rotation_rate(&self) -> cm::RotationRate;
11 | }
12 |
13 | define_obj_type!(
14 | #[doc(alias = "CMRecordedRotationRateData")]
15 | pub RecordedRotationRateData(cm::RotationRateData)
16 | );
17 |
18 | impl RecordedRotationRateData {
19 | #[objc::msg_send(startDate)]
20 | pub fn start_date(&self) -> arc::R;
21 | }
22 |
--------------------------------------------------------------------------------
/cidre/src/ct.rs:
--------------------------------------------------------------------------------
1 | mod font;
2 | pub use font::Font;
3 | pub use font::Opts as FontOpts;
4 | pub use font::UIFontType as FontUIFontType;
5 |
6 | mod font_descriptor;
7 | pub use font_descriptor::Desc as FontDesc;
8 | pub use font_descriptor::FontFormat;
9 | pub use font_descriptor::FontOrientation;
10 | pub use font_descriptor::FontPriority;
11 |
12 | mod font_traits;
13 | pub use font_traits::FontStylisticClass;
14 | pub use font_traits::FontSymbolicTraits;
15 | pub use font_traits::CLASS_MASK_SHIFT as FONT_CLASS_MASK_SHIFT;
16 |
17 | mod font_manager;
18 | pub use font_manager::FontManager;
19 | pub use font_manager::Scope as FontManagerScope;
20 |
21 | mod run;
22 | pub use run::Run;
23 | pub use run::Status as RunStatus;
24 |
25 | mod line;
26 | pub use line::Line;
27 | pub use line::LineBoundsOpts;
28 | pub use line::LineTruncationType;
29 |
30 | mod paragraph_style;
31 | pub use paragraph_style::LineBreakMode;
32 | pub use paragraph_style::ParagraphStyle;
33 | pub use paragraph_style::ParagraphStyleSetting;
34 | pub use paragraph_style::ParagraphStyleSpecifier;
35 | pub use paragraph_style::TextAlignment;
36 | pub use paragraph_style::WritingDirection;
37 |
38 | mod string_attributes;
39 | pub use string_attributes::AttrName as StringAttrName;
40 | pub use string_attributes::UnderlineStyle;
41 | pub use string_attributes::UnderlineStyleModifiers;
42 |
--------------------------------------------------------------------------------
/cidre/src/cv/host_time.rs:
--------------------------------------------------------------------------------
1 | /// The current host time.
2 | ///
3 | /// In macOS, the host time bases for Core Video and CoreAudio
4 | /// are identical—both are based on the mach_absolute_time function—so
5 | /// the values returned from either API can be used interchangeably.
6 | #[doc(alias = "CVGetCurrentHostTime")]
7 | #[inline]
8 | pub fn current_host_time() -> u64 {
9 | unsafe { CVGetCurrentHostTime() }
10 | }
11 |
12 | /// Retrieve the frequency of the host time base.
13 | ///
14 | /// On Mac OS X, the host time base for CoreVideo and CoreAudio are identical, and the values returned from either API
15 | /// may be used interchangeably.
16 | #[inline]
17 | #[doc(alias = "CVGetHostClockFrequency")]
18 | pub fn host_clock_frequency() -> f64 {
19 | unsafe { CVGetHostClockFrequency() }
20 | }
21 |
22 | /// Retrieve the smallest possible increment in the host time base.
23 | #[doc(alias = "CVGetHostClockMinimumTimeDelta")]
24 | #[inline]
25 | pub fn host_clock_minimum_time_delta() -> u32 {
26 | unsafe { CVGetHostClockMinimumTimeDelta() }
27 | }
28 |
29 | #[link(name = "CoreVideo", kind = "framework")]
30 | unsafe extern "C-unwind" {
31 | fn CVGetCurrentHostTime() -> u64;
32 | fn CVGetHostClockFrequency() -> f64;
33 | fn CVGetHostClockMinimumTimeDelta() -> u32;
34 | }
35 |
--------------------------------------------------------------------------------
/cidre/src/cv/metal.rs:
--------------------------------------------------------------------------------
1 | pub mod texture;
2 | pub use texture::keys as texture_keys;
3 | pub use texture::Texture;
4 |
5 | pub mod texture_cache;
6 | pub use texture_cache::keys as texture_cache_keys;
7 | pub use texture_cache::TextureCache;
8 |
--------------------------------------------------------------------------------
/cidre/src/cv/metal/texture.rs:
--------------------------------------------------------------------------------
1 | use crate::{cv, mtl};
2 |
3 | #[doc(alias = "CVMetalTextureRef")]
4 | pub type Texture = cv::ImageBuf;
5 |
6 | impl Texture {
7 | #[doc(alias = "CVMetalTextureGetTexture")]
8 | #[inline]
9 | pub fn texture(&self) -> Option<&mtl::Texture> {
10 | unsafe { CVMetalTextureGetTexture(self) }
11 | }
12 |
13 | #[doc(alias = "CVMetalTextureIsFlipped")]
14 | #[inline]
15 | pub fn is_texture_flipped(&self) -> bool {
16 | unsafe { CVMetalTextureIsFlipped(self) }
17 | }
18 | }
19 |
20 | #[link(name = "CoreVideo", kind = "framework")]
21 | unsafe extern "C-unwind" {
22 | fn CVMetalTextureGetTexture(image: &Texture) -> Option<&mtl::Texture>;
23 | fn CVMetalTextureIsFlipped(image: &Texture) -> bool;
24 | }
25 |
26 | pub mod keys {
27 | use crate::cf;
28 |
29 | #[doc(alias = "kCVMetalTextureUsage")]
30 | #[inline]
31 | pub fn usage() -> &'static cf::String {
32 | unsafe { kCVMetalTextureUsage }
33 | }
34 |
35 | #[doc(alias = "kCVMetalTextureStorageMode")]
36 | #[inline]
37 | pub fn storage_mode() -> &'static cf::String {
38 | unsafe { kCVMetalTextureStorageMode }
39 | }
40 |
41 | #[link(name = "CoreVideo", kind = "framework")]
42 | unsafe extern "C" {
43 | static kCVMetalTextureUsage: &'static cf::String;
44 | static kCVMetalTextureStorageMode: &'static cf::String;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/cidre/src/dispatch/base.rs:
--------------------------------------------------------------------------------
1 | /// Functions that take `Function` type as a parameter also
2 | /// take a pointer to contextual data that you provide.
3 | /// When your dispatch function is called, the pointer to that contextual
4 | /// data is passed as the parameter to the function.
5 | /// The pointer to the contextual data is passed unmodified to your
6 | /// function and it is your responsibility to ensure that the pointer
7 | /// is valid.
8 | #[doc(alias = "dispatch_function_t")]
9 | pub type Fn = extern "C-unwind" fn(*mut T);
10 |
--------------------------------------------------------------------------------
/cidre/src/dispatch/group.rs:
--------------------------------------------------------------------------------
1 | use std::{ffi::c_void, mem::transmute};
2 |
3 | use crate::{arc, define_obj_type, dispatch};
4 |
5 | use super::{Queue, Time};
6 |
7 | define_obj_type!(pub Group(dispatch::Object));
8 |
9 | impl Group {
10 | #[inline]
11 | pub fn new() -> arc::R {
12 | unsafe { dispatch_group_create() }
13 | }
14 |
15 | #[inline]
16 | pub fn wait(&self, timeout: Time) -> isize {
17 | unsafe { dispatch_group_wait(self, timeout) }
18 | }
19 |
20 | #[inline]
21 | pub fn notify_f(&self, queue: &Queue, context: *mut T, work: dispatch::Fn) {
22 | unsafe { dispatch_group_notify_f(self, queue, context as _, transmute(work)) }
23 | }
24 |
25 | #[inline]
26 | pub fn enter(&self) {
27 | unsafe { dispatch_group_enter(self) }
28 | }
29 |
30 | #[inline]
31 | pub fn leave(&self) {
32 | unsafe { dispatch_group_leave(self) }
33 | }
34 | }
35 |
36 | #[link(name = "System", kind = "dylib")]
37 | unsafe extern "C-unwind" {
38 | fn dispatch_group_create() -> arc::R;
39 | fn dispatch_group_wait(group: &Group, timeout: Time) -> isize;
40 |
41 | fn dispatch_group_notify_f(
42 | group: &Group,
43 | queue: &Queue,
44 | context: *mut c_void,
45 | work: dispatch::Fn,
46 | );
47 | fn dispatch_group_enter(group: &Group);
48 | fn dispatch_group_leave(group: &Group);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/cidre/src/gc.rs:
--------------------------------------------------------------------------------
1 | mod color;
2 | pub use color::Color;
3 |
4 | mod device;
5 | pub use device::Device;
6 |
7 | mod device_light;
8 | pub use device_light::DeviceLight;
9 |
10 | mod controller;
11 | pub use controller::Controller;
12 | pub use controller::PlayerIndex as ControllerPlayerIndex;
13 |
--------------------------------------------------------------------------------
/cidre/src/gc/color.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "GCColor")]
5 | pub Color(ns::Id)
6 | );
7 |
8 | impl arc::A {
9 | #[objc::msg_send(initWithRed:green:blue:)]
10 | pub fn init_with_rgb(self, r: f32, g: f32, b: f32) -> arc::R;
11 | }
12 |
13 | impl Color {
14 | define_cls!(GC_COLOR);
15 |
16 | pub fn with_rgb(r: f32, g: f32, b: f32) -> arc::R {
17 | Self::alloc().init_with_rgb(r, g, b)
18 | }
19 |
20 | #[objc::msg_send(red)]
21 | pub fn r(&self) -> f32;
22 |
23 | #[objc::msg_send(green)]
24 | pub fn g(&self) -> f32;
25 |
26 | #[objc::msg_send(blue)]
27 | pub fn b(&self) -> f32;
28 | }
29 |
30 | #[link(name = "gc", kind = "static")]
31 | unsafe extern "C" {
32 | static GC_COLOR: &'static objc::Class;
33 | }
34 |
35 | #[cfg(test)]
36 | mod tests {
37 | use crate::gc;
38 |
39 | #[test]
40 | fn basics() {
41 | let c = gc::Color::with_rgb(0.4, 0.8, 0.9);
42 | assert_eq!(0.4, c.r());
43 | assert_eq!(0.8, c.g());
44 | assert_eq!(0.9, c.b());
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/cidre/src/gc/device.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_obj_type, dispatch, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "GCDevice")]
5 | pub Device(ns::Id)
6 | );
7 |
8 | impl Device {
9 | #[objc::msg_send(handlerQueue)]
10 | pub fn handler_queue(&self) -> arc::R;
11 |
12 | #[objc::msg_send(setHandlerQueue:)]
13 | pub fn set_handler_queue(&mut self, val: &dispatch::Queue);
14 |
15 | #[objc::msg_send(vendorName)]
16 | pub fn vendor_name(&self) -> Option>;
17 |
18 | #[objc::msg_send(productCategory)]
19 | pub fn product_category(&self) -> arc::R;
20 | }
21 |
--------------------------------------------------------------------------------
/cidre/src/gc/device_light.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_obj_type, gc, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "GCDeviceLight")]
5 | pub DeviceLight(ns::Id)
6 | );
7 |
8 | impl DeviceLight {
9 | #[objc::msg_send(color)]
10 | pub fn color(&self) -> arc::R;
11 | }
12 |
--------------------------------------------------------------------------------
/cidre/src/io.rs:
--------------------------------------------------------------------------------
1 | #[cfg(feature = "io_surface")]
2 | pub mod surface;
3 |
4 | #[cfg(feature = "io_surface")]
5 | pub use surface::ComponentName as SurfComponentName;
6 | #[cfg(feature = "io_surface")]
7 | pub use surface::ComponentRange as SurfComponentRange;
8 | #[cfg(feature = "io_surface")]
9 | pub use surface::LockOpts as SurfLockOpts;
10 | #[cfg(feature = "io_surface")]
11 | pub use surface::Subsampling as SurfSubsampling;
12 | #[cfg(feature = "io_surface")]
13 | pub use surface::Surf;
14 | #[cfg(feature = "io_surface")]
15 | pub use surface::SurfId;
16 |
17 | #[cfg(feature = "io_surface")]
18 | #[link(name = "IOSurface", kind = "framework")]
19 | unsafe extern "C" {}
20 |
21 | #[cfg(all(target_os = "macos", feature = "io_kit"))]
22 | mod kit;
23 | #[cfg(all(target_os = "macos", feature = "io_kit"))]
24 | pub use kit::audio;
25 | // we just define constants for now, so we don't need link yet
26 | // #[link(name = "IOKit", kind = "framework")]
27 | // unsafe extern "C" {}
28 |
--------------------------------------------------------------------------------
/cidre/src/io/kit.rs:
--------------------------------------------------------------------------------
1 | pub mod audio;
2 |
--------------------------------------------------------------------------------
/cidre/src/io/kit/audio.rs:
--------------------------------------------------------------------------------
1 | mod types;
2 | pub use types::bidirectional_term;
3 | pub use types::input_term;
4 | pub use types::output_term;
5 |
--------------------------------------------------------------------------------
/cidre/src/mac_types.rs:
--------------------------------------------------------------------------------
1 | pub type FourCharCode = u32;
2 |
3 | pub type ResType = FourCharCode; // ??
4 | pub type UniChar = u16;
5 |
6 | pub fn four_cc_to_string(bytes: [u8; 4]) -> String {
7 | let mut bytes = bytes;
8 | four_cc_to_str(&mut bytes).to_owned()
9 | }
10 |
11 | pub fn four_cc_to_str(bytes: &mut [u8; 4]) -> &str {
12 | for b in bytes.iter_mut() {
13 | if *b < b' ' || *b > b'~' {
14 | *b = b'.';
15 | }
16 | }
17 | // SAFETY: All bytes are in the ASCII range, so the result is valid UTF-8.
18 | unsafe { std::str::from_utf8_unchecked(bytes) }
19 | }
20 |
21 | pub fn four_cc_fmt_debug(
22 | val: u32,
23 | name: &str,
24 | f: &mut std::fmt::Formatter<'_>,
25 | ) -> std::fmt::Result {
26 | let mut fcc = val.to_be_bytes();
27 | f.debug_struct(name)
28 | .field("raw", &val)
29 | .field("fcc", &four_cc_to_str(&mut fcc))
30 | .finish()
31 | }
32 |
33 | #[cfg(test)]
34 | mod tests {
35 | use crate::four_cc_to_str;
36 |
37 | #[test]
38 | fn basics() {
39 | let mut x: [u8; 4] = (*b"24BG").into();
40 | let s = four_cc_to_str(&mut x);
41 | assert_eq!(s, "24BG");
42 |
43 | let mut bytes = 0u32.to_be_bytes();
44 | let s = four_cc_to_str(&mut bytes);
45 | assert_eq!(s, "....");
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/cidre/src/mach/boolean.rs:
--------------------------------------------------------------------------------
1 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd)]
2 | #[repr(transparent)]
3 | pub struct Boolean(pub i32);
4 |
5 | impl Boolean {
6 | pub const FALSE: Self = Self(0);
7 | pub const TRUE: Self = Self(1);
8 | }
9 |
10 | impl From for Boolean {
11 | #[inline]
12 | fn from(v: bool) -> Self {
13 | if v {
14 | Self::TRUE
15 | } else {
16 | Self::FALSE
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/cidre/src/mach/policy.rs:
--------------------------------------------------------------------------------
1 | use std::ffi::c_int;
2 |
3 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
4 | #[repr(transparent)]
5 | pub struct Policy(c_int);
6 |
--------------------------------------------------------------------------------
/cidre/src/mach/task.rs:
--------------------------------------------------------------------------------
1 | use std::{ffi::c_void, mem::MaybeUninit};
2 |
3 | use crate::mach;
4 |
5 | use super::TaskBasicInfo;
6 |
7 | #[inline]
8 | pub fn basic_info(target_task: mach::Port) -> Result {
9 | unsafe {
10 | let mut info: MaybeUninit = MaybeUninit::uninit();
11 | let mut cnt = TaskBasicInfo::count();
12 | let res = task_info(
13 | target_task,
14 | TaskBasicInfo::flavor(),
15 | info.as_mut_ptr() as _,
16 | &mut cnt as *mut mach::message::Number,
17 | );
18 |
19 | if res.is_ok() {
20 | Ok(info.assume_init())
21 | } else {
22 | Err(res)
23 | }
24 | }
25 | }
26 |
27 | unsafe extern "C-unwind" {
28 | fn task_info(
29 | target_task: mach::Port,
30 | flavor: mach::TaskFlavor,
31 | task_info_out: *mut c_void,
32 | task_info_out_cnt: *mut mach::message::Number,
33 | ) -> mach::KernReturn;
34 | }
35 |
36 | #[cfg(test)]
37 | mod tests {
38 | use crate::mach;
39 |
40 | #[test]
41 | fn basics() {
42 | let res =
43 | mach::task::basic_info(mach::Port::current_task()).expect("Failed to get task info");
44 | println!("task info {:?}", res);
45 | assert!(res.resident_size > 0);
46 | assert!(res.resident_size_max > 0);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/cidre/src/mach/task_info.rs:
--------------------------------------------------------------------------------
1 | use crate::mach;
2 |
3 | #[doc(alias = "mach_task_basic_info")]
4 | #[derive(Debug)]
5 | #[repr(C)]
6 | pub struct TaskBasicInfo {
7 | /// Virtual memory size (bytes)
8 | pub virtual_size: mach::VmSize,
9 |
10 | /// Resident memory size (bytes)
11 | pub resident_size: mach::VmSize,
12 |
13 | /// Maximum resident memory size (bytes)
14 | pub resident_size_max: mach::VmSize,
15 |
16 | /// Total user run time for terminated threads
17 | pub user_time: mach::TimeValue,
18 |
19 | /// Total system run time for terminated threads
20 | pub system_time: mach::TimeValue,
21 |
22 | /// Default policy for new threads
23 | pub policy: mach::Policy,
24 |
25 | /// Suspend count for task
26 | pub suspend_count: mach::Integer,
27 | }
28 |
29 | impl TaskBasicInfo {
30 | pub const fn flavor() -> TaskFlavor {
31 | TaskFlavor(20)
32 | }
33 |
34 | pub const fn count() -> mach::message::Number {
35 | (std::mem::size_of::() / std::mem::size_of::()) as _
36 | }
37 | }
38 |
39 | #[repr(transparent)]
40 | pub struct TaskFlavor(pub mach::Natural);
41 |
--------------------------------------------------------------------------------
/cidre/src/mach/time_value.rs:
--------------------------------------------------------------------------------
1 | use crate::mach;
2 |
3 | /// Time value returned by kernel
4 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
5 | #[doc(alias = "time_value_t")]
6 | #[repr(C)]
7 | pub struct TimeValue {
8 | pub seconds: mach::Integer,
9 | pub microseconds: mach::Integer,
10 | }
11 |
--------------------------------------------------------------------------------
/cidre/src/mach/types.rs:
--------------------------------------------------------------------------------
1 | use crate::mach;
2 |
3 | #[derive(Clone, Copy, Debug, PartialEq, Eq)]
4 | #[repr(transparent)]
5 | pub struct Task(pub mach::Port);
6 |
7 | #[derive(Clone, Copy, Debug, PartialEq, Eq)]
8 | #[repr(transparent)]
9 | pub struct TaskName(pub mach::Port);
10 |
--------------------------------------------------------------------------------
/cidre/src/mach/vm_map.rs:
--------------------------------------------------------------------------------
1 | use super::{KernReturn, VmAddr, VmAllocationFlags, VmSize};
2 |
3 | unsafe extern "C-unwind" {
4 | pub fn vm_allocate(
5 | target_task: super::VmMap,
6 | address: *mut VmAddr,
7 | size: VmSize,
8 | flags: VmAllocationFlags,
9 | ) -> KernReturn;
10 |
11 | pub fn vm_deallocate(target_task: super::VmMap, address: VmAddr, size: VmSize) -> KernReturn;
12 | }
13 |
--------------------------------------------------------------------------------
/cidre/src/mach/vm_statistics.rs:
--------------------------------------------------------------------------------
1 | use crate::define_opts;
2 |
3 | define_opts!(pub VmAllocationFlags(i32));
4 |
5 | impl VmAllocationFlags {
6 | /// Allocate new VM region at the specified virtual address, if possible.
7 | pub const FIXED: Self = Self(0x00000000);
8 |
9 | /// Allocate new VM region anywhere it would fit in the address space.
10 | pub const ANYWHERE: Self = Self(0x00000001);
11 |
12 | /// Create a purgable VM object for that new VM region.
13 | pub const PURGABLE: Self = Self(0x00000002);
14 |
15 | /// The new VM region will be chunked up into 4GB sized pieces.
16 | pub const _4GB_CHUNK: Self = Self(0x00000004);
17 |
18 | pub const RANDOM_ADDR: Self = Self(0x00000008);
19 |
20 | /// Pages brought in to this VM region are placed on the speculativeA
21 | /// queue instead of the active queue. In other words, they are not
22 | /// cached so that they will be stolen first if memory runs low.
23 | pub const NO_CACHE: Self = Self(0x00000010);
24 | pub const RESILIENT_CODESIGN: Self = Self(0x00000020);
25 | pub const RESILIENT_MEDIA: Self = Self(0x00000040);
26 | pub const PERMANENT: Self = Self(0x00001000);
27 |
28 | /// The new VM region can replace existing VM regions if necessary
29 | /// (to be used in combination with VM_FLAGS_FIXED).
30 | pub const VM_FLAGS_OVERWRITE: Self = Self(0x00004000);
31 |
32 | pub const fn make_tag(tag: i32) -> Self {
33 | Self(tag << 24)
34 | }
35 | }
36 |
37 | pub const VM_MEMORY_MACH_MSG: i32 = 20;
38 | pub const VM_MEMORY_SHARED_PMAP: i32 = 32;
39 |
--------------------------------------------------------------------------------
/cidre/src/mach/vm_types.rs:
--------------------------------------------------------------------------------
1 | use std::ffi::{c_int, c_uint};
2 |
3 | use super::Port;
4 |
5 | pub type Integer = c_int;
6 | pub type Natural = c_uint;
7 |
8 | pub type Size = usize;
9 | pub type Offset = usize;
10 | pub type Addr = usize;
11 |
12 | pub type Map = Port;
13 | pub type MapRead = Port;
14 | pub type MapInspect = Port;
15 |
--------------------------------------------------------------------------------
/cidre/src/mc/error.rs:
--------------------------------------------------------------------------------
1 | use crate::ns;
2 |
3 | impl ns::ErrorDomain {
4 | pub fn multipeer_connectivity() -> &'static Self {
5 | unsafe { MCErrorDomain }
6 | }
7 | }
8 |
9 | #[link(name = "MultipeerConnectivity", kind = "framework")]
10 | unsafe extern "C" {
11 | static MCErrorDomain: &'static ns::ErrorDomain;
12 | }
13 |
14 | #[derive(Debug, PartialEq, Eq, Clone, Copy)]
15 | #[repr(isize)]
16 | pub enum Code {
17 | /// An unknown error occurred.
18 | #[doc(alias = "MCErrorUnknown")]
19 | Unknown = 0,
20 |
21 | /// Your app attempted to send data to a peer that is not connected.
22 | #[doc(alias = "MCErrorNotConnected")]
23 | NotConnected = 1,
24 |
25 | /// Your app passed an invalid value as a parameter.
26 | #[doc(alias = "MCErrorInvalidParameter")]
27 | InvalidParameter = 2,
28 |
29 | /// The operation is unsupported.
30 | #[doc(alias = "MCErrorUnsupported")]
31 | Unsupported = 3,
32 |
33 | /// The connection attempt timed out.
34 | #[doc(alias = "MCErrorTimedOut")]
35 | TimedOut = 4,
36 |
37 | /// The operation was cancelled by the user.
38 | #[doc(alias = "MCErrorCancelled")]
39 | Cancelled = 5,
40 |
41 | /// Multipeer connectivity is currently unavailable.
42 | #[doc(alias = "MCErrorUnavailable")]
43 | Unavailable = 6,
44 | }
45 |
--------------------------------------------------------------------------------
/cidre/src/mc/peer_id.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "MCPeerID")]
5 | pub PeerId(ns::Id)
6 | );
7 |
8 | impl arc::A {
9 | #[objc::msg_send(initWithDisplayName:)]
10 | pub unsafe fn init_with_display_name_throws(self, display_name: &ns::String) -> arc::R;
11 | }
12 |
13 | impl PeerId {
14 | define_cls!(MC_PEER_ID);
15 |
16 | #[inline]
17 | pub fn with_display_name<'ear>(name: &ns::String) -> ns::ExResult<'ear, arc::R> {
18 | ns::try_catch(|| unsafe { Self::alloc().init_with_display_name_throws(name) })
19 | }
20 |
21 | #[objc::msg_send(displayName)]
22 | pub fn display_name(&self) -> arc::R;
23 | }
24 |
25 | #[link(name = "mc", kind = "static")]
26 | unsafe extern "C" {
27 | static MC_PEER_ID: &'static objc::Class;
28 | }
29 |
30 | #[cfg(test)]
31 | mod tests {
32 | use crate::{mc, ns};
33 |
34 | #[test]
35 | fn basics() {
36 | let name = ns::str!(c"test");
37 | let peer = mc::PeerId::with_display_name(name).unwrap();
38 | assert_eq!(&peer.display_name(), name);
39 |
40 | let name = ns::str!(c"");
41 | let _err = mc::PeerId::with_display_name(name).expect_err("should be err");
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/cidre/src/mlc/adam_optimizer.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, mlc, objc};
2 |
3 | define_obj_type!(pub AdamOptimizer(mlc::Optimizer));
4 | impl AdamOptimizer {
5 | define_cls!(MLC_ADAM_OPTIMIZER);
6 |
7 | #[objc::msg_send(beta1)]
8 | pub fn beta1(&self) -> f32;
9 |
10 | #[objc::msg_send(beta2)]
11 | pub fn beta2(&self) -> f32;
12 |
13 | #[objc::msg_send(epsilon)]
14 | pub fn epsilon(&self) -> f32;
15 |
16 | #[objc::msg_send(usesAMSGrad)]
17 | pub fn uses_ams_grad(&self) -> bool;
18 |
19 | #[objc::msg_send(timeStep)]
20 | pub fn time_step(&self) -> usize;
21 |
22 | #[objc::msg_send(optimizerWithDescriptor:)]
23 | pub fn with_desc(desc: &mlc::OptimizerDesc) -> arc::R;
24 |
25 | #[objc::msg_send(optimizerWithDescriptor:beta1:beta2:epsilon:timeStep:)]
26 | pub fn with_desc_betas_epsilon_time_step(
27 | desc: &mlc::OptimizerDesc,
28 | beta1: f32,
29 | beta2: f32,
30 | epsilon: f32,
31 | time_step: usize,
32 | ) -> arc::R;
33 |
34 | #[objc::msg_send(optimizerWithDescriptor:beta1:beta2:epsilon:usesAMSGrad:timeStep:)]
35 | pub fn with_desc_betas_epsilon_uses_ams_grad_time_step(
36 | desc: &mlc::OptimizerDesc,
37 | beta1: f32,
38 | beta2: f32,
39 | epsilon: f32,
40 | uses_ams_grad: bool,
41 | time_step: usize,
42 | ) -> arc::R;
43 | }
44 |
45 | #[link(name = "mlc", kind = "static")]
46 | unsafe extern "C" {
47 | static MLC_ADAM_OPTIMIZER: &'static objc::Class;
48 | }
49 |
--------------------------------------------------------------------------------
/cidre/src/mlc/adamw_optimizer.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, mlc, objc};
2 |
3 | define_obj_type!(pub AdamWOptimizer(mlc::Optimizer));
4 | impl AdamWOptimizer {
5 | define_cls!(MLC_ADAMW_OPTIMIZER);
6 |
7 | #[objc::msg_send(beta1)]
8 | pub fn beta1(&self) -> f32;
9 |
10 | #[objc::msg_send(beta2)]
11 | pub fn beta2(&self) -> f32;
12 |
13 | #[objc::msg_send(epsilon)]
14 | pub fn epsilon(&self) -> f32;
15 |
16 | #[objc::msg_send(usesAMSGrad)]
17 | pub fn uses_ams_grad(&self) -> bool;
18 |
19 | #[objc::msg_send(timeStep)]
20 | pub fn time_step(&self) -> usize;
21 |
22 | #[objc::msg_send(optimizerWithDescriptor:)]
23 | pub fn with_descriptor(desc: &mlc::OptimizerDesc) -> arc::R;
24 |
25 | #[objc::msg_send(optimizerWithDescriptor:beta1:beta2:epsilon:usesAMSGrad:timeStep:)]
26 | pub fn with_descriptor_betas_epsilon_uses_ams_grad_time_step(
27 | desc: &mlc::OptimizerDesc,
28 | beta1: f32,
29 | beta2: f32,
30 | epsilon: f32,
31 | uses_ams_grad: bool,
32 | time_step: usize,
33 | ) -> arc::R;
34 | }
35 |
36 | #[link(name = "mlc", kind = "static")]
37 | unsafe extern "C" {
38 | static MLC_ADAMW_OPTIMIZER: &'static objc::Class;
39 | }
40 |
--------------------------------------------------------------------------------
/cidre/src/mlc/arithmetic_layer.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, mlc, objc};
2 |
3 | define_obj_type!(pub ArithmeticLayer(mlc::Layer));
4 |
5 | impl ArithmeticLayer {
6 | define_cls!(MLC_ARITHMETIC_LAYER);
7 |
8 | #[objc::msg_send(operation)]
9 | pub fn operation(&self) -> mlc::ArithmeticOp;
10 |
11 | #[objc::msg_send(layerWithOperation:)]
12 | pub fn with_op(op: mlc::ArithmeticOp) -> arc::R;
13 | }
14 |
15 | #[link(name = "mlc", kind = "static")]
16 | unsafe extern "C" {
17 | static MLC_ARITHMETIC_LAYER: &'static objc::Class;
18 | }
19 |
20 | #[cfg(test)]
21 | mod tests {
22 | use crate::mlc;
23 |
24 | #[test]
25 | fn basics() {
26 | let layer = mlc::ArithmeticLayer::with_op(mlc::ArithmeticOp::Add);
27 | println!("layer {layer:?}");
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/cidre/src/mlc/batch_normalization_layer.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_cls, define_obj_type, mlc, objc};
2 |
3 | define_obj_type!(pub BatchNormalizationLayer(mlc::Layer));
4 |
5 | impl BatchNormalizationLayer {
6 | define_cls!(MLC_BATCH_NORMALIZATION_LAYER);
7 |
8 | /// The number of feature channels
9 | #[objc::msg_send(featureChannelCount)]
10 | pub fn feature_channel_count(&self) -> usize;
11 |
12 | #[objc::msg_send(mean)]
13 | pub fn mean(&self) -> &mlc::Tensor;
14 |
15 | #[objc::msg_send(beta)]
16 | pub fn beta(&self) -> Option<&mlc::Tensor>;
17 |
18 | #[objc::msg_send(gamma)]
19 | pub fn gamma(&self) -> Option<&mlc::Tensor>;
20 | }
21 |
22 | unsafe extern "C" {
23 | static MLC_BATCH_NORMALIZATION_LAYER: &'static objc::Class;
24 | }
25 |
--------------------------------------------------------------------------------
/cidre/src/mlc/graph.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_obj_type, mlc, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "MLCGraph")]
5 | pub Graph(ns::Id), MLC_GRAPH
6 | );
7 |
8 | impl Graph {
9 | #[objc::msg_send(nodeWithLayer:sources:)]
10 | pub fn node_with_layer_sources_array(
11 | &self,
12 | layer: &mlc::Layer,
13 | sources: &ns::Array,
14 | ) -> Option>;
15 |
16 | #[inline]
17 | pub fn node_with_layer_sources(
18 | &self,
19 | layer: &mlc::Layer,
20 | sources: &[&mlc::Tensor],
21 | ) -> Option> {
22 | let sources = ns::Array::from_slice(sources);
23 | self.node_with_layer_sources_array(layer, &sources)
24 | }
25 | }
26 |
27 | #[link(name = "mlc", kind = "static")]
28 | unsafe extern "C" {
29 | static MLC_GRAPH: &'static objc::Class;
30 | }
31 |
--------------------------------------------------------------------------------
/cidre/src/mlc/layer.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_obj_type, mlc, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "MLCLayer")]
5 | pub Layer(ns::Id)
6 | );
7 | impl Layer {
8 | #[objc::msg_send(layerID)]
9 | pub fn layer_id(&self) -> usize;
10 |
11 | #[objc::msg_send(label)]
12 | pub fn label(&self) -> arc::R;
13 |
14 | #[objc::msg_send(setLabel:)]
15 | pub fn set_label(&mut self, val: &ns::String);
16 |
17 | #[objc::msg_send(isDebuggingEnabled)]
18 | pub fn is_debug_enabled(&self) -> bool;
19 |
20 | #[objc::msg_send(setIsDebuggingEnabled:)] // TODO: check setter signature
21 | pub fn set_debug_enabled(&mut self, val: bool);
22 |
23 | #[objc::msg_send(deviceType)]
24 | pub fn device_type(&self) -> mlc::DeviceType;
25 | }
26 |
--------------------------------------------------------------------------------
/cidre/src/mlc/matmul.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, mlc, ns, objc};
2 |
3 | define_obj_type!(pub Desc(ns::Id));
4 | impl Desc {
5 | define_cls!(MLC_MATMUL_DESCRIPTOR);
6 |
7 | #[objc::msg_send(alpha)]
8 | pub fn alpha(&self) -> f32;
9 |
10 | #[objc::msg_send(transposesX)]
11 | pub fn transposes_x(&self) -> bool;
12 |
13 | #[objc::msg_send(transposesY)]
14 | pub fn transposes_y(&self) -> bool;
15 |
16 | #[objc::msg_send(descriptor)]
17 | pub fn desc() -> arc::R;
18 |
19 | #[objc::msg_send(descriptorWithAlpha:transposesX:transposesY:)]
20 | pub fn with_alpha(alpha: f32, transposes_x: bool, transposes_y: bool) -> Option>;
21 |
22 | #[inline]
23 | pub fn new() -> arc::R {
24 | Self::desc()
25 | }
26 | }
27 |
28 | define_obj_type!(
29 | #[doc(alias = "MLCLayer")]
30 | pub Layer(mlc::Layer)
31 | );
32 |
33 | impl Layer {
34 | define_cls!(MLC_MATMUL_LAYER);
35 |
36 | #[objc::msg_send(layerWithDescriptor:)]
37 | pub fn with_desc(desc: &Desc) -> Option>;
38 |
39 | #[objc::msg_send(descriptor)]
40 | pub fn desc(&self) -> &Desc;
41 |
42 | pub fn new() -> arc::R {
43 | Self::with_desc(&Desc::new()).unwrap()
44 | }
45 | }
46 |
47 | #[link(name = "mlc", kind = "static")]
48 | unsafe extern "C" {
49 | static MLC_MATMUL_DESCRIPTOR: &'static objc::Class;
50 | static MLC_MATMUL_LAYER: &'static objc::Class;
51 | }
52 |
--------------------------------------------------------------------------------
/cidre/src/mlc/optimizer.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, mlc, ns, objc};
2 |
3 | define_obj_type!(pub Optimizer(ns::Id));
4 |
5 | impl Optimizer {
6 | /// The learning rate.
7 | /// This property is 'readwrite' so that callers can implement a 'decay' during training
8 | #[objc::msg_send(learningRate)]
9 | pub fn learning_rate(&self) -> f32;
10 |
11 | #[objc::msg_send(setLearningRate:)]
12 | pub fn set_learning_rate(&mut self, val: f32);
13 |
14 | #[objc::msg_send(gradientRescale)]
15 | pub fn grad_rescale(&self) -> f32;
16 |
17 | #[objc::msg_send(setGradientRescale:)]
18 | pub fn set_grad_rescale(&mut self, val: f32);
19 |
20 | #[objc::msg_send(appliesGradientClipping)]
21 | pub fn applies_grad_clipping(&self) -> f32;
22 |
23 | #[objc::msg_send(setAppliesGradientClipping:)]
24 | pub fn set_applies_grad_clipping(&mut self, val: f32);
25 |
26 | #[objc::msg_send(gradientClipMax)]
27 | pub fn grad_clip_max(&self) -> f32;
28 |
29 | #[objc::msg_send(gradientClipMin)]
30 | pub fn grad_clip_min(&self) -> f32;
31 |
32 | #[objc::msg_send(regularizationScale)]
33 | pub fn regularization_scale(&self) -> f32;
34 |
35 | #[objc::msg_send(gradientClippingType)]
36 | pub fn grad_clipping_type(&self) -> mlc::GradientClippingType;
37 |
38 | #[objc::msg_send(maximumClippingNorm)]
39 | pub fn max_clipping_norm(&self) -> f32;
40 |
41 | #[objc::msg_send(customGlobalNorm)]
42 | pub fn custom_global_norm(&self) -> f32;
43 | }
44 |
--------------------------------------------------------------------------------
/cidre/src/mlc/tensor_data.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "MLCTensorData")]
5 | pub TensorData(ns::Id)
6 | );
7 |
8 | impl TensorData {
9 | define_cls!(MLC_TENSOR_DATA);
10 |
11 | #[objc::msg_send(bytes)]
12 | pub fn bytes(&self) -> *const u8;
13 |
14 | #[objc::msg_send(bytes)]
15 | pub fn bytes_mut(&mut self) -> *mut u8;
16 |
17 | #[objc::msg_send(length)]
18 | pub fn len(&self) -> usize;
19 |
20 | #[inline]
21 | pub fn is_empty(&self) -> bool {
22 | self.len() == 0
23 | }
24 |
25 | #[objc::msg_send(dataWithImmutableBytesNoCopy:length:)]
26 | pub fn with_bytes_no_copy(bytes: *const u8, length: usize) -> arc::R;
27 |
28 | #[inline]
29 | pub fn with_slice_no_copy(slice: &[T]) -> arc::R {
30 | Self::with_bytes_no_copy(slice.as_ptr() as _, std::mem::size_of_val(slice))
31 | }
32 | }
33 |
34 | #[link(name = "mlc", kind = "static")]
35 | unsafe extern "C" {
36 | static MLC_TENSOR_DATA: &'static objc::Class;
37 | }
38 |
--------------------------------------------------------------------------------
/cidre/src/mlc/tensor_parameter.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, mlc, ns, objc};
2 |
3 | define_obj_type!(pub TensorParameter(ns::Id));
4 | impl TensorParameter {
5 | define_cls!(MLC_TENSOR_PARAMETER);
6 |
7 | #[objc::msg_send(tensor)]
8 | pub fn tensor(&self) -> &mlc::Tensor;
9 |
10 | #[objc::msg_send(isUpdatable)]
11 | pub fn is_updatable(&self) -> bool;
12 |
13 | #[objc::msg_send(setUpdatable:)]
14 | pub fn set_updatable(&mut self, val: bool);
15 |
16 | #[objc::msg_send(parameterWithTensor:)]
17 | pub fn with_tensor(tensor: &mlc::Tensor) -> arc::R;
18 |
19 | #[objc::msg_send(parameterWithTensor:optimizerData:)]
20 | pub fn with_tensor_optimizer_data(
21 | tensor: &mlc::Tensor,
22 | optimizer_data: Option>,
23 | ) -> arc::R;
24 | }
25 |
26 | #[link(name = "mlc", kind = "static")]
27 | unsafe extern "C" {
28 | static MLC_TENSOR_PARAMETER: &'static objc::Class;
29 | }
30 |
--------------------------------------------------------------------------------
/cidre/src/mlc/training_graph.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_obj_type, mlc, objc};
2 |
3 | define_obj_type!(pub TrainingGraph(mlc::Graph), MLC_TRAINING_GRAPH);
4 | impl TrainingGraph {
5 | /// The optimizer to be used with the training graph
6 | #[objc::msg_send(optimizer)]
7 | pub fn optimizer(&self) -> Option<&mlc::Optimizer>;
8 |
9 | /// The device memory size used by the training graph
10 | ///
11 | /// Returns the total size in bytes of device memory used for all intermediate tensors
12 | /// for forward, gradient passes and optimizer update for all layers in the training graph.
13 | /// We recommend executing an iteration before checking the device memory size as
14 | /// the buffers needed get allocated when the corresponding pass such as gradient,
15 | /// optimizer update is executed.
16 | #[objc::msg_send(deviceMemorySize)]
17 | pub fn device_mem_size(&self) -> usize;
18 | }
19 |
20 | #[link(name = "mlc", kind = "static")]
21 | unsafe extern "C" {
22 | static MLC_TRAINING_GRAPH: &'static objc::Class;
23 | }
24 |
25 | #[cfg(test)]
26 | mod tests {
27 | use crate::mlc;
28 |
29 | #[test]
30 | fn basics() {
31 | let graph = mlc::TrainingGraph::new();
32 | assert!(graph.optimizer().is_none());
33 | assert_eq!(graph.device_mem_size(), 0);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/cidre/src/mps.rs:
--------------------------------------------------------------------------------
1 | pub mod graph;
2 |
3 | mod core;
4 | pub use core::AliasingStrategy;
5 | pub use core::DType;
6 | pub use core::DimensionSlice;
7 | pub use core::ImageEdgeMode;
8 | pub use core::ImageFeatureChannelFormat;
9 | pub use core::KernelOpts;
10 | pub use core::Offset;
11 | pub use core::Origin;
12 | pub use core::Shape;
13 | pub use core::Size;
14 |
15 | pub use core::NdArray;
16 | pub use core::NdArrayAllocator;
17 | pub use core::NdArrayDesc;
18 |
--------------------------------------------------------------------------------
/cidre/src/mps/core.rs:
--------------------------------------------------------------------------------
1 | mod types;
2 |
3 | pub use types::AliasingStrategy;
4 | pub use types::DType;
5 | pub use types::DimensionSlice;
6 | pub use types::ImageEdgeMode;
7 | pub use types::ImageFeatureChannelFormat;
8 | pub use types::KernelOpts;
9 | pub use types::Offset;
10 | pub use types::Origin;
11 | pub use types::Shape;
12 | pub use types::Size;
13 |
14 | mod nd_array;
15 | pub use nd_array::NdArray;
16 | pub use nd_array::NdArrayAllocator;
17 | pub use nd_array::NdArrayDesc;
18 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/activation_ops.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, mps::graph, ns, objc};
2 |
3 | impl graph::Graph {
4 | #[objc::msg_send(reLUWithTensor:name:)]
5 | pub fn relu(&self, tensor: &graph::Tensor, name: Option<&ns::String>) -> arc::R;
6 |
7 | #[objc::msg_send(sigmoidWithTensor:name:)]
8 | pub fn sigmoid(
9 | &self,
10 | tensor: &graph::Tensor,
11 | name: Option<&ns::String>,
12 | ) -> arc::R;
13 |
14 | #[objc::msg_send(softMaxWithTensor:axis:name:)]
15 | pub fn soft_max(
16 | &self,
17 | tensor: &graph::Tensor,
18 | axis: ns::Integer,
19 | name: Option<&ns::String>,
20 | ) -> arc::R;
21 | }
22 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/convolution_ops.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, mps::graph, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "MPSGraphConvolution2dDescriptor")]
5 | pub Conv2dOpDesc(ns::Id)
6 | );
7 |
8 | impl Conv2dOpDesc {
9 | define_cls!(MPS_GRAPH_CONVOLUTION_2D_OP_DESCRIPTOR);
10 |
11 | #[objc::msg_send(descriptorWithStrideInX:strideInY:dilationRateInX:dilationRateInY:groups:paddingLeft:paddingRight:paddingTop:paddingBottom:paddingStyle:dataLayout:weightsLayout:)]
12 | pub fn with(
13 | stride_in_x: usize,
14 | stride_in_y: usize,
15 | dilation_rate_in_x: usize,
16 | dilation_rate_in_y: usize,
17 | groups: usize,
18 | padding_left: usize,
19 | padding_right: usize,
20 | padding_top: usize,
21 | padding_bottom: usize,
22 | padding_style: graph::PaddingStyle,
23 | data_layout: graph::TensorNamedDataLayout,
24 | weight_layout: graph::TensorNamedDataLayout,
25 | ) -> Option>;
26 | }
27 |
28 | impl graph::Graph {
29 | #[objc::msg_send(convolution2DWithSourceTensor:weightsTensor:descriptor:name:)]
30 | pub fn conv_2d(
31 | &self,
32 | source: &graph::Tensor,
33 | weights: &graph::Tensor,
34 | descriptor: &Conv2dOpDesc,
35 | name: Option<&ns::String>,
36 | ) -> arc::R;
37 | }
38 |
39 | #[link(name = "mpsg", kind = "static")]
40 | unsafe extern "C" {
41 | static MPS_GRAPH_CONVOLUTION_2D_OP_DESCRIPTOR: &'static objc::Class;
42 | }
43 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/core.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, objc};
2 |
3 | define_obj_type!(pub Type(objc::Id));
4 |
5 | define_obj_type!(pub ShapedType(Type));
6 |
7 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
8 | #[repr(usize)]
9 | #[doc(alias = "MPSGraphTensorNamedDataLayout")]
10 | pub enum TensorNamedDataLayout {
11 | /// LayoutNCHW
12 | Nchw = 0,
13 |
14 | /// LayoutNHWC
15 | Nhwc = 1,
16 |
17 | /// LayoutOIHW
18 | Oihw = 2,
19 |
20 | /// LayoutHWIO
21 | Hwio = 3,
22 |
23 | /// LayoutCHW
24 | Chw = 4,
25 |
26 | /// LayoutHWC
27 | Hwc = 5,
28 |
29 | /// LayoutHW
30 | Hw = 6,
31 | }
32 |
33 | #[doc(alias = "MPSGraphPaddingStyle")]
34 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
35 | #[repr(usize)]
36 | pub enum PaddingStyle {
37 | Explicit = 0,
38 | TfValid = 1,
39 | TfSame = 2,
40 | ExplicitOffset = 3,
41 | OnnxSameLower,
42 | }
43 |
44 | /// Tensor Padding mode
45 | #[doc(alias = "MPSGraphPaddingMode")]
46 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
47 | #[repr(isize)]
48 | pub enum PaddingMode {
49 | Constant = 0,
50 | Reflect = 1,
51 | Symmetric = 2,
52 | ClampToEdge = 3,
53 | Zero = 4,
54 | Periodic = 5,
55 | AntiPeriodic = 6,
56 | }
57 |
58 | /// Reduction Mode
59 | #[doc(alias = "MPSGraphReductionMode")]
60 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
61 | #[repr(usize)]
62 | pub enum ReductionMode {
63 | Min = 0,
64 | Max = 1,
65 | Sum = 2,
66 | Product = 3,
67 | ArgumentMin = 4,
68 | ArgumentMax = 5,
69 | }
70 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/device.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_cls, define_obj_type, mtl, ns, objc};
2 |
3 | #[doc(alias = "MPSGraphDeviceType")]
4 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
5 | #[repr(u32)]
6 | pub enum DeviceType {
7 | Metal = 0,
8 | }
9 |
10 | define_obj_type!(
11 | #[doc(alias = "MPSGraphDevice")]
12 | pub Device(ns::Id)
13 | );
14 |
15 | impl Device {
16 | define_cls!(MPS_GRAPH_DEVICE);
17 |
18 | #[objc::msg_send(metalDevice)]
19 | pub fn metal_device(&self) -> Option<&mtl::Device>;
20 |
21 | #[objc::msg_send(type)]
22 | pub fn device_type(&self) -> DeviceType;
23 |
24 | #[objc::msg_send(deviceWithMTLDevice:)]
25 | pub fn with_mtl_device(mtl_device: &mtl::Device) -> arc::R;
26 | }
27 |
28 | #[link(name = "mpsg", kind = "static")]
29 | unsafe extern "C" {
30 | static MPS_GRAPH_DEVICE: &'static objc::Class;
31 | }
32 |
33 | #[cfg(test)]
34 | mod tests {
35 | use crate::{mps::graph, mtl};
36 |
37 | #[test]
38 | fn basics() {
39 | let device = graph::Device::with_mtl_device(&mtl::Device::sys_default().unwrap());
40 |
41 | assert_eq!(device.device_type(), graph::DeviceType::Metal);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/gather_ops.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, mps::graph, ns, objc};
2 |
3 | impl graph::Graph {
4 | #[objc::msg_send(gatherWithUpdatesTensor:indicesTensor:axis:batchDimensions:name:)]
5 | pub fn gather(
6 | &self,
7 | updates: &graph::Tensor,
8 | indices: &graph::Tensor,
9 | axis: ns::UInteger,
10 | batch_dimensions: ns::UInteger,
11 | name: Option<&ns::String>,
12 | ) -> arc::R;
13 |
14 | #[objc::msg_send(gatherAlongAxis:withUpdatesTensor:indicesTensor:name:)]
15 | pub fn gather_along_axis(
16 | &self,
17 | axis: ns::Integer,
18 | updates: &graph::Tensor,
19 | indices: &graph::Tensor,
20 | name: Option<&ns::String>,
21 | ) -> arc::R;
22 | }
23 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/matrix_multiplication_ops.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, mps::graph, ns, objc};
2 |
3 | impl graph::Graph {
4 | #[objc::msg_send(matrixMultiplicationWithPrimaryTensor:secondaryTensor:name:)]
5 | pub fn mat_mul(
6 | &self,
7 | primary: &graph::Tensor,
8 | secondary: &graph::Tensor,
9 | name: Option<&ns::String>,
10 | ) -> arc::R;
11 | }
12 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/normalization_ops.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, mps::graph, ns, objc};
2 |
3 | impl graph::Graph {
4 | #[objc::msg_send(meanOfTensor:axes:name:)]
5 | pub fn mean(
6 | &self,
7 | tensor: &graph::Tensor,
8 | axes: &ns::Array,
9 | name: Option<&ns::String>,
10 | ) -> arc::R;
11 |
12 | #[objc::msg_send(varianceOfTensor:axes:name:)]
13 | pub fn variance(
14 | &self,
15 | tensor: &graph::Tensor,
16 | axes: &ns::Array,
17 | name: Option<&ns::String>,
18 | ) -> arc::R;
19 |
20 | #[objc::msg_send(varianceOfTensor:meanTensor:axes:name:)]
21 | pub fn variance_mean(
22 | &self,
23 | tensor: &graph::Tensor,
24 | mean: &graph::Tensor,
25 | axes: &ns::Array,
26 | name: Option<&ns::String>,
27 | ) -> arc::R;
28 |
29 | #[objc::msg_send(normalizationWithTensor:meanTensor:varianceTensor:gammaTensor:betaTensor:epsilon:name:)]
30 | pub fn normalize(
31 | &self,
32 | tensor: &graph::Tensor,
33 | mean: &graph::Tensor,
34 | variance: &graph::Tensor,
35 | gamma: Option<&graph::Tensor>,
36 | beta: Option<&graph::Tensor>,
37 | epsilon: f32,
38 | name: Option<&ns::String>,
39 | ) -> arc::R;
40 | }
41 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/operation.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_obj_type, mps::graph, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "MPSGraphOperation")]
5 | pub Op(ns::Id)
6 | );
7 |
8 | impl Op {
9 | #[objc::msg_send(inputTensors)]
10 | pub fn input_tensors(&self) -> arc::R>;
11 |
12 | #[objc::msg_send(outputTensors)]
13 | pub fn output_tensors(&self) -> arc::R>;
14 |
15 | #[objc::msg_send(controlDependencies)]
16 | pub fn control_deps(&self) -> arc::R>;
17 |
18 | /// Graph on which the operation is defined
19 | #[objc::msg_send(graph)]
20 | pub fn graph(&self) -> arc::R;
21 |
22 | #[objc::msg_send(name)]
23 | pub fn name(&self) -> arc::R;
24 | }
25 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/resize_ops.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, mps, mps::graph, ns, objc};
2 |
3 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
4 | #[repr(usize)]
5 | pub enum ResizeMode {
6 | Nearest = 0,
7 | Bilinear = 1,
8 | }
9 |
10 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
11 | #[repr(usize)]
12 | pub enum ResizeNearestRoundingMode {
13 | RoundPreferCeil = 0,
14 | RoundPreferFloor = 1,
15 | Ceil = 2,
16 | Floor = 3,
17 | }
18 |
19 | impl graph::Graph {
20 | #[objc::msg_send(resizeTensor:size:mode:centerResult:alignCorners:layout:name:)]
21 | pub fn resize(
22 | &self,
23 | tensor: &graph::Tensor,
24 | size: &mps::Shape,
25 | mode: graph::ResizeMode,
26 | center_result: bool,
27 | align_corners: bool,
28 | layout: graph::TensorNamedDataLayout,
29 | name: Option<&ns::String>,
30 | ) -> arc::R;
31 | }
32 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/tensor.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, mps, mps::graph, ns, objc};
2 |
3 | define_obj_type!(pub Tensor(ns::Id));
4 | impl Tensor {
5 | #[objc::msg_send(shape)]
6 | pub fn shape(&self) -> Option<&mps::Shape>;
7 |
8 | #[objc::msg_send(dataType)]
9 | pub fn data_type(&self) -> mps::DType;
10 |
11 | #[objc::msg_send(operation)]
12 | pub fn op(&self) -> &graph::Op;
13 | }
14 |
--------------------------------------------------------------------------------
/cidre/src/mps/graph/tensor_data.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, mps, ns, objc};
2 |
3 | define_obj_type!(pub TensorData(ns::Id));
4 |
5 | impl TensorData {
6 | #[objc::msg_send(shape)]
7 | pub fn shape(&self) -> mps::Shape;
8 |
9 | #[objc::msg_send(dataType)]
10 | pub fn data_type(&self) -> mps::DType;
11 |
12 | #[objc::msg_send(device)]
13 | pub fn device(&self) -> &mps::graph::Device;
14 | }
15 |
--------------------------------------------------------------------------------
/cidre/src/mtk.rs:
--------------------------------------------------------------------------------
1 | mod texture_loader;
2 | pub use texture_loader::TextureLoader;
3 | #[cfg(feature = "blocks")]
4 | pub use texture_loader::TextureLoaderArrayCb;
5 | #[cfg(feature = "blocks")]
6 | pub use texture_loader::TextureLoaderCb;
7 | pub use texture_loader::TextureLoaderCubeLayout;
8 | pub use texture_loader::TextureLoaderOpt;
9 | pub use texture_loader::TextureLoaderOrigin;
10 |
--------------------------------------------------------------------------------
/cidre/src/mtl/allocation.rs:
--------------------------------------------------------------------------------
1 | use crate::{define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "MTLAllocation")]
5 | pub Allocation(ns::Id)
6 | );
7 |
8 | impl Allocation {
9 | #[objc::msg_send(allocatedSize)]
10 | #[objc::available(
11 | macos = 15.0,
12 | ios = 18.0,
13 | maccatalyst = 18.0,
14 | tvos = 18.0,
15 | visionos = 2.0
16 | )]
17 | pub fn allocated_size(&self) -> usize;
18 | }
19 |
--------------------------------------------------------------------------------
/cidre/src/mtl/capture_scope.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_obj_type, mtl, ns, objc};
2 |
3 | define_obj_type!(
4 | pub CaptureScope(ns::Id)
5 | );
6 |
7 | impl CaptureScope {
8 | #[objc::msg_send(beginScope)]
9 | pub fn begin(&mut self);
10 |
11 | #[objc::msg_send(endScope)]
12 | pub fn end(&mut self);
13 |
14 | #[objc::msg_send(label)]
15 | pub fn label(&self) -> Option>;
16 |
17 | #[objc::msg_send(setLabel:)]
18 | pub fn set_label(&mut self, val: Option<&ns::String>);
19 |
20 | #[objc::msg_send(device)]
21 | pub fn device(&self) -> arc::R;
22 |
23 | #[objc::msg_send(commandQueue)]
24 | pub fn cmd_queue(&self) -> Option>;
25 | }
26 |
--------------------------------------------------------------------------------
/cidre/src/mtl/fence.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_mtl, define_obj_type, mtl, ns, objc};
2 |
3 | define_obj_type!(
4 | /// An object that can capture, track, and manage resource dependencies
5 | /// across command encoders.
6 | ///
7 | /// Apple Documentation:
8 | /// - [Objective-C](https://developer.apple.com/documentation/metal/mtlfence?language=objc)
9 | /// - [Swift](https://developer.apple.com/documentation/metal/mtlfence?language=swift)
10 | #[doc(alias = "MTLFence")]
11 | pub Fence(ns::Id)
12 | );
13 |
14 | impl Fence {
15 | define_mtl!(set_label);
16 |
17 | #[objc::msg_send(device)]
18 | pub fn device(&self) -> arc::R;
19 |
20 | #[objc::msg_send(label)]
21 | pub fn label(&self) -> Option>;
22 | }
23 |
--------------------------------------------------------------------------------
/cidre/src/mtl/function_handle.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, mtl, ns, objc, objc::Obj};
2 |
3 | pub trait FnHandle: Obj {
4 | #[objc::msg_send(functionType)]
5 | fn fn_type(&self) -> mtl::FnType;
6 |
7 | #[objc::msg_send(name)]
8 | fn name(&self) -> arc::R;
9 |
10 | #[objc::msg_send(device)]
11 | fn device(&self) -> arc::R;
12 | }
13 |
--------------------------------------------------------------------------------
/cidre/src/nl.rs:
--------------------------------------------------------------------------------
1 | mod language;
2 | pub use language::Lang;
3 |
4 | mod language_recognizer;
5 | pub use language_recognizer::LangRecognizer;
6 |
7 | mod embedding;
8 | pub use embedding::Distance;
9 | pub use embedding::DistanceType;
10 | pub use embedding::Embedding;
11 |
--------------------------------------------------------------------------------
/cidre/src/ns/app/animation.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, objc};
2 |
3 | #[objc::protocol(NSAnimatablePropertyContainer)]
4 | pub trait AnimatablePropContainer: objc::Obj
5 | where
6 | Self: 'static,
7 | {
8 | #[objc::msg_send(animator)]
9 | fn animator(&self) -> arc::R;
10 | }
11 |
--------------------------------------------------------------------------------
/cidre/src/ns/app/button_cell.rs:
--------------------------------------------------------------------------------
1 | #[derive(Debug, Clone, Copy, Eq, PartialEq)]
2 | #[repr(usize)]
3 | pub enum ButtonType {
4 | #[doc(alias = "NSButtonTypeMomentaryLight")]
5 | MomentaryLight,
6 |
7 | #[doc(alias = "NSButtonTypePushOnPushOff")]
8 | PushOnPushOff,
9 |
10 | #[doc(alias = "NSButtonTypeToggle")]
11 | Toggle,
12 |
13 | #[doc(alias = "NSButtonTypeSwitch")]
14 | Switch,
15 |
16 | #[doc(alias = "NSButtonTypeRadio")]
17 | Radio,
18 |
19 | #[doc(alias = "NSButtonTypeMomentaryChange")]
20 | MomentaryChange,
21 |
22 | #[doc(alias = "NSButtonTypeOnOff")]
23 | OnOff,
24 |
25 | #[doc(alias = "NSButtonTypeMomentaryPushIn")]
26 | MomentaryPushIn,
27 |
28 | #[doc(alias = "NSButtonTypeAccelerator")]
29 | Accelerator,
30 |
31 | #[doc(alias = "NSButtonTypeMultiLevelAccelerator")]
32 | MultiLevelAccelerator,
33 | }
34 |
35 | #[doc(alias = "NSBezelStyle")]
36 | #[derive(Debug, Clone, Copy, Eq, PartialEq)]
37 | #[non_exhaustive]
38 | #[repr(usize)]
39 | pub enum BezelStyle {
40 | Automatic = 0,
41 | Push = 1,
42 | FlexiblePush = 2,
43 | Disclosure = 5,
44 | Circular = 7,
45 | HelpButton = 9,
46 | SmallSquare = 10,
47 | Toolbar = 11,
48 | AccessoryBarAction = 12,
49 | AccessoryBar = 13,
50 | PushDisclosure = 14,
51 | Badge = 15,
52 | }
53 |
--------------------------------------------------------------------------------
/cidre/src/ns/app/dock_tile.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "NSDockTile")]
5 | pub DockTile(ns::Id)
6 | );
7 |
8 | impl DockTile {
9 | #[objc::msg_send(size)]
10 | pub fn size(&self) -> ns::Size;
11 |
12 | #[objc::msg_send(contentView)]
13 | pub fn content_view(&self) -> Option>;
14 |
15 | #[objc::msg_send(setContentView:)]
16 | pub fn set_content_view(&mut self, val: Option<&ns::View>);
17 |
18 | #[objc::msg_send(display)]
19 | pub fn display(&mut self);
20 |
21 | #[objc::msg_send(showsApplicationBadge)]
22 | pub fn shows_app_badge(&self) -> bool;
23 |
24 | #[objc::msg_send(setShowsApplicationBadge:)]
25 | pub fn set_shows_app_badge(&mut self, val: bool);
26 |
27 | #[objc::msg_send(badgeLabel)]
28 | pub fn badge_label(&self) -> Option>;
29 |
30 | #[objc::msg_send(setBadgeLabel:)]
31 | pub fn set_badge_label(&mut self, val: Option<&ns::String>);
32 |
33 | #[objc::msg_send(owner)]
34 | pub fn owner(&self) -> arc::R;
35 | }
36 |
--------------------------------------------------------------------------------
/cidre/src/ns/app/graphics.rs:
--------------------------------------------------------------------------------
1 | use crate::cg;
2 |
3 | #[doc(alias = "NSWindowOrderingMode")]
4 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
5 | #[repr(isize)]
6 | pub enum WindowOrderingMode {
7 | Above = 1,
8 | Below = -1,
9 | Out = 0,
10 | }
11 |
12 | #[doc(alias = "NSWindowDepth")]
13 | #[derive(Debug, Eq, PartialEq, Copy, Clone)]
14 | #[repr(transparent)]
15 | pub struct WindowDepth(pub i32);
16 |
17 | impl WindowDepth {
18 | pub const RGB_24_BIT: Self = Self(0x208);
19 | pub const RGB_64_BIT: Self = Self(0x210);
20 | pub const RGB_128_BIT: Self = Self(0x220);
21 | }
22 |
23 | #[doc(alias = "NSEdgeInsets")]
24 | #[derive(Debug, PartialEq, Copy, Clone)]
25 | #[repr(C)]
26 | pub struct EdgeInsets {
27 | pub top: cg::Float,
28 | pub left: cg::Float,
29 | pub bottom: cg::Float,
30 | pub right: cg::Float,
31 | }
32 |
--------------------------------------------------------------------------------
/cidre/src/ns/app/menu.rs:
--------------------------------------------------------------------------------
1 | use crate::{arc, define_obj_type, ns, objc};
2 |
3 | define_obj_type!(
4 | #[doc(alias = "NSMenu")]
5 | pub Menu(ns::Id),
6 | NS_MENU
7 | );
8 |
9 | impl arc::A