Apple Carbon/CoreFoundation 风格指南?

发布于 2024-08-20 03:07:11 字数 323 浏览 13 评论 0原文

Cocoa 有详细的文档,并且有很多关于以良好形式编写 Cocoa 代码的信息。我正在编写一些与硬件密切配合的代码,需要我经常使用 CoreFoundation 和 Carbon API。是否有任何类型的“风格”指南可以帮助您理解 Apple 的 Carbon 和 CoreFoundation 等库? Apple 的示例代码中充斥着以下内容:

  • kSomeValue
  • CFMightDoSomethingUseful

我可以推断出 CF 表示 CoreFoundation,k 可能表示常量或枚举类型,但我想验证这一点并了解有关其他语法样式的更多信息。

Cocoa is well-documented and there is a lot of information on writing Cocoa code in good form. I'm working on some code that works closely with hardware, requiring me to use CoreFoundation and Carbon APIs often. Is there any sort of 'style' guide for understanding libraries such as Carbon and CoreFoundation from Apple? Apple's example code is littered with things like:

  • kSomeValue
  • CFMightDoSomethingUseful

I can deduce that CF means CoreFoundation and k might be for constants or enumerated types, but I would like to verify this and learn more about the other syntactic styles.

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

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

发布评论

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

评论(2

雨巷深深 2024-08-27 03:07:11

Mac 开发中心的核心基础设计概念实际上已经清除提出我的问题。

Core Foundation Design Concepts at the Mac Dev Center actually cleared up my question.

肩上的翅膀 2024-08-27 03:07:11

我可以推断 CF 意味着 CoreFoundation ...

具体来说,它是Core Foundation框架中函数、类型和常量的前缀。

...和 ​​k 可能用于常量或枚举类型...

是的。这可以追溯到 Toolbox 时代,甚至在 Core Foundation 存在之前。我相信这是帕斯卡的习俗。

除了这些规则之外,我不知道任何通用的 CF/Carbon 风格指南。

您可以尝试更笼统地学习一些关于 C 风格的书籍。它们之间的比较和对比;通常没有客观正确的答案。

我喜欢的一本是艾伦·霍鲁布(Allen Holub)所著的《足够的绳子搬起石头砸自己的脚》。它很机智,并提出了一些很好的案例。 Holub 在他的网站上有摘要版本(只是规则本身,没有详细解释);据我所知,整本书已经绝版了。

I can deduce that CF means CoreFoundation …

Specifically, it's the prefix for functions, types, and constants in the Core Foundation framework.

… and k might be for constants or enumerated types…

Yup. This one dates back all the way to the Toolbox days, before Core Foundation even existed. I believe it was a Pascal custom.

Aside from these rules, I'm not aware of any general CF/Carbon style guides.

You might try going even more general and picking up some books on C style. Compare and contrast between them; there is often no objectively-right answer.

One that I like is “Enough Rope to Shoot Yourself in the Foot”, by Allen Holub. It's witty and makes some good cases. Holub has a summary version on his website (just the rules themselves, without the detailed explanations); as far as I can tell, the full book is out of print.

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