or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

bridge-registration.mdclass-enhancement.mdcore-bridge.mdframework-loading.mdindex.mdinterface-builder.mdmethod-decorators.mdproperties-accessors.mdprotocol-support.mdpyobjctools.md

core-bridge.mddocs/

0

# Core Bridge Functionality

1

2

Essential bridge components that provide the foundation for Python-Objective-C interoperability, including constants, context management, and fundamental runtime integration features.

3

4

## Capabilities

5

6

### Objective-C Constants

7

8

Standard Objective-C constants mapped to Python equivalents for seamless code compatibility.

9

10

```python { .api }

11

nil = None

12

"""Objective-C nil constant, equivalent to Python None."""

13

14

YES = True

15

"""Objective-C YES constant, equivalent to Python True."""

16

17

NO = False

18

"""Objective-C NO constant, equivalent to Python False."""

19

```

20

21

### Autorelease Pool Management

22

23

Context manager for managing NSAutoreleasePool instances, essential for memory management when working with Objective-C objects.

24

25

```python { .api }

26

class autorelease_pool:

27

"""

28

Context manager that runs the body of the block with a fresh autorelease pool.

29

The actual release pool is not accessible.

30

"""

31

def __init__(self): ...

32

def __enter__(self): ...

33

def __exit__(self, exc_type, value, tp): ...

34

```

35

36

**Usage Example:**

37

38

```python

39

import objc

40

41

# Use autorelease pool for memory management

42

with objc.autorelease_pool():

43

# Work with Objective-C objects here

44

# Pool will be automatically drained when exiting the context

45

pass

46

```

47

48

### Helper Functions

49

50

Utility functions for name resolution and runtime introspection.

51

52

```python { .api }

53

def _resolve_name(name):

54

"""

55

Resolve a dotted name to a Python object.

56

57

Args:

58

name (str): Dotted name like "module.submodule.function"

59

60

Returns:

61

object: The resolved Python object

62

63

Raises:

64

ValueError: If name doesn't contain dots

65

"""

66

```

67

68

### Core Runtime Integration

69

70

The core bridge functionality is provided through the `objc._objc` C extension module, which includes:

71

72

- Objective-C runtime integration

73

- Object and class manipulation

74

- Method dispatch and invocation

75

- Type encoding and conversion

76

- Selector and method signature handling

77

- Memory management integration

78

- Exception bridging between Python and Objective-C

79

80

This C extension is automatically imported and its namespace is merged into the main `objc` module, providing seamless access to all bridge functionality.