开发者

MessagePack implementation for Objective-C

开发者 https://www.devze.com 2023-03-15 05:47 出处:网络
Is there an implementation of the MessagePack protocol for Objective-C? If not, are there开发者_JAVA技巧 examples for bridging the C implementation to Objective-C types?If by bridge you mean the poss

Is there an implementation of the MessagePack protocol for Objective-C?

If not, are there开发者_JAVA技巧 examples for bridging the C implementation to Objective-C types?


If by bridge you mean the possibility of accessing one language feature from another language, then there is no need of bridging between Objective-C and C. You can call C code directly from Objective-C, so you can use C-MessagePack types directly.

I suppose you already know this, so what you are looking for is a bridge (or adapter, or facade, or bindings, or any of many other names) between Objective-C and MessagePack, allowing you to use MessagePack in a more "Objective-C"-like way.

So I assume that you problem is that the C-API to MessagePack is really "low-level" and that you are looking for an "higher-level" API to MessagePack from Objective-C.

A few proposals:

  1. instead of using the C-API, use the C++ API for MessagePack. This is straightforward and could easily do the job for you. Indeed, the MessagePack C++-API is pretty good, in my opinion, and if you name your Objective-C file with an ".mm" extension, you can mix Objective-C and C++ code in it (this is called Objective-C++).

  2. if you are looking for an even higher-level API to MessagePack, you could use the Python-API and then the Python-Objective-C bridge to allow for mixing Objective-C and Python code. Your performance may vary.

  3. if you are really after the implementation of some kind of intermediate layer (call it as you like) between Objective-C and MessagePack C API, I would suggest using the C++ or Python API to MessagePack as example of design, depending on which language you are most familiar with. So, e.g., you would use an NSArray where a std:vector (or a Python vector) is used, and so on. This should provide a straight way into design of this intermediate layer.


There is now an official implementation under the MessagePack project.

https://github.com/msgpack/msgpack-objectivec


https://github.com/chrishulbert/msgpack

Chris Hulbert just implemented and released one.

See his blog for more info:

http://splinter.com.au/messagepack-parser-for-objective-c-iphone

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号