Class RPCImplementationGenerator
java.lang.Object
eu.cloudnetservice.driver.impl.network.rpc.generation.RPCImplementationGenerator
The generator for rpc api implementations.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final RPCMethodGeneratorprivate static final RPCMethodGeneratorprivate final RPCGenerationContext(package private) static final intprivate final ClassDescprivate final intprivate final RPCClassMetadata -
Constructor Summary
ConstructorsConstructorDescriptionRPCImplementationGenerator(@NonNull RPCGenerationContext context, @NonNull RPCClassMetadata targetClassMeta, int generationFlags) Constructs a new rpc implementation generator. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanflagEnabled(int flag) Checks if the given flag is enabled in this implementation generator.private voidgenerateBridgeChannelGetterMethod(@NonNull ClassBuilder classBuilder) Generates a utility method to get the channel into which all rpc requests should be sent, which internally just calls the channel supplier.private voidgenerateBridgeRPCInvokeMethod(@NonNull ClassBuilder classBuilder) Generates a local utility method that can be used to invoke a method in this target class.private voidgenerateConstructor(@NonNull ClassBuilder classBuilder, @NonNull ClassDesc superClass, @NonNull MethodTypeDesc superConstructorDesc) Generates the constructor and the constructor code into the given target class builder.Runs the actual class implementation process.(package private) static voidgenerateObjectArgumentStore(@NonNull CodeBuilder codeBuilder, @NonNull MethodType methodType) Generates a set of instructions into the given code builder that stores all parameters of the given method into an object array.private @NonNull Tuple2<ClassDesc, MethodTypeDesc> Tries to find the super constructor that should be invoked from the generated implementation class.
-
Field Details
-
FLAG_IMPLEMENT_CONCRETE
static final int FLAG_IMPLEMENT_CONCRETE- See Also:
-
BASIC_GENERATOR
-
CHAINED_GENERATOR
-
generationFlags
private final int generationFlags -
targetClassMeta
-
generatingClass
-
context
-
-
Constructor Details
-
RPCImplementationGenerator
RPCImplementationGenerator(@NonNull @NonNull RPCGenerationContext context, @NonNull @NonNull RPCClassMetadata targetClassMeta, int generationFlags) Constructs a new rpc implementation generator.- Parameters:
context- the generation context to use for the process.targetClassMeta- the metadata of the class for which the implementation is being generated.generationFlags- the option flags to customize the generation process.- Throws:
NullPointerException- if the given context or target class meta is null.
-
-
Method Details
-
generateObjectArgumentStore
static void generateObjectArgumentStore(@NonNull @NonNull CodeBuilder codeBuilder, @NonNull @NonNull MethodType methodType) Generates a set of instructions into the given code builder that stores all parameters of the given method into an object array.- Parameters:
codeBuilder- the code builder into which the parameter store instruction should be generated.methodType- the information about the method for which the instructions are generated.- Throws:
NullPointerException- if the given code builder or method type is null.
-
generateImplementation
Runs the actual class implementation process.- Returns:
- a method handle with full access to the generated target class.
- Throws:
IllegalStateException- if something went wrong generating the implementation class.
-
flagEnabled
private boolean flagEnabled(int flag) Checks if the given flag is enabled in this implementation generator.- Parameters:
flag- the flag to check the status of.- Returns:
- true if the given flag is enabled, false otherwise.
-
resolveBaseConstructorInformation
Tries to find the super constructor that should be invoked from the generated implementation class.- Returns:
- the super constructor to invoke from the generated class.
- Throws:
IllegalStateException- if no target constructor for rpc found in target class.
-
generateBridgeRPCInvokeMethod
Generates a local utility method that can be used to invoke a method in this target class. The method automatically joins the base rpc with the newly constructed rpc, if any is provided.- Parameters:
classBuilder- the class builder into which the method should be generated.- Throws:
NullPointerException- if the given class builder is null.
-
generateBridgeChannelGetterMethod
Generates a utility method to get the channel into which all rpc requests should be sent, which internally just calls the channel supplier.- Parameters:
classBuilder- the class builder into which the method should be generated.- Throws:
NullPointerException- if the given class builder is null.
-
generateConstructor
private void generateConstructor(@NonNull @NonNull ClassBuilder classBuilder, @NonNull @NonNull ClassDesc superClass, @NonNull @NonNull MethodTypeDesc superConstructorDesc) Generates the constructor and the constructor code into the given target class builder.- Parameters:
classBuilder- the builder of the class to generate the constructor in.superClass- the super class in which the target constructor is located.superConstructorDesc- the descriptor of the constructor in the super class.- Throws:
NullPointerException- if the given class builder, super class or super constructor descriptor is null.
-