nsIURI 没有成员“asciiSpec”、“asciiHost”等错误

发布于 2024-12-17 04:01:55 字数 1145 浏览 4 评论 0原文

我对 Mozilla (6.0.2) 代码中的 nsMediaStream.h/cpp 进行了一些修改,其中之一要求我从 Mozilla 框架用于表示和解析 URI 的 nsIURI 类中获取 ASCII 字符串。人们可能会想,这似乎很容易。 Mozilla 文档 (https://developer.mozilla.org/en/nsIURI) 告诉我我可以使用属性 asciiSpec 来获取这样的字符串。 nsACString 的文档非常混乱,但那是另一回事了。

问题在于,当我尝试使用 nsMediaStream 的 nsIURI 变量 mURI 时,

mURI->asciiSpec

我从 MSVC 编译器中收到以下错误:

[..]/content/media/nsMediaStream.cpp(146) :
 error C2039: 'asciiSpec' : is not a member of 'nsIURI'
        [..]\obj-i686-pc-mingw32\dist\include\nsIURI.h(83) : see declaration of 'nsIURI'

当我查看引用的 nsIURI.h 文件(该文件是从接口 IDL 文件生成的)时,我看到以下: http://google -web-toolkit.googlecode.com/svn/plugin-sdks/gecko-sdks/gecko-1.9.0/include/nsIURI.h

据我所知可以看出,所述头文件与 Mozilla 代码中使用的 nsIURI 完全无关,并且看起来更像是接口/原型而不是实际的类。文档中列出的属性和方法都不存在。 MSVC 似乎同意我的观点。

我觉得我在这里错过了一些大东西,但即使在 Mozilla 源代码中花费了几个月的时间并在构建系统中幸存下来之后,我似乎也无法弄清楚这个问题,到目前为止我问过的其他人也无法弄清楚。任何线索将不胜感激:)

I have made some modifications to nsMediaStream.h/cpp in the Mozilla (6.0.2) code and one of them requires that I get the ASCII string from the nsIURI class used by the Mozilla framework for representing and parsing URIs. Seems easy enough, one might think. The Mozilla documentation (https://developer.mozilla.org/en/nsIURI) tells me that I can use the attribute asciiSpec to obtain such a string. The documentation for nsACString is horribly confusing, but that's another matter.

Where things go south is that when I try to use the nsIURI variable mURI of nsMediaStream using

mURI->asciiSpec

I get the following error from the MSVC compiler:

[..]/content/media/nsMediaStream.cpp(146) :
 error C2039: 'asciiSpec' : is not a member of 'nsIURI'
        [..]\obj-i686-pc-mingw32\dist\include\nsIURI.h(83) : see declaration of 'nsIURI'

When I look at the referenced nsIURI.h file, which is generated from an interface IDL file, I see the following: http://google-web-toolkit.googlecode.com/svn/plugin-sdks/gecko-sdks/gecko-1.9.0/include/nsIURI.h

As far as I can tell said header file has no relevance at all to nsIURI as used in the Mozilla code and seems more of an interface/prototype than an actual class. None of the attributes and methods listed in the documentation are present. MSVC seems to agree with me on this.

I feel like I'm missing something big here, but even after spending months in the Mozilla source and surviving the build system I can't seem to figure this one out, nor can anyone else I have asked so far. Any clues would be more than appreciated :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫罗兰の梦幻 2024-12-24 04:01:55

当从 C++ 使用 XPCOM 时,没有属性 - 所有接口属性都转换为 getter/setter 方法。接口定义文件(IDL 文件)使用 xpidl 工具编译为常规 C++ 头文件 - 因此您找到的文件是正确的,但它是自动生成的。您将获得如下所示的 asciiSpec 属性:

nsCString spec;
nsresult rv = mURI->GetAsciiSpec(spec);
if (NS_FAILED(rv))
  ...  // handle error
else
  ...  // do something with spec variable

没有 SetAsciiSpec 方法,因为此属性是只读的。

When using XPCOM from C++ there are no properties - all interface properties are transformed into getter/setter methods. The interface definition files (IDL files) are compiled into regular C++ header files using xpidl tool - so the file you found is the correct one but it is generated automatically. You would get asciiSpec property like this:

nsCString spec;
nsresult rv = mURI->GetAsciiSpec(spec);
if (NS_FAILED(rv))
  ...  // handle error
else
  ...  // do something with spec variable

There is no SetAsciiSpec method because this property is read-only.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文