Когда возврат E_POINTER и когда E_INVALIDARG?

Быстрое объяснение того, что это означает:

В рубине, можно определить методы на конкретном объекте:

a = "hello"

def a.informal
  "hi"
end

a.informal
=> "hi"

, Что происходит, когда Вы делаете, который является, что объект a, который имеет класс String, изменил свой класс на "фантомный" класс, иначе метакласс, singleton-класс или eigenclass. Тот новый суперкласс класса String.

кроме того, в определениях классов, self установлен на определяемый класс, таким образом

class Greeting
  def self.say_hello
    "Hello"
  end
  #is the same as:
  def Greeting.informal
    "hi"
  end
end

, Что происходит, существует то, что объект Greeting, который имеет класс Class, получает новый метакласс с новыми методами, поэтому когда Вы звоните

Greeting.informal
=> "hi"

нет такой вещи, как методы класса в рубине, но семантика подобны.

9
задан sharptooth 15 September 2009 в 00:54
поделиться

1 ответ

You return E_POINTER when the reference to the pointer of an out parameter is null, this consider to be an error code that indicates a bug in the program or in the interop layer.

You return E_INVALIDARG when there is an application level on with the parameter for example out of range issue or parameter that collide with each other.

In Your case, in SaveToFile(...) you should return E_INVLIADARG since it is not valid to pass empty file name, and in GetAttributes(...) you should return E_POINTER (if it's an out param) because you cannot fill the value.

And yes, we all L-O-V-E com :)

11
ответ дан 3 November 2019 в 01:02
поделиться
Другие вопросы по тегам:

Похожие вопросы: