コード例 #1
0
Handle<Value> HoneydConfigBinding::GetPortSet(const Arguments& args)
{
	HandleScope scope;
	HoneydConfigBinding* obj = ObjectWrap::Unwrap<HoneydConfigBinding>(args.This());

	if(args.Length() != 2)
	{
		return ThrowException(Exception::TypeError(String::New("Must be invoked with 2 parameters")));
	}

	std::string profileName = cvv8::CastFromJS<string>(args[0]);
	int portSetIndex = cvv8::CastFromJS<int>(args[1]);

	Profile *profile = obj->m_conf->GetProfile(profileName);
	if(profile == NULL)
	{
		return scope.Close( Null() );
	}
	PortSet *portSet = profile->GetPortSet(portSetIndex);
	if(portSet == NULL)
	{
		return scope.Close( Null() );
	}

	return scope.Close( HoneydNodeJs::WrapPortSet( portSet ));
}