├── .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 { 10 | #[objc::msg_send(initWithTitle:)] 11 | pub fn init_with_title(self, title: &ns::String) -> arc::R; 12 | } 13 | 14 | impl Menu { 15 | pub fn with_title(title: &ns::String) -> arc::R { 16 | Self::alloc().init_with_title(title) 17 | } 18 | 19 | #[objc::msg_send(title)] 20 | pub fn title(&self) -> arc::R; 21 | 22 | #[objc::msg_send(setTitle:)] 23 | pub fn set_title(&mut self, val: &ns::String); 24 | } 25 | 26 | unsafe extern "C" { 27 | static NS_MENU: &'static objc::Class; 28 | } 29 | 30 | #[cfg(test)] 31 | mod tests { 32 | use crate::ns; 33 | 34 | #[test] 35 | fn basics() { 36 | let mut menu = ns::Menu::with_title(ns::str!(c"Copy")); 37 | assert_eq!(menu.title().as_ref(), "Copy"); 38 | 39 | menu.set_title(ns::str!(c"")); 40 | assert!(menu.title().is_empty()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /cidre/src/ns/app/paragraph_style.rs: -------------------------------------------------------------------------------- 1 | use crate::define_opts; 2 | 3 | #[doc = "NSLineBreakMode"] 4 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 5 | #[repr(usize)] 6 | pub enum LineBreakMode { 7 | WordWrapping = 0, 8 | CharWrapping = 1, 9 | Clipping = 2, 10 | TruncatingHead = 3, 11 | TruncatingTail = 4, 12 | TruncatingMiddle = 5, 13 | } 14 | 15 | define_opts!( 16 | #[doc(alias = "NSLineBreakStrategy")] 17 | pub LineBreakStrategy(usize) 18 | ); 19 | 20 | impl LineBreakStrategy { 21 | pub const NONE: Self = Self(0); 22 | pub const PUSH_OUT: Self = Self(1 << 0); 23 | pub const HANGUL_WORD_PRIORITY: Self = Self(1 << 1); 24 | pub const STANDARD: Self = Self(0xFFFF); 25 | } 26 | -------------------------------------------------------------------------------- /cidre/src/ns/app/responder.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | pub Responder(ns::Id), 5 | NS_RESPONDER 6 | ); 7 | 8 | #[link(name = "app", kind = "static")] 9 | unsafe extern "C" { 10 | static NS_RESPONDER: &'static objc::Class; 11 | } 12 | -------------------------------------------------------------------------------- /cidre/src/ns/app/sound.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSSound")] 5 | pub Sound(ns::Id) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ns/app/status_bar.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, cg, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSStatusBar")] 5 | pub StatusBar(ns::Id), 6 | NS_STATUS_BAR 7 | ); 8 | 9 | impl StatusBar { 10 | #[objc::msg_send(systemStatusBar)] 11 | pub fn system() -> arc::R; 12 | 13 | #[objc::msg_send(isVertical)] 14 | pub fn is_vertical(&self) -> bool; 15 | 16 | #[objc::msg_send(thickness)] 17 | pub fn thickness(&self) -> cg::Float; 18 | } 19 | 20 | #[link(name = "app", kind = "static")] 21 | unsafe extern "C" { 22 | static NS_STATUS_BAR: &'static objc::Class; 23 | } 24 | -------------------------------------------------------------------------------- /cidre/src/ns/app/text.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSText")] 5 | pub Text(ns::View) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ns/app/text_field_cell.rs: -------------------------------------------------------------------------------- 1 | #[doc = "NSTextFieldBezelStyle"] 2 | #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] 3 | #[repr(usize)] 4 | pub enum TextFieldBezelStyle { 5 | Square = 0, 6 | Rounded = 1, 7 | } 8 | -------------------------------------------------------------------------------- /cidre/src/ns/app/text_view.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSTextView")] 5 | pub TextView(ns::Text) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ns/app/window_controller.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc}; 2 | 3 | impl arc::A { 4 | #[objc::msg_send(initWithWindow:)] 5 | pub fn init_with_window(self, window: Option<&ns::Window>) -> arc::R; 6 | } 7 | 8 | define_obj_type!( 9 | pub WindowController(ns::Responder), 10 | NS_WINDOW_CONTROLLER 11 | ); 12 | 13 | impl WindowController { 14 | pub fn with_window(window: Option<&ns::Window>) -> arc::R { 15 | Self::alloc().init_with_window(window) 16 | } 17 | 18 | #[objc::msg_send(shouldCascadeWindows)] 19 | pub fn should_cascade_windows(&self) -> bool; 20 | 21 | #[objc::msg_send(setShouldCascadeWindows:)] 22 | pub fn set_should_cascade_windows(&mut self, val: bool); 23 | 24 | #[objc::msg_send(showWindow:)] 25 | pub fn show_window(&self, sender: Option<&ns::Id>); 26 | 27 | #[objc::msg_send(close)] 28 | pub fn close(&self); 29 | 30 | #[objc::msg_send(dismissController:)] 31 | pub fn dismiss_controller(&self, sender: Option<&ns::Id>); 32 | } 33 | 34 | #[link(name = "app", kind = "static")] 35 | unsafe extern "C" { 36 | static NS_WINDOW_CONTROLLER: &'static objc::Class; 37 | } 38 | -------------------------------------------------------------------------------- /cidre/src/ns/formatter.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSFormatter")] 5 | pub Formatter(ns::Id) 6 | ); 7 | 8 | impl Formatter { 9 | #[objc::msg_send(stringForObjectValue:)] 10 | pub fn string_for_obj_value(&self, obj: &ns::Id) -> Option>; 11 | } 12 | -------------------------------------------------------------------------------- /cidre/src/ns/geometry.rs: -------------------------------------------------------------------------------- 1 | use crate::cg; 2 | 3 | #[doc(alias = "NSPoint")] 4 | pub type Point = cg::Point; 5 | 6 | #[doc(alias = "NSSize")] 7 | pub type Size = cg::Size; 8 | 9 | #[doc(alias = "NSRect")] 10 | pub type Rect = cg::Rect; 11 | -------------------------------------------------------------------------------- /cidre/src/ns/keyed_archiver.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_cls, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSKeyedArchiver")] 5 | pub KeyedArchiver(ns::Coder) 6 | ); 7 | 8 | impl KeyedArchiver { 9 | define_cls!(NS_KEYED_ARCHIVER); 10 | 11 | #[objc::msg_send(archivedDataWithRootObject:requiringSecureCoding:error:)] 12 | pub unsafe fn archived_data_with_root_obj_err<'ear>( 13 | obj: &ns::Id, 14 | secure_coding: bool, 15 | err: *mut Option<&'ear ns::Error>, 16 | ) -> Option>; 17 | 18 | #[inline] 19 | pub fn archived_data_with_root_obj<'ear>( 20 | obj: &ns::Id, 21 | secure_coding: bool, 22 | ) -> Result, &'ear ns::Error> { 23 | ns::if_none(|err| unsafe { Self::archived_data_with_root_obj_err(obj, secure_coding, err) }) 24 | } 25 | } 26 | 27 | #[link(name = "ns", kind = "static")] 28 | unsafe extern "C" { 29 | static NS_KEYED_ARCHIVER: &'static objc::Class; 30 | } 31 | 32 | #[cfg(test)] 33 | mod tests { 34 | use crate::ns; 35 | 36 | #[test] 37 | fn basics() { 38 | let s = ns::str!(c"value"); 39 | let data = ns::KeyedArchiver::archived_data_with_root_obj(s, false).unwrap(); 40 | assert!(!data.is_empty()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /cidre/src/ns/keyed_unarchiver.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_cls, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSKeyedUnarchiver")] 5 | pub KeyedUnarchiver(ns::Coder) 6 | ); 7 | 8 | impl KeyedUnarchiver { 9 | define_cls!(NS_KEYED_UNARCHIVER); 10 | 11 | #[objc::msg_send(unarchivedObjectOfClass:fromData:error:)] 12 | pub unsafe fn unarchived_obj_of_cls_err<'a, 'ear, T: objc::Obj>( 13 | cls: &'a objc::Class, 14 | data: &'a ns::Data, 15 | err: *mut Option<&'ear ns::Error>, 16 | ) -> Option>; 17 | 18 | #[inline] 19 | pub fn unarchived_obj_of_cls<'a, 'ear, T: objc::Obj>( 20 | cls: &'a objc::Class, 21 | data: &'a ns::Data, 22 | ) -> Result, &'ear ns::Error> { 23 | ns::if_none(|err| unsafe { Self::unarchived_obj_of_cls_err(cls, data, err) }) 24 | } 25 | } 26 | 27 | #[link(name = "ns", kind = "static")] 28 | unsafe extern "C" { 29 | static NS_KEYED_UNARCHIVER: &'static objc::Class; 30 | } 31 | 32 | #[cfg(test)] 33 | mod tests { 34 | use crate::ns; 35 | 36 | #[test] 37 | fn basics() { 38 | let a = ns::String::with_str("data"); 39 | let data = ns::KeyedArchiver::archived_data_with_root_obj(&a, true).unwrap(); 40 | let b = ns::KeyedUnarchiver::unarchived_obj_of_cls(ns::String::cls(), &data).unwrap(); 41 | assert_eq!(&a, &b); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /cidre/src/ns/locale.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_cls, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSLocale")] 5 | pub Locale(ns::Id) 6 | ); 7 | 8 | unsafe impl Send for Locale {} 9 | unsafe impl Sync for Locale {} 10 | 11 | impl arc::A { 12 | #[objc::msg_send(initWithLocaleIdentifier:)] 13 | pub fn init_with_locale_id(self, id: &ns::String) -> arc::R; 14 | } 15 | 16 | impl Locale { 17 | define_cls!(NS_LOCALE); 18 | 19 | #[objc::msg_send(availableLocaleIdentifiers)] 20 | pub fn available_locale_ids() -> arc::R>; 21 | 22 | pub fn with_locale_id(id: &ns::String) -> arc::R { 23 | Self::alloc().init_with_locale_id(id) 24 | } 25 | 26 | #[objc::msg_send(autoupdatingCurrentLocale)] 27 | pub fn autoupdating_current_locale() -> arc::R; 28 | 29 | #[objc::msg_send(currentLocale)] 30 | pub fn current_locale() -> arc::R; 31 | 32 | #[objc::msg_send(systemLocale)] 33 | pub fn sys_locale() -> arc::R; 34 | 35 | #[objc::msg_send(languageCode)] 36 | pub fn lang_code(&self) -> arc::R; 37 | 38 | #[objc::msg_send(languageIdentifier)] 39 | pub fn lang_id(&self) -> arc::R; 40 | 41 | #[objc::msg_send(regionCode)] 42 | pub fn region_code(&self) -> Option>; 43 | } 44 | 45 | #[link(name = "ns", kind = "static")] 46 | unsafe extern "C" { 47 | static NS_LOCALE: &'static objc::Class; 48 | } 49 | -------------------------------------------------------------------------------- /cidre/src/ns/null.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_cls, define_obj_type, ns, objc}; 2 | 3 | #[cfg(feature = "cf")] 4 | use crate::cf; 5 | 6 | define_obj_type!( 7 | #[doc(alias = "NSNull")] 8 | pub Null(ns::Id) 9 | ); 10 | 11 | unsafe impl Send for Null {} 12 | 13 | impl Null { 14 | define_cls!(NS_NULL); 15 | 16 | /// The singleton instance of [`ns::Null`]. Equal to [`cf::Null::value()`]. 17 | /// 18 | /// use cf::Null::value if possible. 19 | #[objc::msg_send(null)] 20 | pub fn value() -> arc::R; 21 | 22 | #[cfg(feature = "cf")] 23 | #[inline] 24 | pub fn as_cf(&self) -> &cf::Null { 25 | unsafe { std::mem::transmute(self) } 26 | } 27 | } 28 | 29 | impl Default for arc::R { 30 | fn default() -> Self { 31 | Null::value() 32 | } 33 | } 34 | 35 | impl AsRef for Null { 36 | fn as_ref(&self) -> &cf::Null { 37 | self.as_cf() 38 | } 39 | } 40 | 41 | impl AsRef for Null { 42 | fn as_ref(&self) -> &cf::Type { 43 | self.as_cf() 44 | } 45 | } 46 | 47 | #[link(name = "ns", kind = "static")] 48 | unsafe extern "C" { 49 | static NS_NULL: &'static objc::Class; 50 | } 51 | -------------------------------------------------------------------------------- /cidre/src/ns/progress.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSProgress")] 5 | pub Progress(ns::Id) 6 | ); 7 | 8 | impl Progress { 9 | #[objc::msg_send(isCancelled)] 10 | pub fn is_cancelled(&self) -> bool; 11 | 12 | #[objc::msg_send(isPaused)] 13 | pub fn is_paused(&self) -> bool; 14 | 15 | #[objc::msg_send(isIndeterminate)] 16 | pub fn is_indeterminate(&self) -> bool; 17 | 18 | #[objc::msg_send(fractionCompleted)] 19 | pub fn fraction_completed(&self) -> f64; 20 | 21 | #[objc::msg_send(isFinished)] 22 | pub fn is_finished(&self) -> bool; 23 | 24 | #[objc::msg_send(cancel)] 25 | pub fn cancel(&mut self); 26 | 27 | #[objc::msg_send(pause)] 28 | pub fn pause(&mut self); 29 | 30 | #[objc::msg_send(resume)] 31 | pub fn resume(&mut self); 32 | } 33 | -------------------------------------------------------------------------------- /cidre/src/ns/stream.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns, objc}; 2 | 3 | #[doc(alias = "NSStreamStatus")] 4 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] 5 | #[repr(usize)] 6 | pub enum Status { 7 | NotOpen = 0, 8 | Opening = 1, 9 | Open = 2, 10 | Reading = 3, 11 | Writing = 4, 12 | AtEnd = 5, 13 | Closed = 6, 14 | Error = 7, 15 | } 16 | 17 | define_obj_type!( 18 | pub Stream(ns::Id) 19 | ); 20 | 21 | impl Stream { 22 | #[objc::msg_send(open)] 23 | pub fn open(&mut self); 24 | 25 | #[objc::msg_send(close)] 26 | pub fn close(&mut self); 27 | } 28 | 29 | define_obj_type!( 30 | pub InputStream(Stream) 31 | ); 32 | 33 | define_obj_type!( 34 | pub OutputStream(Stream) 35 | ); 36 | -------------------------------------------------------------------------------- /cidre/src/ns/timer.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSTimer")] 5 | pub Timer(ns::Id), 6 | NS_TIMER 7 | ); 8 | 9 | impl Timer { 10 | #[objc::msg_send(timeInterval)] 11 | pub fn time_interval(&self) -> ns::TimeInterval; 12 | 13 | #[objc::msg_send(invalidate)] 14 | pub fn invalidate(&self); 15 | 16 | #[objc::msg_send(isValid)] 17 | pub fn is_valid(&self) -> bool; 18 | 19 | #[objc::msg_send(fire)] 20 | pub fn fire(&self); 21 | } 22 | 23 | #[link(name = "ns", kind = "static")] 24 | unsafe extern "C" { 25 | static NS_TIMER: &'static objc::Class; 26 | } 27 | -------------------------------------------------------------------------------- /cidre/src/ns/uuid.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "NSUUID")] 5 | pub Uuid(ns::Id), NS_UUID 6 | ); 7 | 8 | unsafe impl Send for Uuid {} 9 | 10 | impl Uuid { 11 | #[objc::msg_send(UUIDString)] 12 | pub fn string(&self) -> arc::R; 13 | } 14 | 15 | #[link(name = "ns", kind = "static")] 16 | unsafe extern "C" { 17 | static NS_UUID: &'static objc::Class; 18 | } 19 | 20 | #[cfg(test)] 21 | mod tests { 22 | use crate::ns; 23 | 24 | #[test] 25 | fn basics() { 26 | let uuid = ns::Uuid::new(); 27 | 28 | let string = uuid.string(); 29 | assert!(!string.is_empty()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /cidre/src/ns/xpc.rs: -------------------------------------------------------------------------------- 1 | mod connection; 2 | pub use connection::Connection; 3 | pub use connection::ConnectionOptions; 4 | pub use connection::ProxyCreating; 5 | pub use connection::ProxyCreatingImpl; 6 | -------------------------------------------------------------------------------- /cidre/src/nw/connection_group.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "nw_connection_group")] 5 | #[doc(alias = "nw_connection_group_t")] 6 | pub ConnectionGroup(ns::Id) 7 | ); 8 | -------------------------------------------------------------------------------- /cidre/src/nw/object.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "nw_object")] 5 | pub Obj(ns::Id) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/nw/protocol_options.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "nw_protocol_definition")] 5 | #[doc(alias = "nw_protocol_definition_t")] 6 | pub ProtocolDefinition(ns::Id) 7 | ); 8 | 9 | define_obj_type!( 10 | #[doc(alias = "nw_protocol_options")] 11 | #[doc(alias = "nw_protocol_options_t")] 12 | pub ProtocolOpts(ns::Id) 13 | ); 14 | 15 | define_obj_type!( 16 | #[doc(alias = "nw_protocol_metadata")] 17 | #[doc(alias = "nw_protocol_metadata_t")] 18 | pub ProtocolMetadata(ns::Id) 19 | ); 20 | -------------------------------------------------------------------------------- /cidre/src/nw/proxy_config.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "nw_proxy_config")] 5 | #[doc(alias = "nw_proxy_config_t")] 6 | pub ProxyCfg(ns::Id) 7 | ); 8 | 9 | define_obj_type!( 10 | #[doc(alias = "nw_relay_hop")] 11 | #[doc(alias = "nw_relay_hop_t")] 12 | pub RelayHop(ns::Id) 13 | ); 14 | -------------------------------------------------------------------------------- /cidre/src/nw/resolver_config.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "nw_resolver_config")] 5 | #[doc(alias = "nw_resolver_config_t")] 6 | pub ResolverCfg(ns::Id) 7 | ); 8 | -------------------------------------------------------------------------------- /cidre/src/nw/txt_record.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "nw_txt_record")] 5 | #[doc(alias = "nw_txt_record_t")] 6 | pub TxtRecord(ns::Id) 7 | ); 8 | -------------------------------------------------------------------------------- /cidre/src/objc/autorelease_pool.rs: -------------------------------------------------------------------------------- 1 | use std::ffi::c_void; 2 | 3 | /// ``` 4 | /// use cidre::objc; 5 | /// 6 | /// let _pp = objc::AutoreleasePoolPage::push(); 7 | /// 8 | /// ``` 9 | #[repr(transparent)] 10 | pub struct AutoreleasePoolPage(*const c_void); 11 | 12 | impl AutoreleasePoolPage { 13 | #[must_use] 14 | pub fn push() -> AutoreleasePoolPage { 15 | unsafe { objc_autoreleasePoolPush() } 16 | } 17 | } 18 | 19 | impl Drop for AutoreleasePoolPage { 20 | fn drop(&mut self) { 21 | unsafe { objc_autoreleasePoolPop(self.0) } 22 | } 23 | } 24 | 25 | #[link(name = "objc", kind = "dylib")] 26 | unsafe extern "C" { 27 | fn objc_autoreleasePoolPush() -> AutoreleasePoolPage; 28 | fn objc_autoreleasePoolPop(ctx: *const c_void); 29 | } 30 | -------------------------------------------------------------------------------- /cidre/src/objc/ns.rs: -------------------------------------------------------------------------------- 1 | #[doc(alias = "NSInteger")] 2 | pub type Integer = isize; 3 | 4 | #[doc(alias = "NSUInteger")] 5 | pub type UInteger = usize; 6 | -------------------------------------------------------------------------------- /cidre/src/os/lock.rs: -------------------------------------------------------------------------------- 1 | #[repr(C)] 2 | pub struct UnfairLock { 3 | internal: u32, 4 | } 5 | 6 | impl UnfairLock { 7 | pub fn new() -> Self { 8 | Self { internal: 0 } 9 | } 10 | 11 | #[inline] 12 | pub fn lock(&self) { 13 | unsafe { os_unfair_lock_lock(self) } 14 | } 15 | 16 | #[inline] 17 | pub fn try_lock(&self) -> bool { 18 | unsafe { os_unfair_lock_trylock(self) } 19 | } 20 | 21 | #[inline] 22 | pub fn unlock(&self) { 23 | unsafe { os_unfair_lock_unlock(self) } 24 | } 25 | 26 | #[inline] 27 | pub fn assert_owner(&self) { 28 | unsafe { os_unfair_lock_assert_owner(self) } 29 | } 30 | 31 | #[inline] 32 | pub fn assert_not_owner(&self) { 33 | unsafe { os_unfair_lock_assert_not_owner(self) } 34 | } 35 | } 36 | 37 | impl Default for UnfairLock { 38 | fn default() -> Self { 39 | Self::new() 40 | } 41 | } 42 | 43 | unsafe extern "C-unwind" { 44 | fn os_unfair_lock_lock(lock: &UnfairLock); 45 | fn os_unfair_lock_trylock(lock: &UnfairLock) -> bool; 46 | fn os_unfair_lock_unlock(lock: &UnfairLock); 47 | fn os_unfair_lock_assert_owner(lock: &UnfairLock); 48 | fn os_unfair_lock_assert_not_owner(lock: &UnfairLock); 49 | } 50 | -------------------------------------------------------------------------------- /cidre/src/os/proc.rs: -------------------------------------------------------------------------------- 1 | #[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))] 2 | #[inline] 3 | pub fn available_memory() -> usize { 4 | unsafe { os_proc_available_memory() } 5 | } 6 | 7 | unsafe extern "C-unwind" { 8 | #[cfg(any(target_os = "ios", target_os = "watchos", target_os = "tvos"))] 9 | fn os_proc_available_memory() -> usize; 10 | } 11 | -------------------------------------------------------------------------------- /cidre/src/sc.rs: -------------------------------------------------------------------------------- 1 | pub mod content_sharing_picker; 2 | pub use content_sharing_picker::Cfg as ContentSharingPickerCfg; 3 | pub use content_sharing_picker::Mode as ContentSharingPickerMode; 4 | pub use content_sharing_picker::Observer as ContentSharingPickerObserver; 5 | pub use content_sharing_picker::ObserverImpl as ContentSharingPickerObserverImpl; 6 | pub use content_sharing_picker::Picker as ContentSharingPicker; 7 | 8 | pub mod stream; 9 | 10 | pub use stream::CaptureResolution; 11 | pub use stream::Cfg as StreamCfg; 12 | pub use stream::ContentFilter; 13 | pub use stream::Delegate as StreamDelegate; 14 | pub use stream::DelegateImpl as StreamDelegateImpl; 15 | pub use stream::FrameInfo; 16 | pub use stream::FrameStatus; 17 | pub use stream::Output as StreamOutput; 18 | pub use stream::OutputImpl as StreamOutputImpl; 19 | pub use stream::OutputType; 20 | pub use stream::PresenterOverlayAlertSetting; 21 | pub use stream::Stream; 22 | 23 | mod screenshot_manager; 24 | pub use screenshot_manager::ScreenshotManager; 25 | 26 | pub mod shareable_content; 27 | pub use shareable_content::Display; 28 | pub use shareable_content::RunningApp; 29 | pub use shareable_content::ShareableContent; 30 | pub use shareable_content::Style as ShareableContentStyle; 31 | pub use shareable_content::Window; 32 | 33 | pub mod recording_output; 34 | pub use recording_output::Delegate as RecordingOutputDelegate; 35 | pub use recording_output::DelegateImpl as RecordingOutputDelegateImpl; 36 | pub use recording_output::RecordingOutput; 37 | pub use recording_output::RecordingOutputCfg; 38 | 39 | pub mod error; 40 | -------------------------------------------------------------------------------- /cidre/src/sec.rs: -------------------------------------------------------------------------------- 1 | mod base; 2 | pub use base::*; 3 | 4 | pub mod certificate; 5 | pub use certificate::oids as cert_oids; 6 | #[cfg(target_os = "macos")] 7 | pub use certificate::prop_keys; 8 | #[cfg(target_os = "macos")] 9 | pub use certificate::prop_types; 10 | 11 | pub mod item; 12 | pub use item::class; 13 | pub use item::class_key; 14 | pub use item::match_keys; 15 | pub use item::match_limit; 16 | pub use item::matching as item_matching; 17 | pub use item::return_data; 18 | 19 | pub mod identity; 20 | 21 | pub mod policy; 22 | pub use policy::Policy; 23 | -------------------------------------------------------------------------------- /cidre/src/sec/identity.rs: -------------------------------------------------------------------------------- 1 | use crate::{cf, sec}; 2 | 3 | impl sec::Identity { 4 | pub fn type_id() -> cf::TypeId { 5 | unsafe { SecIdentityGetTypeID() } 6 | } 7 | } 8 | 9 | unsafe extern "C" { 10 | fn SecIdentityGetTypeID() -> cf::TypeId; 11 | } 12 | -------------------------------------------------------------------------------- /cidre/src/sn.rs: -------------------------------------------------------------------------------- 1 | use crate::define_obj_type; 2 | use crate::ns; 3 | 4 | mod types; 5 | pub use types::Id; 6 | 7 | mod error; 8 | pub use error::Code as ErrorCode; 9 | 10 | define_obj_type!( 11 | #[doc(alias = "SNRequest")] 12 | pub Request(ns::Id) 13 | ); 14 | 15 | mod result; 16 | pub use result::Result; 17 | pub use result::ResultsObserving; 18 | pub use result::ResultsObservingImpl; 19 | 20 | mod analyzer; 21 | pub use analyzer::AudioFileAnalyzer; 22 | pub use analyzer::AudioStreamAnalyzer; 23 | 24 | mod time_duration_constraint; 25 | pub use time_duration_constraint::Constraint as TimeDurationConstraint; 26 | pub use time_duration_constraint::Type as TimeDurationConstraintType; 27 | 28 | mod classify_sound_request; 29 | pub use classify_sound_request::ClassifySoundRequest; 30 | 31 | mod classification_result; 32 | pub use classification_result::Classification; 33 | pub use classification_result::ClassificationResult; 34 | -------------------------------------------------------------------------------- /cidre/src/sn/classification_result.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, cm, define_obj_type, ns, objc, sn}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "SNClassification")] 5 | pub Classification(ns::Id) 6 | ); 7 | 8 | impl Classification { 9 | #[objc::msg_send(identifier)] 10 | pub fn id(&self) -> arc::R; 11 | 12 | #[objc::msg_send(confidence)] 13 | pub fn confidence(&self) -> f64; 14 | } 15 | 16 | define_obj_type!( 17 | #[doc(alias = "SNClassificationResult")] 18 | pub ClassificationResult(sn::Result), 19 | SN_CLASSIFICATION_RESULT 20 | ); 21 | 22 | impl ClassificationResult { 23 | #[objc::msg_send(classifications)] 24 | pub fn classifications(&self) -> arc::R>; 25 | 26 | #[objc::msg_send(timeRange)] 27 | pub fn time_range(&self) -> cm::TimeRange; 28 | 29 | #[objc::msg_send(classificationForIdentifier:)] 30 | pub fn classification_for_id(&self, id: &ns::String) -> Option>; 31 | } 32 | 33 | unsafe extern "C" { 34 | static SN_CLASSIFICATION_RESULT: &'static objc::Class; 35 | } 36 | -------------------------------------------------------------------------------- /cidre/src/sn/error.rs: -------------------------------------------------------------------------------- 1 | use crate::ns; 2 | 3 | impl ns::ErrorDomain { 4 | pub fn sound_analysis() -> &'static Self { 5 | unsafe { SNErrorDomain } 6 | } 7 | } 8 | 9 | #[link(name = "SoundAnalysis", kind = "framework")] 10 | unsafe extern "C" { 11 | static SNErrorDomain: &'static ns::ErrorDomain; 12 | } 13 | 14 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] 15 | #[repr(isize)] 16 | pub enum Code { 17 | /// An error that represents a failure that no other error handles. 18 | #[doc(alias = "SNErrorCodeUnknownError")] 19 | UnknownError = 1, 20 | 21 | /// An error that occurs when the framework fails to analyze audio. 22 | #[doc(alias = "SNErrorCodeOperationFailed")] 23 | OpFailed = 2, 24 | 25 | /// An error that indicates the audio data’s format isn’t valid. 26 | #[doc(alias = "SNErrorCodeInvalidFormat")] 27 | InvalidFormat = 3, 28 | 29 | /// An error that indicates the sound classifier’s underlying Core ML model is an invalid model type. 30 | #[doc(alias = "SNErrorCodeInvalidModel")] 31 | InvalidModel = 4, 32 | 33 | /// An error that indicates an audio file is invalid. 34 | #[doc(alias = "SNErrorCodeInvalidFile")] 35 | InvalidFile = 5, 36 | } 37 | -------------------------------------------------------------------------------- /cidre/src/sn/result.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns, objc, sn}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "SNResult")] 5 | pub Result(ns::Id) 6 | ); 7 | 8 | #[objc::protocol(SNResultsObserving)] 9 | pub trait ResultsObserving: objc::Obj { 10 | #[objc::msg_send(request:didProduceResult:)] 11 | fn request_did_produce_result(&mut self, request: &sn::Request, result: &sn::Result); 12 | 13 | #[objc::optional] 14 | #[objc::msg_send(request:didFailWithError:)] 15 | fn request_did_fail_with_err(&mut self, request: &sn::Request, error: &ns::Error); 16 | 17 | #[objc::optional] 18 | #[objc::msg_send(requestDidComplete:)] 19 | fn request_did_complete(&mut self, request: &sn::Request); 20 | } 21 | -------------------------------------------------------------------------------- /cidre/src/sn/types.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "SNClassifierIdentifier")] 5 | pub Id(ns::Id) 6 | ); 7 | 8 | impl Id { 9 | #[inline] 10 | pub fn v1() -> &'static Id { 11 | unsafe { SNClassifierIdentifierVersion1 } 12 | } 13 | } 14 | 15 | #[link(name = "SoundAnalysis", kind = "framework")] 16 | unsafe extern "C" { 17 | static SNClassifierIdentifierVersion1: &'static Id; 18 | } 19 | -------------------------------------------------------------------------------- /cidre/src/sys.rs: -------------------------------------------------------------------------------- 1 | pub mod _types; 2 | 3 | pub use _types::Pid; 4 | 5 | pub mod termios; 6 | -------------------------------------------------------------------------------- /cidre/src/sys/_types.rs: -------------------------------------------------------------------------------- 1 | use std::ffi::c_long; 2 | 3 | pub use crate::mach::Port as MachPort; 4 | 5 | pub type Pid = i32; 6 | 7 | #[doc(alias = "__darwin_time_t")] 8 | pub type DarwinTime = c_long; 9 | 10 | #[doc(alias = "timespec")] 11 | #[derive(PartialEq, Eq, Debug, Copy, Clone)] 12 | #[repr(C)] 13 | pub struct TimeSpec { 14 | pub tv_sec: DarwinTime, 15 | pub tv_nsec: c_long, 16 | } 17 | -------------------------------------------------------------------------------- /cidre/src/time.rs: -------------------------------------------------------------------------------- 1 | #[doc(alias = "clockid_t")] 2 | #[derive(Clone, Copy, Debug, Eq, PartialEq)] 3 | #[repr(i32)] 4 | pub enum Clock { 5 | #[doc(alias = "CLOCK_REALTIME")] 6 | RealTime = 0, 7 | 8 | #[doc(alias = "CLOCK_MONOTONIC")] 9 | Monotonic = 6, 10 | 11 | #[doc(alias = "CLOCK_MONOTONIC_RAW")] 12 | MonotonicRaw = 4, 13 | 14 | #[doc(alias = "CLOCK_MONOTONIC_RAW_APPROX")] 15 | MonotonicRawApprox = 5, 16 | // use this for get time 17 | #[doc(alias = "CLOCK_UPTIME_RAW")] 18 | UptimeRaw = 8, 19 | 20 | #[doc(alias = "CLOCK_UPTIME_RAW_APPROX")] 21 | UptimeRawApprox = 9, 22 | 23 | #[doc(alias = "CLOCK_PROCESS_CPUTIME_ID")] 24 | ProcessCpuTimeId = 12, 25 | 26 | #[doc(alias = "CLOCK_THREAD_CPUTIME_ID")] 27 | ThreadCpuTimeId = 16, 28 | } 29 | 30 | impl Clock { 31 | #[inline] 32 | pub fn time_nsec_np(&self) -> u64 { 33 | unsafe { clock_gettime_nsec_np(*self) } 34 | } 35 | } 36 | 37 | unsafe extern "C-unwind" { 38 | fn clock_gettime_nsec_np(clock_id: Clock) -> u64; 39 | } 40 | -------------------------------------------------------------------------------- /cidre/src/ui/blur_effect.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_cls, define_obj_type, objc, ui}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UIBlurEffect")] 5 | pub BlurEffect(ui::VisualEffect) 6 | ); 7 | 8 | #[cfg(not(target_os = "watchos"))] 9 | impl BlurEffect { 10 | define_cls!(UI_BLUR_EFFECT); 11 | 12 | #[objc::msg_send(effectWithStyle:)] 13 | pub fn with_style(style: ui::BlurEffectStyle) -> arc::R; 14 | } 15 | 16 | #[doc(alias = "UIBlurEffectStyle")] 17 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] 18 | #[repr(isize)] 19 | pub enum BlurEffectStyle { 20 | ExtraLight, 21 | Light, 22 | ExtraDark, 23 | Regular, 24 | Prominent, 25 | SysUltraThinMaterial, 26 | SysThinMaterial, 27 | SysMaterial, 28 | SysThickMaterial, 29 | SysChromeMaterial, 30 | SysUltraThinMaterialLight, 31 | SysThinMaterialLight, 32 | SysMaterialLight, 33 | SysThickMaterialLight, 34 | SysChromeMaterialLight, 35 | SysUltraThinMaterialDark, 36 | SysThinMaterialDark, 37 | SysMaterialDark, 38 | SysThickMaterialDark, 39 | SysChromeMaterialDark, 40 | } 41 | 42 | #[link(name = "ui", kind = "static")] 43 | unsafe extern "C" { 44 | static UI_BLUR_EFFECT: &'static objc::Class; 45 | } 46 | -------------------------------------------------------------------------------- /cidre/src/ui/command.rs: -------------------------------------------------------------------------------- 1 | use crate::define_opts; 2 | 3 | define_opts!( 4 | #[doc(alias = "UIKeyModifierFlags")] 5 | pub KeyModFlags(isize) 6 | ); 7 | 8 | impl KeyModFlags { 9 | /// This bit indicates CapsLock 10 | pub const ALPHA_SHIFT: Self = Self(1 << 16); 11 | pub const SHIFT: Self = Self(1 << 17); 12 | pub const CTRL: Self = Self(1 << 18); 13 | pub const ALT: Self = Self(1 << 19); 14 | pub const CMD: Self = Self(1 << 20); 15 | pub const NUM_PAD: Self = Self(1 << 21); 16 | } 17 | -------------------------------------------------------------------------------- /cidre/src/ui/event.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, define_opts, ns, objc}; 2 | 3 | #[doc(alias = "UIEventType")] 4 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] 5 | #[repr(isize)] 6 | #[non_exhaustive] 7 | pub enum EventType { 8 | Touches, 9 | Motion, 10 | RemoteControl, 11 | Presses, 12 | Scroll = 10, 13 | Hover = 11, 14 | Transform = 14, 15 | } 16 | 17 | #[doc(alias = "UIEventSubtype")] 18 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] 19 | #[repr(isize)] 20 | #[non_exhaustive] 21 | pub enum EventSubType { 22 | None = 0, 23 | MotionSnake = 1, 24 | RemoteControlPlay = 100, 25 | RemoteControlPause = 101, 26 | RemoteControlStop = 102, 27 | RemoteControlTogglePlayPause = 103, 28 | RemoteControlNextTrack = 104, 29 | RemoteControlPrevTrack = 105, 30 | RemoteControlBeginSeekingBackward = 106, 31 | RemoteControlEndSeekingBackward = 107, 32 | RemoteControlBeginSeekingForward = 108, 33 | RemoteControlEndSeekingForward = 109, 34 | } 35 | 36 | define_opts!( 37 | pub EventButtonMask(isize) 38 | ); 39 | 40 | impl EventButtonMask { 41 | pub const PRIMARY: Self = Self(1 << 0); 42 | pub const SECONDARY: Self = Self(1 << 1); 43 | } 44 | 45 | define_obj_type!( 46 | pub Event(ns::Id) 47 | ); 48 | 49 | impl Event { 50 | #[objc::msg_send(type)] 51 | pub fn type_(&self) -> EventType; 52 | 53 | #[objc::msg_send(subtype)] 54 | pub fn sub_type(&self) -> EventSubType; 55 | 56 | #[objc::msg_send(timestamp)] 57 | pub fn timestamp(&self) -> ns::TimeInterval; 58 | } 59 | -------------------------------------------------------------------------------- /cidre/src/ui/geometry.rs: -------------------------------------------------------------------------------- 1 | use crate::cg; 2 | 3 | #[doc(alias = "UIEdgeInsets")] 4 | #[derive(Debug, PartialEq, Copy, Clone)] 5 | #[repr(C)] 6 | pub struct EdgeInsets { 7 | pub top: cg::Float, 8 | pub left: cg::Float, 9 | pub bottom: cg::Float, 10 | pub right: cg::Float, 11 | } 12 | 13 | #[doc(alias = "UIOffset")] 14 | #[derive(Debug, PartialEq, Copy, Clone)] 15 | #[repr(C)] 16 | pub struct Offset { 17 | pub horizontal: cg::Float, 18 | pub vertical: cg::Float, 19 | } 20 | -------------------------------------------------------------------------------- /cidre/src/ui/image.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UIImage")] 5 | pub Image(ns::Id), 6 | UI_IMAGE 7 | ); 8 | 9 | impl arc::A { 10 | #[objc::msg_send(initWithContentsOfFile:)] 11 | fn init_with_contents_of_file(self, path: &ns::String) -> Option>; 12 | 13 | #[objc::msg_send(initWithContentsOfURL:)] 14 | fn init_with_contents_of_url(self, url: &ns::Url) -> Option>; 15 | 16 | #[objc::msg_send(initWithData:)] 17 | fn init_with_data(self, data: &ns::Data) -> Option>; 18 | } 19 | 20 | impl Image { 21 | #[inline] 22 | pub fn with_contents_of_file(path: &ns::String) -> Option> { 23 | Self::alloc().init_with_contents_of_file(path) 24 | } 25 | 26 | #[inline] 27 | pub fn with_contents_of_url(url: &ns::Url) -> Option> { 28 | Self::alloc().init_with_contents_of_url(url) 29 | } 30 | 31 | #[inline] 32 | pub fn with_data(data: &ns::Data) -> Option> { 33 | Self::alloc().init_with_data(data) 34 | } 35 | } 36 | 37 | #[link(name = "ui", kind = "static")] 38 | unsafe extern "C" { 39 | static UI_IMAGE: &'static objc::Class; 40 | } 41 | -------------------------------------------------------------------------------- /cidre/src/ui/interaction.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc, ui}; 2 | 3 | #[objc::protocol(UIProtocol)] 4 | pub trait Interaction: objc::Obj { 5 | #[objc::msg_send(view)] 6 | fn view(&self) -> arc::R; 7 | 8 | #[objc::msg_send(willMoveToView:)] 9 | fn will_move_to_view(&self, view: Option<&ui::View>); 10 | 11 | #[objc::msg_send(didMoveToView:)] 12 | fn did_move_to_view(&self, view: Option<&ui::View>); 13 | } 14 | 15 | define_obj_type!( 16 | pub AnyInteraction(ns::Id) 17 | ); 18 | 19 | impl Interaction for AnyInteraction {} 20 | 21 | /// Interactions 22 | impl ui::View { 23 | #[objc::msg_send(addInteraction:)] 24 | pub fn add_interaction(&mut self, val: &T); 25 | 26 | #[objc::msg_send(removeInteraction:)] 27 | pub fn remove_interaction(&mut self, val: &T); 28 | 29 | #[objc::msg_send(interactions)] 30 | pub fn interactions(&self) -> arc::R>; 31 | } 32 | -------------------------------------------------------------------------------- /cidre/src/ui/key.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc, ui}; 2 | 3 | define_obj_type!( 4 | pub Key(ns::Id) 5 | ); 6 | 7 | impl Key { 8 | /// A string representing what would be inserted into a text field when this key is pressed. 9 | /// 10 | /// If a modifier key is held, this property will contain the modified characters according 11 | /// the rules for that particular modifier key (i.e., if shift is held on a Latin keyboard, this will 12 | /// contain capital letters). 13 | #[objc::msg_send(characters)] 14 | pub fn characters(&self) -> arc::R; 15 | 16 | /// A string representing which characters would be inserted into a text field when this key is 17 | /// pressed, not taking any held modifiers into account. 18 | /// 19 | /// For Latin based languages, expect this to be always in lowercase (unmodified meaning not 20 | /// taking shift key into account). If only a modifier key was pressed, this property will contain an empty string. 21 | #[objc::msg_send(charactersIgnoringModifiers)] 22 | pub fn characters_ignoring_modifiers(&self) -> arc::R; 23 | 24 | /// A bitfield representing which modifier keys are currently being held in addition to this key. 25 | #[objc::msg_send(modifierFlags)] 26 | pub fn mod_flags(&self) -> ui::KeyModFlags; 27 | 28 | /// The raw HID usage code for the pressed key. 29 | #[objc::msg_send(keyCode)] 30 | pub fn key_code(&self) -> ui::KeyboardHidUsage; 31 | } 32 | -------------------------------------------------------------------------------- /cidre/src/ui/layout_guide.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, cg, define_obj_type, ns, objc, ui}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UILayoutGuide")] 5 | pub LayoutGuide(ns::Id), 6 | UI_LAYOUT_GUIDE 7 | ); 8 | 9 | impl LayoutGuide { 10 | #[objc::msg_send(layoutFrame)] 11 | pub fn layout_frame(&self) -> cg::Rect; 12 | 13 | #[objc::msg_send(owningView)] 14 | pub fn owning_view(&self) -> Option>; 15 | 16 | #[objc::msg_send(setOwningView:)] 17 | pub fn set_owning_view(&mut self, val: Option<&ui::View>); 18 | 19 | #[objc::msg_send(identifier)] 20 | pub fn id(&self) -> arc::R; 21 | 22 | #[objc::msg_send(setIdentifier:)] 23 | pub fn set_id(&mut self, val: &ns::String); 24 | } 25 | 26 | #[link(name = "ui", kind = "static")] 27 | unsafe extern "C" { 28 | static UI_LAYOUT_GUIDE: &'static objc::Class; 29 | } 30 | -------------------------------------------------------------------------------- /cidre/src/ui/navigation_bar.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ui}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UINavigationBar")] 5 | pub NavBar(ui::View) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ui/pan_gesture_recognizer.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ui}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UIPanGestureRecognizer")] 5 | pub PanGestureRecognizer(ui::GestureRecognizer) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ui/responder.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UIResponder")] 5 | pub Responder(ns::Id), 6 | UI_RESPONDER 7 | ); 8 | 9 | #[link(name = "ui", kind = "static")] 10 | unsafe extern "C" { 11 | static UI_RESPONDER: &'static objc::Class; 12 | } 13 | -------------------------------------------------------------------------------- /cidre/src/ui/scene_definitions.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UISceneSessionRole")] 5 | pub SceneSessionRole(ns::String) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ui/scene_windowing_behaviors.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | pub SceneWindowingBehaviors(ns::Id) 5 | ); 6 | 7 | impl SceneWindowingBehaviors { 8 | #[objc::msg_send(closable)] 9 | pub fn is_closable(&self) -> bool; 10 | 11 | #[objc::msg_send(setClosable:)] 12 | pub fn set_closable(&mut self, val: bool); 13 | 14 | #[objc::msg_send(isMiniaturizable)] 15 | pub fn is_miniaturizable(&self) -> bool; 16 | 17 | #[objc::msg_send(setMiniaturizable:)] 18 | pub fn set_miniaturizable(&mut self, val: bool); 19 | } 20 | -------------------------------------------------------------------------------- /cidre/src/ui/screen_mode.rs: -------------------------------------------------------------------------------- 1 | use crate::{cg, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UIScreenMode")] 5 | pub ScreenMode(ns::Id) 6 | ); 7 | 8 | impl ScreenMode { 9 | /// The width and height in pixels 10 | #[objc::msg_send(size)] 11 | pub fn size(&self) -> cg::Size; 12 | 13 | /// The aspect ratio of a single pixel. The ratio is defined as X/Y. 14 | #[objc::msg_send(pixelAspectRatio)] 15 | pub fn pixel_aspect_ratio(&self) -> cg::Float; 16 | } 17 | -------------------------------------------------------------------------------- /cidre/src/ui/tab_bar.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ui}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UITabBar")] 5 | pub TabBar(ui::View) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ui/tab_bar_controller_sidebar.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UITabBarControllerSidebar")] 5 | pub TabBarControllerSidebar(ns::Id) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ui/tap_gesture_recognizer.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ui}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UITapGestureRecognizer")] 5 | pub TapGestureRecognizer(ui::GestureRecognizer) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ui/toolbar.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ui}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UIToolbar")] 5 | pub Toolbar(ui::View) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ui/trait_collection.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, cg, define_obj_type, ns, objc, ui}; 2 | 3 | define_obj_type!( 4 | pub TraitCollection(ns::Id), 5 | UI_TRAIT_COLLECTION 6 | ); 7 | 8 | impl TraitCollection { 9 | #[objc::msg_send(userInterfaceIdiom)] 10 | pub fn ui_idiom(&self) -> ui::Idiom; 11 | 12 | #[objc::msg_send(userInterfaceStyle)] 13 | pub fn ui_style(&self) -> ui::Style; 14 | 15 | #[objc::msg_send(layoutDirection)] 16 | pub fn layout_direction(&self) -> ui::LayoutDirection; 17 | 18 | #[objc::msg_send(displayScale)] 19 | pub fn display_scale(&self) -> cg::Float; 20 | 21 | #[objc::msg_send(horizontalSizeClass)] 22 | pub fn horizontal_size_class(&self) -> ui::SizeClass; 23 | 24 | #[objc::msg_send(verticalSizeClass)] 25 | pub fn vertical_size_class(&self) -> ui::SizeClass; 26 | 27 | #[objc::msg_send(displayGamut)] 28 | pub fn display_gamut(&self) -> ui::DisplayGamut; 29 | 30 | // pub fn scene_capture_state(&self) -> ui::SceneCa 31 | } 32 | 33 | unsafe extern "C" { 34 | static UI_TRAIT_COLLECTION: &'static objc::Class; 35 | } 36 | -------------------------------------------------------------------------------- /cidre/src/ui/visual_effect.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | pub VisualEffect(ns::Id) 5 | ); 6 | -------------------------------------------------------------------------------- /cidre/src/ui/window.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, objc, ui}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UIWindow")] 5 | pub Window(ui::View), 6 | UI_WINDOW 7 | ); 8 | 9 | impl arc::A { 10 | #[objc::msg_send(initWithWindowScene:)] 11 | pub fn init_with_window_scene(self, scene: &ui::WindowScene) -> arc::R; 12 | } 13 | 14 | impl Window { 15 | pub fn with_window_scene(scene: &ui::WindowScene) -> arc::R { 16 | Self::alloc().init_with_window_scene(scene) 17 | } 18 | 19 | #[objc::msg_send(rootViewController)] 20 | pub fn root_vc(&self) -> Option<&ui::ViewController>; 21 | 22 | #[objc::msg_send(setRootViewController:)] 23 | pub fn set_root_vc(&mut self, val: Option<&ui::ViewController>); 24 | 25 | #[objc::msg_send(makeKeyAndVisible)] 26 | pub fn make_key_and_visible(&self); 27 | } 28 | 29 | #[link(name = "ui", kind = "static")] 30 | unsafe extern "C" { 31 | static UI_WINDOW: &'static objc::Class; 32 | } 33 | -------------------------------------------------------------------------------- /cidre/src/ui/window_scene_activation_request_options.rs: -------------------------------------------------------------------------------- 1 | use crate::{api, arc, define_obj_type, objc, ui}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UIWindowSceneActivationRequestOptions")] 5 | pub WindowSceneActivationRequestOpts(ui::SceneActivationRequestOpts), 6 | UI_WINDOW_SCENE_ACTIVATION_REQUEST_OPTIONS, 7 | #[api::available(ios = 15.0)] 8 | ); 9 | 10 | #[cfg(target_os = "ios")] 11 | impl WindowSceneActivationRequestOpts { 12 | #[objc::msg_send(placement)] 13 | pub fn placement(&self) -> Option>; 14 | 15 | #[objc::msg_send(setPlacement:)] 16 | pub fn set_placement(&mut self, val: Option<&ui::WindowScenePlacement>); 17 | } 18 | 19 | #[link(name = "ui", kind = "static")] 20 | unsafe extern "C" { 21 | static UI_WINDOW_SCENE_ACTIVATION_REQUEST_OPTIONS: 22 | &'static objc::Class; 23 | } 24 | -------------------------------------------------------------------------------- /cidre/src/ui/window_scene_placement.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UIWindowScenePlacement")] 5 | pub WindowScenePlacement(ns::Id) 6 | ); 7 | -------------------------------------------------------------------------------- /cidre/src/ui/window_scene_prominent_placement.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ui}; 2 | 3 | #[cfg(target_os = "ios")] 4 | use crate::{arc, objc}; 5 | 6 | define_obj_type!( 7 | #[doc(alias = "UIWindowSceneProminentPlacement")] 8 | pub WindowSceneProminentPlacement(ui::WindowScenePlacement) 9 | ); 10 | 11 | #[cfg(target_os = "ios")] 12 | impl WindowSceneProminentPlacement { 13 | #[objc::available(ios = 17.0)] 14 | crate::define_cls!(UI_WINDOW_SCENE_PROMINENT_PLACEMENT); 15 | 16 | #[objc::msg_send(prominentPlacement)] 17 | #[objc::available(ios = 17.0)] 18 | pub fn new() -> arc::R; 19 | } 20 | 21 | #[cfg(target_os = "ios")] 22 | #[link(name = "ui", kind = "static")] 23 | unsafe extern "C" { 24 | static UI_WINDOW_SCENE_PROMINENT_PLACEMENT: &'static objc::Class; 25 | } 26 | -------------------------------------------------------------------------------- /cidre/src/ui/window_scene_standard_placement.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_cls, define_obj_type, objc, ui}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UIWindowSceneStandardPlacement")] 5 | pub WindowSceneStandardPlacement(ui::WindowScenePlacement) 6 | ); 7 | 8 | impl WindowSceneStandardPlacement { 9 | #[objc::available(ios = 17.0, tvos = 17.0)] 10 | define_cls!(UI_WINDOW_SCENE_STANDARD_PLACEMENT); 11 | 12 | #[objc::msg_send(standardPlacement)] 13 | pub fn new() -> arc::R; 14 | } 15 | 16 | #[link(name = "ui", kind = "static")] 17 | unsafe extern "C" { 18 | static UI_WINDOW_SCENE_STANDARD_PLACEMENT: &'static objc::Class; 19 | } 20 | -------------------------------------------------------------------------------- /cidre/src/un/error.rs: -------------------------------------------------------------------------------- 1 | use crate::ns; 2 | 3 | impl ns::ErrorDomain { 4 | #[doc(alias = "UNErrorDomain")] 5 | pub fn user_notifications() -> &'static Self { 6 | unsafe { UNErrorDomain } 7 | } 8 | } 9 | 10 | #[link(name = "UserNotifications", kind = "framework")] 11 | unsafe extern "C" { 12 | static UNErrorDomain: &'static ns::ErrorDomain; 13 | } 14 | 15 | #[doc(alias = "UNErrorCode")] 16 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] 17 | #[repr(isize)] 18 | pub enum Code { 19 | NotificationsNotAllowed = 1, 20 | AttachInvalidUrl = 100, 21 | AttachUnrecognizedType, 22 | AttachInvalidFileSize, 23 | AttachNotInDataStore, 24 | AttachMoveIntoDataStoreFailed, 25 | AttachCorrupt, 26 | 27 | NotificationInvalidNoDate = 1400, 28 | NotificationInvalidNoContent, 29 | 30 | ContentProvidingObjectNotAllowed = 1500, 31 | ContentProvidingInvalid, 32 | 33 | CodeBadgeInputInvalid = 1600, 34 | } 35 | -------------------------------------------------------------------------------- /cidre/src/un/notification.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc, un}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UNNotification")] 5 | pub Notification(ns::Id) 6 | ); 7 | 8 | impl Notification { 9 | /// The date displayed on the notification. 10 | #[objc::msg_send(date)] 11 | pub fn date(&self) -> arc::R; 12 | 13 | /// The notification request that caused the notification to be delivered. 14 | #[objc::msg_send(request)] 15 | pub fn request(&self) -> arc::R; 16 | } 17 | -------------------------------------------------------------------------------- /cidre/src/un/notification_action_icon.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_cls, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UNNotificationActionIcon")] 5 | pub NotificationActionIcon(ns::Id) 6 | ); 7 | 8 | impl NotificationActionIcon { 9 | define_cls!(UN_NOTIFICATION_ACTION_ICON); 10 | 11 | #[objc::msg_send(iconWithTemplateImageName:)] 12 | pub fn with_template_image_name(template_image_name: &ns::String) -> arc::R; 13 | 14 | #[objc::msg_send(iconWithSystemImageName:)] 15 | pub fn with_sys_image_name(sys_image_name: &ns::String) -> arc::R; 16 | } 17 | 18 | unsafe extern "C" { 19 | static UN_NOTIFICATION_ACTION_ICON: &'static objc::Class; 20 | } 21 | -------------------------------------------------------------------------------- /cidre/src/un/notification_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_cls, define_obj_type, ns, objc, un}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UNNotificationRequest")] 5 | pub NotificationRequest(ns::Id) 6 | ); 7 | 8 | impl NotificationRequest { 9 | define_cls!(UN_NOTIFICATION_REQUEST); 10 | 11 | #[objc::msg_send(identifier)] 12 | pub fn id(&self) -> arc::R; 13 | 14 | #[objc::msg_send(content)] 15 | pub fn content(&self) -> arc::R; 16 | } 17 | 18 | unsafe extern "C" { 19 | static UN_NOTIFICATION_REQUEST: &'static objc::Class; 20 | } 21 | -------------------------------------------------------------------------------- /cidre/src/un/notification_response.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc, un}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "UNNotificationResponse")] 5 | pub NotificationResponse(ns::Id) 6 | ); 7 | 8 | impl NotificationResponse { 9 | #[objc::msg_send(notification)] 10 | pub fn notification(&self) -> arc::R; 11 | 12 | #[objc::msg_send(actionIdentifier)] 13 | pub fn action_id(&self) -> arc::R; 14 | } 15 | 16 | define_obj_type!( 17 | #[doc(alias = "UNTextInputNotificationResponse")] 18 | pub TextInputNotificationResponse(NotificationResponse) 19 | ); 20 | 21 | impl TextInputNotificationResponse { 22 | #[objc::msg_send(userText)] 23 | pub fn user_text(&self) -> arc::R; 24 | } 25 | -------------------------------------------------------------------------------- /cidre/src/ut.rs: -------------------------------------------------------------------------------- 1 | mod _type; 2 | pub use _type::Type; 3 | pub mod core_types; 4 | -------------------------------------------------------------------------------- /cidre/src/vn/detect_document_segmentation_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc, vn}; 2 | 3 | define_obj_type!( 4 | pub DetectDocumentSegmentationRequest(vn::ImageBasedRequest), 5 | VN_DETECT_DOCUMENT_SEGMENTATION_REQUEST 6 | ); 7 | 8 | impl DetectDocumentSegmentationRequest { 9 | pub const REVISION_1: usize = 1; 10 | 11 | #[objc::msg_send(results)] 12 | pub fn results(&self) -> Option>>; 13 | } 14 | 15 | #[link(name = "vn", kind = "static")] 16 | unsafe extern "C" { 17 | static VN_DETECT_DOCUMENT_SEGMENTATION_REQUEST: 18 | &'static objc::Class; 19 | } 20 | -------------------------------------------------------------------------------- /cidre/src/vn/detect_face_capture_quality_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc, vn}; 2 | 3 | define_obj_type!( 4 | pub DetectFaceCaptureQualityRequest(vn::ImageBasedRequest), 5 | VN_DETECT_FACE_CAPTURE_QUALITY_REQUEST 6 | ); 7 | 8 | impl DetectFaceCaptureQualityRequest { 9 | pub const REVISION_1: usize = 1; 10 | pub const REVISION_2: usize = 2; 11 | 12 | #[objc::msg_send(results)] 13 | pub fn results(&self) -> Option>>; 14 | } 15 | 16 | #[link(name = "vn", kind = "static")] 17 | unsafe extern "C" { 18 | static VN_DETECT_FACE_CAPTURE_QUALITY_REQUEST: 19 | &'static objc::Class; 20 | } 21 | 22 | #[cfg(test)] 23 | mod tests { 24 | use crate::vn; 25 | #[test] 26 | fn basics() { 27 | let mut request = vn::DetectFaceCaptureQualityRequest::new(); 28 | request.set_revision(vn::DetectFaceCaptureQualityRequest::REVISION_2); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cidre/src/vn/detect_face_rectangles_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc, vn}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "VNDetectFaceRectanglesRequest")] 5 | pub DetectFaceRectanglesRequest(vn::ImageBasedRequest), 6 | VN_DETECT_FACE_RECTANGLES_REQUEST 7 | ); 8 | 9 | impl DetectFaceRectanglesRequest { 10 | #[doc(alias = "VNDetectFaceRectanglesRequestRevision1")] 11 | pub const REVISION_1: usize = 1; 12 | 13 | #[doc(alias = "VNDetectFaceRectanglesRequestRevision2")] 14 | pub const REVISION_2: usize = 2; 15 | 16 | #[doc(alias = "VNDetectFaceRectanglesRequestRevision3")] 17 | pub const REVISION_3: usize = 3; 18 | 19 | #[objc::msg_send(results)] 20 | pub fn results(&self) -> Option>>; 21 | } 22 | 23 | #[link(name = "vn", kind = "static")] 24 | unsafe extern "C" { 25 | static VN_DETECT_FACE_RECTANGLES_REQUEST: &'static objc::Class; 26 | } 27 | -------------------------------------------------------------------------------- /cidre/src/vn/generate_attention_based_saliency_image_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc, vn}; 2 | 3 | define_obj_type!( 4 | pub GenAttentionBasedSaliencyImageRequest(vn::ImageBasedRequest), 5 | VN_GENERATE_ATTENTION_BAED_SALIENCY_IMAGE_REQUEST 6 | ); 7 | 8 | impl GenAttentionBasedSaliencyImageRequest { 9 | pub const REVISION_1: usize = 1; 10 | 11 | #[objc::msg_send(results)] 12 | pub fn results(&self) -> Option>>; 13 | } 14 | 15 | #[link(name = "vn", kind = "static")] 16 | unsafe extern "C" { 17 | static VN_GENERATE_ATTENTION_BAED_SALIENCY_IMAGE_REQUEST: 18 | &'static objc::Class; 19 | } 20 | -------------------------------------------------------------------------------- /cidre/src/vn/generate_foreground_instance_mask_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{api, arc, define_obj_type, ns, objc, vn}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "VNGenerateForegroundInstanceMaskRequest")] 5 | pub GenForegroundInstanceMaskRequest(vn::ImageBasedRequest), 6 | VN_GENERATE_FOREGROUND_INSTANCE_MASK_REQUEST, 7 | #[api::available(macos = 14.0, ios = 17.0, maccatalyst = 17.0, tvos = 17.0, visionos = 1.0)] 8 | ); 9 | 10 | impl GenForegroundInstanceMaskRequest { 11 | pub const REVISION_1: usize = 1; 12 | 13 | #[objc::msg_send(results)] 14 | pub fn results(&self) -> Option>>; 15 | } 16 | 17 | unsafe extern "C" { 18 | static VN_GENERATE_FOREGROUND_INSTANCE_MASK_REQUEST: 19 | &'static objc::Class; 20 | } 21 | -------------------------------------------------------------------------------- /cidre/src/vn/generate_objectness_based_saliency_image_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc, vn}; 2 | 3 | define_obj_type!( 4 | pub GenObjectnessBasedSaliencyImageRequest(vn::ImageBasedRequest), 5 | VN_GENERATE_OBJECTNESS_BASED_SALIENCY_IMAGE_REQUEST 6 | ); 7 | 8 | impl GenObjectnessBasedSaliencyImageRequest { 9 | pub const REVISION_1: usize = 1; 10 | 11 | #[objc::msg_send(results)] 12 | pub fn results(&self) -> Option>>; 13 | } 14 | 15 | #[link(name = "vn", kind = "static")] 16 | unsafe extern "C" { 17 | static VN_GENERATE_OBJECTNESS_BASED_SALIENCY_IMAGE_REQUEST: 18 | &'static objc::Class; 19 | } 20 | -------------------------------------------------------------------------------- /cidre/src/vn/generate_optical_flow_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, vn}; 2 | 3 | define_obj_type!(pub GenOpticalFlowRequest(vn::TargetedImageRequest)); 4 | -------------------------------------------------------------------------------- /cidre/src/vn/targeted_image_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, vn}; 2 | 3 | define_obj_type!(pub TargetedImageRequest(vn::ImageBasedRequest)); 4 | -------------------------------------------------------------------------------- /cidre/src/vn/tracking_request.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, objc, vn}; 2 | 3 | #[repr(usize)] 4 | pub enum Level { 5 | Accurate, 6 | Fast, 7 | } 8 | 9 | define_obj_type!(pub TrackingRequest(vn::ImageBasedRequest)); 10 | 11 | impl TrackingRequest { 12 | /// Tracking level allows tuning tracking algorithm to prefer speed (vn::RequestTrackingLevel::Fast) 13 | /// vs. tracking object location 14 | #[objc::msg_send(trackingLevel)] 15 | pub fn tracking_level(&self) -> Level; 16 | 17 | #[objc::msg_send(setTrackingLevel:)] 18 | pub fn set_tracking_level(&mut self, value: Level); 19 | } 20 | -------------------------------------------------------------------------------- /cidre/src/vt/decompression.rs: -------------------------------------------------------------------------------- 1 | pub mod session; 2 | #[cfg(feature = "blocks")] 3 | pub use session::MultiImageCapableOutputHandler; 4 | pub use session::OutputCb; 5 | pub use session::OutputCbRecord; 6 | pub use session::OutputMultiImageCb; 7 | pub use session::Session; 8 | 9 | pub mod properties; 10 | pub use properties::keys as property_keys; 11 | -------------------------------------------------------------------------------- /cidre/src/vt/pixel_rotation.rs: -------------------------------------------------------------------------------- 1 | pub mod session; 2 | pub use session::Session; 3 | 4 | pub mod properties; 5 | -------------------------------------------------------------------------------- /cidre/src/vt/pixel_transfer.rs: -------------------------------------------------------------------------------- 1 | pub mod properties; 2 | 3 | pub mod session; 4 | pub use session::Session; 5 | -------------------------------------------------------------------------------- /cidre/src/vt/professional_video_workflow.rs: -------------------------------------------------------------------------------- 1 | #[doc(alias = "VTRegisterProfessionalVideoWorkflowVideoDecoders")] 2 | pub fn register_decoders() { 3 | unsafe { VTRegisterProfessionalVideoWorkflowVideoDecoders() } 4 | } 5 | 6 | #[doc(alias = "VTRegisterProfessionalVideoWorkflowVideoEncoders")] 7 | pub fn register_encoders() { 8 | unsafe { VTRegisterProfessionalVideoWorkflowVideoEncoders() } 9 | } 10 | 11 | #[link(name = "VideoToolbox", kind = "framework")] 12 | unsafe extern "C" { 13 | fn VTRegisterProfessionalVideoWorkflowVideoDecoders(); 14 | fn VTRegisterProfessionalVideoWorkflowVideoEncoders(); 15 | } 16 | 17 | #[cfg(test)] 18 | mod tests { 19 | use crate::vt; 20 | #[test] 21 | fn basics() { 22 | let list = vt::video_encoder_list::copy().unwrap(); 23 | let a = list.len(); 24 | // println!("{list:?}"); 25 | vt::professional_video_workflow::register_encoders(); 26 | let list = vt::video_encoder_list::copy().unwrap(); 27 | // println!("{list:?}"); 28 | let b = list.len(); 29 | 30 | assert!(a < b); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /cidre/src/vt/utilities.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, cf, cg, cv, os}; 2 | 3 | pub fn cg_image_from_cv_pixel_buf( 4 | pixel_buffer: &cv::PixelBuf, 5 | options: Option<&cf::Dictionary>, 6 | ) -> os::Result> { 7 | unsafe { 8 | os::result_unchecked(|res| VTCreateCGImageFromCVPixelBuffer(pixel_buffer, options, res)) 9 | } 10 | } 11 | 12 | unsafe extern "C" { 13 | fn VTCreateCGImageFromCVPixelBuffer( 14 | pixel_buffer: &cv::PixelBuf, 15 | options: Option<&cf::Dictionary>, 16 | image_out: *mut Option>, 17 | ) -> os::Status; 18 | } 19 | -------------------------------------------------------------------------------- /cidre/src/wc.rs: -------------------------------------------------------------------------------- 1 | mod session; 2 | pub use session::ActivationState as SessionActivationState; 3 | pub use session::Session; 4 | 5 | mod error; 6 | pub use error::Code as ErrorCode; 7 | pub use error::Domain as ErrorDomain; 8 | -------------------------------------------------------------------------------- /cidre/src/wc/error.rs: -------------------------------------------------------------------------------- 1 | use crate::ns; 2 | 3 | pub type Domain = ns::ErrorDomain; 4 | 5 | impl Domain { 6 | pub fn watch_connectivity() -> &'static Self { 7 | unsafe { WCErrorDomain } 8 | } 9 | } 10 | 11 | #[link(name = "WatchConnectivity", kind = "framework")] 12 | unsafe extern "C" { 13 | static WCErrorDomain: &'static Domain; 14 | } 15 | 16 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] 17 | #[repr(isize)] 18 | pub enum Code { 19 | GenericError = 7001, 20 | SessionNotSupported = 7002, 21 | SessionMissingDelegate = 7003, 22 | SessionNotActivated = 7004, 23 | DeviceNotPaired = 7005, 24 | WatchAppNotInstalled = 7006, 25 | NotReachable = 7007, 26 | InvalidParameter = 7008, 27 | PayloadTooLarge = 7009, 28 | PayloadUnsupportedTypes = 7010, 29 | MessageReplyFailed = 7011, 30 | MessageReplyTimedOut = 7012, 31 | FileAccessDenied = 7013, 32 | DeliveryFailed = 7014, 33 | InsufficientSpace = 7015, 34 | SessionInactive = 7016, 35 | TransferTimedOut = 7017, 36 | CompanionAppNotInstalled = 7018, 37 | WatchOnlyApp = 7019, 38 | } 39 | -------------------------------------------------------------------------------- /cidre/src/wk.rs: -------------------------------------------------------------------------------- 1 | pub mod navigation; 2 | pub use navigation::Navigation; 3 | 4 | pub mod web_view; 5 | pub use web_view::FullscreenState; 6 | pub use web_view::MediaCaptureState; 7 | pub use web_view::MediaPlaybackState; 8 | pub use web_view::WebView; 9 | 10 | mod web_view_configuration; 11 | pub use web_view_configuration::AudiovisualMediaTypes; 12 | pub use web_view_configuration::SelectionGranularity; 13 | pub use web_view_configuration::UiDirectionPolicy; 14 | pub use web_view_configuration::WebViewCfg; 15 | 16 | mod process_pool; 17 | pub use process_pool::ProcessPool; 18 | 19 | mod preferences; 20 | pub use preferences::InactiveSchedulingPolicy; 21 | pub use preferences::Preferences; 22 | 23 | mod user_content_controller; 24 | pub use user_content_controller::UserContentController; 25 | 26 | mod user_script; 27 | pub use user_script::UserScript; 28 | pub use user_script::UserScriptInjectionTime; 29 | 30 | pub mod navigation_delegate; 31 | pub use navigation_delegate::NavigationDelegate; 32 | pub use navigation_delegate::NavigationDelegateImpl; 33 | 34 | mod website_data_store; 35 | pub use website_data_store::WebsiteDataStore; 36 | -------------------------------------------------------------------------------- /cidre/src/wk/navigation.rs: -------------------------------------------------------------------------------- 1 | use crate::{define_obj_type, ns}; 2 | 3 | define_obj_type!(pub Navigation(ns::Id)); 4 | -------------------------------------------------------------------------------- /cidre/src/wk/navigation_delegate.rs: -------------------------------------------------------------------------------- 1 | use crate::{ns, objc, wk}; 2 | 3 | #[objc::protocol(WKNavigationDelegate)] 4 | pub trait NavigationDelegate { 5 | #[objc::optional] 6 | #[objc::msg_send(webView:didFinishNavigation:)] 7 | fn web_view_did_finish_navigation( 8 | &mut self, 9 | web_view: &mut wk::WebView, 10 | navigation: Option<&wk::Navigation>, 11 | ); 12 | 13 | #[objc::optional] 14 | #[objc::msg_send(webView:didFinishNavigation:withError:)] 15 | fn web_view_did_fail_navigation_err( 16 | &mut self, 17 | web_view: &mut wk::WebView, 18 | navigation: Option<&wk::Navigation>, 19 | error: &ns::Error, 20 | ); 21 | } 22 | -------------------------------------------------------------------------------- /cidre/src/wk/process_pool.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | #[doc(alias = "WKProcessPool")] 5 | pub ProcessPool(ns::Id), 6 | WK_PROCESS_POOL 7 | ); 8 | 9 | #[link(name = "wk", kind = "static")] 10 | unsafe extern "C" { 11 | static WK_PROCESS_POOL: &'static objc::Class; 12 | } 13 | -------------------------------------------------------------------------------- /cidre/src/wk/user_content_controller.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_obj_type, ns, objc, wk}; 2 | 3 | define_obj_type!( 4 | pub UserContentController(ns::Id), 5 | WK_USER_CONTENT_CONTROLLER 6 | ); 7 | 8 | impl UserContentController { 9 | #[objc::msg_send(userScripts)] 10 | pub fn user_scripts(&self) -> arc::R>; 11 | 12 | #[objc::msg_send(addUserScript:)] 13 | pub fn add_user_script(&mut self, val: &wk::UserScript); 14 | 15 | #[objc::msg_send(removeAllUserScripts)] 16 | pub fn remove_all_user_scripts(&mut self); 17 | } 18 | 19 | #[link(name = "wk", kind = "static")] 20 | unsafe extern "C" { 21 | static WK_USER_CONTENT_CONTROLLER: &'static objc::Class; 22 | } 23 | -------------------------------------------------------------------------------- /cidre/src/wk/user_script.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_cls, define_obj_type, ns, objc, wk}; 2 | 3 | #[doc(alias = "WKUserScriptInjectionTime")] 4 | #[repr(isize)] 5 | pub enum UserScriptInjectionTime { 6 | AtDocumentStart, 7 | AtDocumentEnd, 8 | } 9 | 10 | define_obj_type!( 11 | pub UserScript(ns::Id) 12 | ); 13 | 14 | impl arc::A { 15 | #[objc::msg_send(initWithSource:injectionTime:forMainFrameOnly:)] 16 | pub fn init_with_src_injection_time_for_main_frame_only( 17 | self, 18 | src: &ns::String, 19 | injection_time: wk::UserScriptInjectionTime, 20 | for_main_frame_only: bool, 21 | ) -> arc::R; 22 | } 23 | 24 | impl UserScript { 25 | define_cls!(WK_USER_SCRIPT); 26 | 27 | pub fn with_src( 28 | src: &ns::String, 29 | injection_time: wk::UserScriptInjectionTime, 30 | for_main_frame_only: bool, 31 | ) -> arc::R { 32 | Self::alloc().init_with_src_injection_time_for_main_frame_only( 33 | src, 34 | injection_time, 35 | for_main_frame_only, 36 | ) 37 | } 38 | 39 | #[objc::msg_send(source)] 40 | pub fn src(&self) -> arc::R; 41 | 42 | #[objc::msg_send(injectionTime)] 43 | pub fn injection_time(&self) -> wk::UserScriptInjectionTime; 44 | 45 | #[objc::msg_send(isForMainFrameOnly)] 46 | pub fn is_for_main_frame_only(&self) -> bool; 47 | } 48 | 49 | #[link(name = "wk", kind = "static")] 50 | unsafe extern "C" { 51 | static WK_USER_SCRIPT: &'static objc::Class; 52 | } 53 | -------------------------------------------------------------------------------- /cidre/src/wk/website_data_store.rs: -------------------------------------------------------------------------------- 1 | use crate::{arc, define_cls, define_obj_type, ns, objc}; 2 | 3 | define_obj_type!( 4 | pub WebsiteDataStore(ns::Id) 5 | ); 6 | 7 | impl WebsiteDataStore { 8 | define_cls!(WK_WEBSITE_DATA_STORE); 9 | 10 | #[objc::msg_send(defaultDataStore)] 11 | pub fn default() -> arc::R; 12 | 13 | #[objc::msg_send(nonPersistentDataStore)] 14 | pub fn non_persistent() -> arc::R; 15 | 16 | #[objc::msg_send(isPersistent)] 17 | pub fn is_persistent(&self) -> bool; 18 | 19 | #[objc::msg_send(allWebsiteDataTypes)] 20 | pub fn all_website_data_types(&self) -> arc::R>; 21 | 22 | // ... 23 | 24 | #[objc::msg_send(identifier)] 25 | #[objc::available(macos = 14.0, ios = 17.0)] 26 | pub fn id(&self) -> Option>; 27 | 28 | #[objc::msg_send(dataStoreForIdentifier:)] 29 | #[objc::available(macos = 14.0, ios = 17.0)] 30 | pub fn with_id(id: &ns::Uuid) -> arc::R; 31 | } 32 | 33 | #[link(name = "wk", kind = "static")] 34 | unsafe extern "C" { 35 | static WK_WEBSITE_DATA_STORE: &'static objc::Class; 36 | } 37 | --------------------------------------------------------------------------------