本文整理汇总了C++中UObject::FindFunction方法的典型用法代码示例。如果您正苦于以下问题:C++ UObject::FindFunction方法的具体用法?C++ UObject::FindFunction怎么用?C++ UObject::FindFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UObject
的用法示例。
在下文中一共展示了UObject::FindFunction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReceivedBunch
//.........这里部分代码省略.........
if ( Bunch.IsError() )
{
UE_LOG( LogNet, Error, TEXT( "ReceivedBunch: Error reading bunch 2: %s" ), *Object->GetFullName() );
return false;
}
if ( RepIndex > ClassCache->GetMaxIndex() )
{
UE_LOG( LogNet, Error, TEXT( "ReceivedBunch: RepIndex too large: %s" ), *Object->GetFullName() );
return false;
}
if ( RepIndex == ClassCache->GetMaxIndex() )
{
// We're done
FieldCache = NULL;
}
else
{
FieldCache = ClassCache->GetFromIndex( RepIndex );
if ( FieldCache == NULL )
{
UE_LOG( LogNet, Error, TEXT( "ReceivedBunch: FieldCache == NULL: %s" ), *Object->GetFullName() );
return false;
}
}
}
// Handle function calls.
if ( FieldCache && Cast< UFunction >( FieldCache->Field ) )
{
FName Message = FieldCache->Field->GetFName();
UFunction * Function = Object->FindFunction( Message );
if ( Function == NULL )
{
UE_LOG( LogNet, Error, TEXT( "ReceivedBunch: Function == NULL: %s" ), *Object->GetFullName() );
return false;
}
if ( ( Function->FunctionFlags & FUNC_Net ) == 0 )
{
UE_LOG( LogNet, Error, TEXT( "Rejected non RPC function %s in %s" ), *Message.ToString(), *Object->GetFullName() );
return false;
}
if ( ( Function->FunctionFlags & ( bIsServer ? FUNC_NetServer : ( FUNC_NetClient | FUNC_NetMulticast ) ) ) == 0 )
{
UE_LOG( LogNet, Error, TEXT( "Rejected RPC function due to access rights %s in %s" ), *Message.ToString(), *Object->GetFullName() );
return false;
}
UE_LOG( LogNetTraffic, Log, TEXT( " Received RPC: %s" ), *Message.ToString() );
// Get the parameters.
FMemMark Mark(FMemStack::Get());
uint8* Parms = new(FMemStack::Get(),MEM_Zeroed,Function->ParmsSize)uint8;
// Use the replication layout to receive the rpc parameter values
TSharedPtr<FRepLayout> FuncRepLayout = OwningChannel->Connection->Driver->GetFunctionRepLayout( Function );
FuncRepLayout->ReceivePropertiesForRPC( Object, Function, OwningChannel, Bunch, Parms );
if ( Bunch.IsError() )
{
示例2: HandleExecuteUObjectMethodMessage
bool FWebJSScripting::HandleExecuteUObjectMethodMessage(CefRefPtr<CefListValue> MessageArguments)
{
FGuid ObjectKey;
// Message arguments are Name, Value, bGlobal
if (MessageArguments->GetSize() != 4
|| MessageArguments->GetType(0) != VTYPE_STRING
|| MessageArguments->GetType(1) != VTYPE_STRING
|| MessageArguments->GetType(2) != VTYPE_STRING
|| MessageArguments->GetType(3) != VTYPE_LIST
)
{
// Wrong message argument types or count
return false;
}
if (!FGuid::Parse(FString(MessageArguments->GetString(0).ToWString().c_str()), ObjectKey))
{
// Invalid GUID
return false;
}
// Get the promise callback and use that to report any results from executing this function.
FGuid ResultCallbackId;
if (!FGuid::Parse(FString(MessageArguments->GetString(2).ToWString().c_str()), ResultCallbackId))
{
// Invalid GUID
return false;
}
UObject* Object = GuidToPtr(ObjectKey);
if (Object == nullptr)
{
// Unknown uobject id
InvokeJSErrorResult(ResultCallbackId, TEXT("Unknown UObject ID"));
return true;
}
FName MethodName = MessageArguments->GetString(1).ToWString().c_str();
UFunction* Function = Object->FindFunction(MethodName);
if (!Function)
{
InvokeJSErrorResult(ResultCallbackId, TEXT("Unknown UObject Function"));
return true;
}
// Coerce arguments to function arguments.
uint16 ParamsSize = Function->ParmsSize;
TArray<uint8> Params;
UProperty* ReturnParam = nullptr;
// Convert cef argument list to a dictionary, so we can use FStructDeserializer to convert it for us
CefRefPtr<CefDictionaryValue> NamedArgs = CefDictionaryValue::Create();
{
int32 CurrentArg = 0;
CefRefPtr<CefListValue> CefArgs = MessageArguments->GetList(3);
for ( TFieldIterator<UProperty> It(Function); It; ++It )
{
UProperty* Param = *It;
if (Param->PropertyFlags & CPF_Parm)
{
if (Param->PropertyFlags & CPF_ReturnParm)
{
ReturnParam = Param;
}
else
{
CopyContainerValue(NamedArgs, CefArgs, CefString(*Param->GetName()), CurrentArg);
CurrentArg++;
}
}
}
if (ParamsSize > 0)
{
// UFunction is a subclass of UStruct, so we can treat the arguments as a struct for deserialization
UStruct* TypeInfo = Cast<UStruct>(Function);
Params.AddUninitialized(ParamsSize);
TypeInfo->InitializeStruct(Params.GetData());
FWebJSStructDeserializerBackend Backend = FWebJSStructDeserializerBackend(SharedThis(this), NamedArgs);
FStructDeserializer::Deserialize(Params.GetData(), *TypeInfo, Backend);
}
}
Object->ProcessEvent(Function, Params.GetData());
if ( ReturnParam )
{
FWebJSParam Results[1] = {ConvertResult(ReturnParam, Params.GetData())};
InvokeJSFunction(ResultCallbackId, 1, Results, false);
}
else
{
InvokeJSFunction(ResultCallbackId, 0, nullptr, false);
}
return true;
}
示例3: ReceivedBunch
//.........这里部分代码省略.........
if ( Bunch.IsError() )
{
UE_LOG(LogNet, Error, TEXT("ReceivedBunch: NetDeltaSerialize - Bunch.IsError() == true: %s"), *Object->GetFullName());
return false;
}
if ( Parms.bOutHasMoreUnmapped )
{
UnmappedCustomProperties.Add( DataOffset, StructProperty );
bOutHasUnmapped = true;
}
// Successfully received it.
UE_LOG(LogRepTraffic, Log, TEXT(" %s - %s"), *Object->GetName(), *ReplicatedProp->GetName());
// Notify the Object if this var is RepNotify
QueuePropertyRepNotify( Object, ReplicatedProp, Element, MetaData );
}
// Read next field
FieldCache = ReadField( ClassCache, Bunch );
if ( Bunch.IsError() )
{
UE_LOG(LogNet, Error, TEXT("ReceivedBunch: Error reading field 2: %s"), *Object->GetFullName());
return false;
}
}
// Handle function calls.
if ( FieldCache && Cast< UFunction >( FieldCache->Field ) )
{
FName Message = FieldCache->Field->GetFName();
UFunction * Function = Object->FindFunction( Message );
if ( Function == NULL )
{
UE_LOG(LogNet, Error, TEXT("ReceivedBunch: Function == NULL: %s"), *Object->GetFullName());
return false;
}
if ( ( Function->FunctionFlags & FUNC_Net ) == 0 )
{
UE_LOG(LogRep, Error, TEXT("Rejected non RPC function %s in %s"), *Message.ToString(), *Object->GetFullName());
return false;
}
if ( ( Function->FunctionFlags & ( bIsServer ? FUNC_NetServer : ( FUNC_NetClient | FUNC_NetMulticast ) ) ) == 0 )
{
UE_LOG(LogRep, Error, TEXT("Rejected RPC function due to access rights %s in %s"), *Message.ToString(), *Object->GetFullName());
return false;
}
UE_LOG(LogRepTraffic, Log, TEXT(" Received RPC: %s"), *Message.ToString());
// Get the parameters.
FMemMark Mark(FMemStack::Get());
uint8* Parms = new(FMemStack::Get(),MEM_Zeroed,Function->ParmsSize)uint8;
// Use the replication layout to receive the rpc parameter values
TSharedPtr<FRepLayout> FuncRepLayout = OwningChannel->Connection->Driver->GetFunctionRepLayout( Function );
FuncRepLayout->ReceivePropertiesForRPC( Object, Function, OwningChannel, Bunch, Parms );
if ( Bunch.IsError() )
{
示例4: HandleExecuteUObjectMethodMessage
bool FWebJSScripting::HandleExecuteUObjectMethodMessage(CefRefPtr<CefListValue> MessageArguments)
{
FGuid ObjectKey;
// Message arguments are Name, Value, bGlobal
if (MessageArguments->GetSize() != 4
|| MessageArguments->GetType(0) != VTYPE_STRING
|| MessageArguments->GetType(1) != VTYPE_STRING
|| MessageArguments->GetType(2) != VTYPE_STRING
|| MessageArguments->GetType(3) != VTYPE_LIST
)
{
// Wrong message argument types or count
return false;
}
if (!FGuid::Parse(FString(MessageArguments->GetString(0).ToWString().c_str()), ObjectKey))
{
// Invalid GUID
return false;
}
// Get the promise callback and use that to report any results from executing this function.
FGuid ResultCallbackId;
if (!FGuid::Parse(FString(MessageArguments->GetString(2).ToWString().c_str()), ResultCallbackId))
{
// Invalid GUID
return false;
}
UObject* Object = GuidToPtr(ObjectKey);
if (Object == nullptr)
{
// Unknown uobject id
InvokeJSErrorResult(ResultCallbackId, TEXT("Unknown UObject ID"));
return true;
}
FName MethodName = MessageArguments->GetString(1).ToWString().c_str();
UFunction* Function = Object->FindFunction(MethodName);
if (!Function)
{
InvokeJSErrorResult(ResultCallbackId, TEXT("Unknown UObject Function"));
return true;
}
// Coerce arguments to function arguments.
uint16 ParamsSize = Function->ParmsSize;
TArray<uint8> Params;
UProperty* ReturnParam = nullptr;
UProperty* PromiseParam = nullptr;
// Convert cef argument list to a dictionary, so we can use FStructDeserializer to convert it for us
if (ParamsSize > 0)
{
CefRefPtr<CefDictionaryValue> NamedArgs = CefDictionaryValue::Create();
int32 CurrentArg = 0;
CefRefPtr<CefListValue> CefArgs = MessageArguments->GetList(3);
for ( TFieldIterator<UProperty> It(Function); It; ++It )
{
UProperty* Param = *It;
if (Param->PropertyFlags & CPF_Parm)
{
if (Param->PropertyFlags & CPF_ReturnParm)
{
ReturnParam = Param;
}
else
{
UStructProperty *StructProperty = Cast<UStructProperty>(Param);
if (StructProperty && StructProperty->Struct->IsChildOf(FWebJSResponse::StaticStruct()))
{
PromiseParam = Param;
}
else
{
CopyContainerValue(NamedArgs, CefArgs, CefString(*Param->GetName()), CurrentArg);
CurrentArg++;
}
}
}
}
// UFunction is a subclass of UStruct, so we can treat the arguments as a struct for deserialization
Params.AddUninitialized(ParamsSize);
Function->InitializeStruct(Params.GetData());
FWebJSStructDeserializerBackend Backend = FWebJSStructDeserializerBackend(SharedThis(this), NamedArgs);
FStructDeserializer::Deserialize(Params.GetData(), *Function, Backend);
}
if (PromiseParam)
{
FWebJSResponse* PromisePtr = PromiseParam->ContainerPtrToValuePtr<FWebJSResponse>(Params.GetData());
if (PromisePtr)
{
*PromisePtr = FWebJSResponse(SharedThis(this), ResultCallbackId);
}
}
Object->ProcessEvent(Function, Params.GetData());
CefRefPtr<CefListValue> Results = CefListValue::Create();
//.........这里部分代码省略.........