Library/Compiler.php
private function loadConstantsSources($constantsSources)
    {
        foreach ($constantsSources as $constantsSource) {
            if (!file_exists($constantsSource)) {
                throw new Exception("File '".$constantsSource."' with constants definitions");
            }

            foreach (file($constantsSource) as $line) {
                if (preg_match('/^\#define[ \t]+([A-Z0-9\_]+)[ \t]+([0-9]+)/', $line, $matches)) {
                    $this->constants[$matches[1]] = ['int', $matches[2]];
                    continue;
                }
                if (preg_match('/^\#define[ \t]+([A-Z0-9\_]+)[ \t]+(\'(.){1}\')/', $line, $matches)) {
                    $this->constants[$matches[1]] = ['char', $matches[3]];
                }
            }
        }
    }
private function loadConstantsSources($constantsSources)
    {
        foreach ($constantsSources as $constantsSource) {
            if (!file_exists($constantsSource)) {
                throw new Exception("File '".$constantsSource."' with constants definitions");
            }

            foreach (file($constantsSource) as $line) {
                if (preg_match('/^\#define[ \t]+([A-Z0-9\_]+)[ \t]+([0-9]+)/', $line, $matches)) {
                    $this->constants[$matches[1]] = ['int', $matches[2]];
                    continue;
                }
                if (preg_match('/^\#define[ \t]+([A-Z0-9\_]+)[ \t]+(\'(.){1}\')/', $line, $matches)) {
                    $this->constants[$matches[1]] = ['char', $matches[3]];
                }
            }
        }
    }
private function loadConstantsSources ( $ constantsSources ) { foreach ( $ constantsSources as $ constantsSource ) { if ( ! file_exists ( $ constantsSource ) ) { throw new Exception ( "File '" . $ constantsSource . "' with constants definitions" ) ; } foreach ( file ( $ constantsSource ) as $ line ) { if ( preg_match ( '/^\#define[ \t]+([A-Z0-9\_]+)[ \t]+([0-9]+)/' , $ line , $ matches ) ) { $ this -> constants [ $ matches [ 1 ] ] = [ 'int' , $ matches [ 2 ] ] ; continue ; } if ( preg_match ( '/^\#define[ \t]+([A-Z0-9\_]+)[ \t]+(\'(.){1}\')/' , $ line , $ matches ) ) { $ this -> constants [ $ matches [ 1 ] ] = [ 'char' , $ matches [ 3 ] ] ; } } } }
Registers C-constants as PHP constants from a C-file.

@param array $constantsSources

@throws Exception
Registers C - constants as PHP constants from a C - file .