yaoyansi/maya2renderer — Issue #11: 待优化：liquidSlParsePL.mel
Author: yaoyansi
Created: 2012-02-01 07:22:54+00:00
State: open

Commit:dd3dd2abc5352eb98601d8d46fde3ff9dd41c1f1
* liq| er| user-defined shader| : add *.pl for the parameter list of user-defined shader.

liquidSlParsePL.mel
global int $i_ParmName	= 0;
global int $i_ParmDetails	= 1;
global int $i_ParmType	= 2;
global int $i_ParmOutput	= 3;
global int $i_ParmDefault	= 4;
global int $i_ParmArraySize	= 5;
global proc liquidSlParsePL( string $shaderFile )
{
while ( !`feof $fid` )
{
$line = getSloLine ($fid);

$line = strip($line);

string $paramName = liquidSl_getParamName( $line );
...
string $paramDetail = liquidSl_getParamDetail( $line );
...
int $isOutputParam = liquidSl_isOutputParam( $line );
...
string $paramType = liquidSl_getParamType( $line );
...
int $paramArraySize = liquidSl_getParamArraySize( $line );
...
string $paramDefault = liquidSl_getParamDefault( $line, $paramType );
...
}

}

liquidSl_get*()这些子函数里，每一个都有:
$array = stringToStringArray($line,":");
$size = size($array);

proc string liquidSl_get*( string $line )
{
liqPushIdent();
liqlog("liquidSl_get*("+$line+")");
...
string $array[];
int $size;

$array = stringToStringArray($line,":");
$size = size($array);

liqPopIdent();
return $array[$i_ParmName];
}
----------------------------------------------------------------------------------------------------------
可以改为：
$array = stringToStringArray($line,":");
$size = size($array);

string $paramName = liquidSl_getParamName( $array , $i_ParmName);
...
string $paramDetail = liquidSl_getParamDetail( $array , $i_ParmDetails );
...
int $isOutputParam = liquidSl_isOutputParam( $array , $i_ParmOutput );
...
string $paramType = liquidSl_getParamType( $array , $i_ParmType );
...
int $paramArraySize = liquidSl_getParamArraySize( $array , $i_ParmArraySize );
...
string $paramDefault = liquidSl_getParamDefault( $array , $paramType, $i_ParmDefault );

在各个子函数里：
proc string liquidSl_get*( string[] $array , int $index )
{
liqPushIdent();
liqlog("liquidSl_get*(array[], "+$index+")");

liqPopIdent();
return $array[$index];
}