diff --git a/src/ncc/Objects/ExecutionPointers/ExecutionPointer.php b/src/ncc/Objects/ExecutionPointers/ExecutionPointer.php deleted file mode 100644 index f7d8a1c..0000000 --- a/src/ncc/Objects/ExecutionPointers/ExecutionPointer.php +++ /dev/null @@ -1,131 +0,0 @@ -id; - } - - /** - * @return ExecutionPolicy - */ - public function getExecutionPolicy(): ExecutionPolicy - { - return $this->execution_policy; - } - - /** - * @return string|null - */ - public function getFilePointer(): ?string - { - return $this->file_pointer; - } - - /** - * Public Constructor with optional ExecutionUnit parameter to construct object from - * - * @param ExecutionUnit|null $unit - * @param string|null $bin_file - */ - public function __construct(?ExecutionUnit $unit=null, ?string $bin_file=null) - { - if($unit === null) - { - return; - } - - $this->id = $unit->getId(); - $this->execution_policy = $unit->getExecutionPolicy(); - $this->file_pointer = $bin_file; - } - - /** - * Returns an array representation of the object - * - * @param bool $bytecode - * @return array - */ - public function toArray(bool $bytecode=false): array - { - return [ - ($bytecode ? Functions::cbc('id') : 'id') => $this->id, - ($bytecode ? Functions::cbc('execution_policy') : 'execution_policy') => $this->execution_policy->toArray($bytecode), - ($bytecode ? Functions::cbc('file_pointer') : 'file_pointer') => $this->file_pointer, - ]; - } - - /** - * Constructs an object from an array representation - * - * @param array $data - * @return ExecutionPointer - */ - public static function fromArray(array $data): ExecutionPointer - { - $object = new self(); - - $object->id = Functions::array_bc($data, 'id'); - $object->execution_policy = Functions::array_bc($data, 'execution_policy'); - $object->file_pointer = Functions::array_bc($data, 'file_pointer'); - - if($object->execution_policy !== null) - { - $object->execution_policy = ExecutionPolicy::fromArray($object->execution_policy); - } - - return $object; - } - } \ No newline at end of file diff --git a/src/ncc/Objects/ProjectConfiguration/Build/BuildConfiguration.php b/src/ncc/Objects/ProjectConfiguration/Build/BuildConfiguration.php index 9dfbfe2..11c9478 100644 --- a/src/ncc/Objects/ProjectConfiguration/Build/BuildConfiguration.php +++ b/src/ncc/Objects/ProjectConfiguration/Build/BuildConfiguration.php @@ -26,7 +26,9 @@ use ncc\Enums\Types\BuildOutputType; use ncc\Exceptions\ConfigurationException; + use ncc\Exceptions\NotSupportedException; use ncc\Interfaces\BytecodeObjectInterface; + use ncc\Interfaces\ValidatableObjectInterface; use ncc\Objects\ProjectConfiguration\Dependency; use ncc\Utilities\Functions; use ncc\Utilities\Validate; @@ -35,7 +37,7 @@ * @author Zi Xing Narrakas * @copyright Copyright (C) 2022-2023. Nosial - All Rights Reserved. */ - class BuildConfiguration implements BytecodeObjectInterface + class BuildConfiguration implements BytecodeObjectInterface, ValidatableObjectInterface { /** * The unique name of the build configuration @@ -63,6 +65,13 @@ */ private $output_path; + /** + * Optional. The name of the output file, eg; %ASSEMBLY.PACKAGE%.ncc + * + * @var string|null + */ + private $output_name; + /** * An array of constants to define for the build when importing or executing. * @@ -118,11 +127,11 @@ /** * Validates the BuildConfiguration object * - * @param bool $throw_exception - * @return bool + * @return void * @throws ConfigurationException + * @throws NotSupportedException */ - public function validate(): bool + public function validate(): void { if(!Validate::nameFriendly($this->name)) { @@ -164,8 +173,6 @@ { $dependency->validate(); } - - return True; } /** @@ -244,6 +251,22 @@ $this->output_path = $output_path; } + /** + * @return string|null + */ + public function getOutputName(): ?string + { + return $this->output_name; + } + + /** + * @param string|null $output_name + */ + public function setOutputName(?string $output_name): void + { + $this->output_name = $output_name; + } + /** * @return array|string[] */ @@ -407,6 +430,7 @@ $results[($bytecode ? Functions::cbc('name') : 'name')] = $this->name; $results[($bytecode ? Functions::cbc('build_type') : 'build_type')] = $this->build_type; $results[($bytecode ? Functions::cbc('output_path') : 'output_path')] = $this->output_path; + $results[($bytecode ? Functions::cbc('output_name') : 'output_path')] = $this->output_name; if(count($this->options) > 0) { @@ -462,6 +486,7 @@ $object = new BuildConfiguration($name, $output_path); + $object->output_name = Functions::array_bc($data, 'output_name'); $object->build_type = Functions::array_bc($data, 'build_type') ?? BuildOutputType::NCC_PACKAGE; $object->options = Functions::array_bc($data, 'options') ?? []; $object->define_constants = Functions::array_bc($data, 'define_constants') ?? [];