Ejemplo n.º 1
0
bool CDBusMessage::AppendArgument(const char **arrayString, unsigned int length)
{
  PrepareArgument();
  DBusMessageIter sub;
  bool success = dbus_message_iter_open_container(&m_args, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING_AS_STRING, &sub);

  for (unsigned int i = 0; i < length && success; i++)
    success &= dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &arrayString[i]);

  success &= dbus_message_iter_close_container(&m_args, &sub);

  return success;
}
Ejemplo n.º 2
0
bool CDBusMessage::AppendArgument(const char *string)
{
  PrepareArgument();
  return dbus_message_iter_append_basic(&m_args, DBUS_TYPE_STRING, &string);
}
Ejemplo n.º 3
0
void UGatherTextFromSourceCommandlet::FStringMacroDescriptor::TryParse(const FString& Text, FSourceFileParseContext& Context) const
{
    // Attempt to parse something of the format
    // MACRONAME(param0, param1, param2)

    if (!Context.ExcludedRegion && (Context.Filename.EndsWith(TEXT(".inl")) || (!Context.WithinBlockComment && !Context.WithinLineComment && !Context.WithinStringLiteral)) )
    {
        TArray<FString> ArgArray;
        if (ParseArgsFromMacro(Text, ArgArray, Context))
        {
            int32 NumArgs = ArgArray.Num();

            if (NumArgs != Arguments.Num())
            {
                UE_LOG(LogGatherTextFromSourceCommandlet, Warning, TEXT("Too many arguments in %s macro in %s(%d):%s"), *GetToken(), *Context.Filename, Context.LineNumber, *MungeLogOutput(Context.LineText));
            }
            else
            {
                FString Identifier;
                FString Namespace = Context.Namespace;
                FString SourceLocation = FString( Context.Filename + TEXT(" - line ") + FString::FromInt(Context.LineNumber) );
                FString SourceText;

                bool ArgParseError = false;
                for (int32 ArgIdx=0; ArgIdx<Arguments.Num(); ArgIdx++)
                {
                    FMacroArg Arg = Arguments[ArgIdx];
                    FString ArgText = ArgArray[ArgIdx].Trim();

                    bool HasQuotes;
                    FString MacroDesc = FString::Printf(TEXT("argument %d of %d in localization macro %s %s(%d):%s"), ArgIdx+1, Arguments.Num(), *GetToken(), *Context.Filename, Context.LineNumber, *MungeLogOutput(Context.LineText));
                    if (!PrepareArgument(ArgText, Arg.IsAutoText, MacroDesc, HasQuotes))
                    {
                        ArgParseError = true;
                        break;
                    }

                    switch (Arg.Semantic)
                    {
                    case MAS_Namespace:
                    {
                        Namespace = ArgText;
                    }
                    break;
                    case MAS_Identifier:
                    {
                        Identifier = ArgText;
                    }
                    break;
                    case MAS_SourceText:
                    {
                        SourceText = ArgText;
                    }
                    break;
                    }
                }

                if ( Identifier.IsEmpty() )
                {
                    //The command doesn't have an identifier so we can't gather it
                    UE_LOG(LogGatherTextFromSourceCommandlet, Warning, TEXT("Macro doesn't have unique identifier. %s"), *SourceLocation );
                    return;
                }

                if (!ArgParseError && !Identifier.IsEmpty() && !SourceText.IsEmpty())
                {
                    FContext MacroContext;
                    MacroContext.Key = Identifier;
                    MacroContext.SourceLocation = SourceLocation;

                    Context.AddManifestText( GetToken(), Namespace, SourceText, MacroContext );
                }
            }
        }
    }
}
Ejemplo n.º 4
0
bool CDBusMessage::AppendObjectPath(const char *object)
{
  PrepareArgument();
  return dbus_message_iter_append_basic(&m_args, DBUS_TYPE_OBJECT_PATH, &object);
}
Ejemplo n.º 5
0
void UGatherTextFromSourceCommandlet::FCommandMacroDescriptor::TryParse(const FString& Text, FSourceFileParseContext& Context) const
{
    // Attempt to parse something of the format
    // UI_COMMAND(LocKey, DefaultLangString, DefaultLangTooltipString, <IgnoredParam>, <IgnoredParam>)

    if (!Context.ExcludedRegion && (Context.Filename.EndsWith(TEXT(".inl")) || (!Context.WithinBlockComment && !Context.WithinLineComment && !Context.WithinStringLiteral)) )
    {
        TArray<FString> Arguments;
        if (ParseArgsFromMacro(Text, Arguments, Context))
        {
            if (Arguments.Num() != 5)
            {
                UE_LOG(LogGatherTextFromSourceCommandlet, Warning, TEXT("Too many arguments in command %s macro in %s(%d):%s"), *GetToken(), *Context.Filename, Context.LineNumber, *MungeLogOutput(Context.LineText));
            }
            else
            {
                FString Identifier = Arguments[0].Trim();
                const FString UICommandRootNamespace = TEXT("UICommands");
                FString Namespace = Context.WithinNamespaceDefine && !Context.Namespace.IsEmpty() ? FString::Printf( TEXT("%s.%s"), *UICommandRootNamespace, *Context.Namespace) : UICommandRootNamespace;
                FString SourceLocation = FString( Context.Filename + TEXT(" - line ") + FString::FromInt(Context.LineNumber) );
                FString SourceText = Arguments[1].Trim();

                if ( Identifier.IsEmpty() )
                {
                    //The command doesn't have an identifier so we can't gather it
                    UE_LOG(LogGatherTextFromSourceCommandlet, Warning, TEXT("UICOMMAND macro doesn't have unique identifier. %s"), *SourceLocation );
                    return;
                }

                // parse DefaultLangString argument - this arg will be in quotes without TEXT macro
                bool HasQuotes;
                FString MacroDesc = FString::Printf(TEXT("\"FriendlyName\" argument in %s macro %s(%d):%s"), *GetToken(), *Context.Filename, Context.LineNumber, *Context.LineText);
                if ( PrepareArgument(SourceText, true, MacroDesc, HasQuotes) )
                {
                    if ( HasQuotes && !Identifier.IsEmpty() && !SourceText.IsEmpty() )
                    {
                        // First create the command entry
                        FContext CommandContext;
                        CommandContext.Key = Identifier;
                        CommandContext.SourceLocation = SourceLocation;

                        Context.AddManifestText( GetToken(), Namespace, SourceText, CommandContext );

                        // parse DefaultLangTooltipString argument - this arg will be in quotes without TEXT macro
                        FString TooltipSourceText = Arguments[2].Trim();
                        MacroDesc = FString::Printf(TEXT("\"InDescription\" argument in %s macro %s(%d):%s"), *GetToken(), *Context.Filename, Context.LineNumber, *Context.LineText);
                        if (PrepareArgument(TooltipSourceText, true, MacroDesc, HasQuotes))
                        {
                            if (HasQuotes && !TooltipSourceText.IsEmpty())
                            {
                                // Create the tooltip entry
                                FContext CommandTooltipContext;
                                CommandTooltipContext.Key = Identifier + TEXT("_ToolTip");
                                CommandTooltipContext.SourceLocation = SourceLocation;

                                Context.AddManifestText( GetToken(), Namespace, TooltipSourceText, CommandTooltipContext );
                            }
                        }
                    }
                }
            }
        }
    }
}