Model Classes and API#

Public Type Aliases#

model.QName = <class 'str'>#

Qualified class name. This is a string of the form package.ClassName.

model.RPath = <class 'str'>#

Relative path. This is a string of the form path/to/file.ext.

model.ABSPath = <class 'str'>#

Absolute path. This is a string of the form /src-root/path/to/file.ext.

model.QImport = <class 'str'>#

Qualified import. This is a string of the form package.ClassName with an optional wildcard to import everything.

Public Types#

class bshark.compiler.model.FieldDef(name: str, call: str)[source]#

A simple parcelable field definition.

It contains the name defined in the parcelable class and the corresponding call to the Parcel object.

call: str#
name: str#
class bshark.compiler.model.Direction(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

The direction of an argument in a method call.

IN = 0#
INOUT = 2#
OUT = 1#
class bshark.compiler.model.ReturnDef(call: str)[source]#

A simple binder method return definition.

call: str#
class bshark.compiler.model.ParameterDef(name: str, call: str, direction: Direction = Direction.IN)[source]#

A simple binder method parameter definition.

It contains the name of the type and the corresponding call to the Parcel object as well as its direction.

call: str#
direction: Direction#
name: str#
class bshark.compiler.model.MethodDef(name: str, tc: int, oneway: bool, retval: List[ParameterDef | ReturnDef] | None, arguments: List[ParameterDef])[source]#

A simple parcelable method definition. (Binder method)

Each method stores the source method name and the defined transaction code. Note that the transaction code may not match with the one in intercepted Transactions, since they are automatically inferred.

The return type is optional and will be None to oneway methods.

arguments: List[ParameterDef]#
name: str#
oneway: bool#
retval: List[ParameterDef | ReturnDef] | None#
tc: int#
class bshark.compiler.model.ImportDef(qname: str, file_type: Type = Type.UNDEFINED, unit: Unit | None = None)[source]#

A simple import statement definition.

It contains the import path and the corresponding code unit, which will be None if the import failed.

file_type: Type#
property name: str#
qname: str#
unit: Unit | None#
class bshark.compiler.model.ConditionDef(call: str, check: str, op: str, consequence: List[FieldDef], alternative: List[FieldDef])[source]#

A simple condition definition.

A condition is a simple boolean expression that will be translated from an if-statement and transformed into a readInt call. All following field definitions will be placed here.

alternative: List[FieldDef]#
call: str#
check: str#
consequence: List[FieldDef]#
op: str#
class bshark.compiler.model.ClassDef(qname: str, type: Type | str)[source]#

A simple generic type definition.

qname: str#
type: Type | str#
class bshark.compiler.model.ParcelableDef(qname: str, type: Type | str, fields: List[FieldDef | ConditionDef])[source]#

Bases: ClassDef

A simple parcelable definition.

fields: List[FieldDef | ConditionDef]#
class bshark.compiler.model.BinderDef(qname: str, type: Type | str, methods: List[MethodDef])[source]#

Bases: ClassDef

A simple binder definition.

methods: List[MethodDef]#
class bshark.compiler.model.Stop[source]#

A special stop definition.

This class will be used to track special conditions within the Java code flow. It tells the parser to stop if this field is reached.

class bshark.compiler.model.ImportDefList(iterable=(), /)[source]#

Internal class to store import definitions.

get(name: str) ImportDef | None[source]#

Returns the import definition with the given name.

Public interface#

bshark.compiler.model.to_json(definition) str[source]#

Converts the given definition to JSON.

bshark.compiler.model.from_json(json_str: str | dict) BinderDef | ParcelableDef[source]#

Converts the given JSON string back to the definition.

Internal Types#

class bshark.compiler.model.UnsupportedTypeError[source]#

A special exception used to mark unsupported types.

class bshark.compiler.model.Primitive[source]#

A storage class for all supported primitive types.

class bshark.compiler.model.Complex[source]#

A storage class for all supported complex types.