How to use the jsii._reference_map.register_reference function in jsii

To help you get started, we’ve selected a few jsii examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / jsii / packages / @jsii / python-runtime / src / jsii / _kernel / __init__.py View on Github external
"data": {
                        jsii_name: _make_reference_for_native(kernel, getattr(d, python_name)) for python_name, jsii_name in mapping.items()
                    }
                }
            }
        return d
    elif isinstance(d, (int, type(None), str, float, bool, datetime.datetime)):
        return d
    elif isinstance(d, (FunctionType, MethodType, BuiltinFunctionType, LambdaType)):
        # Whether a given object is a function-like object.
        # We won't use iscallable() since objects may implement __call__()
        # but we still want to serialize them as normal.
        raise JSIIError("Cannot pass function as argument here (did you mean to call this function?): %r" % d)
    else:
        kernel.create(d.__class__, d)
        _reference_map.register_reference(d)
        return d
github aws / jsii / packages / jsii-python-runtime / src / jsii / _runtime.py View on Github external
def __call__(cls, *args, **kwargs):
        inst = super().__call__(*args, **kwargs)

        # Register this instance with our reference map.
        _reference_map.register_reference(inst)

        return inst