{ "info": { "author": "Ivan Korobkov", "author_email": "ivan.korobkov@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Code Generators", "Topic :: Software Development :: Compilers" ], "description": "Pdef Objective-C\n================\nObjective-C code generator for [Pdef compiler](https://github.com/pdef/pdef)\nand Objective-C implementation of descriptors, JSON format and HTTP RPC.\n\nRequirements\n------------\n- Objective-C: iOS 6.0, Mac OSX 10.8, AFNetworking 2.0.\n- Code generator: [Pdef compiler 1.2+](https://github.com/pdef/pdef),\n Python 2.6 or Python 3.3+.\n\nInstallation\n------------\n- Code generator:\n Install the code generator as a python package:\n ```bash\n $ pip install pdef-objc\n ```\n\n Or [download](https://github.com/pdef/pdef-objc/releases) the release,\n unzip it and in the `generator` directory run:\n ```bash\n $ python setup.py install\n ```\n\n- Objective-C package via CocoaPods:\n ```ruby\n pod \"Pdef\"\n ```\n\nCode generation\n---------------\nPass a pdef package path or a url to the compiler:\n```bash\n$ pdefc generate-objc https://raw.github.com/pdef/pdef/1.2/example/world.yaml \\\n --out Generated\n```\n\nMap namespaces to class prefixes with the `--prefix` argument:\n```bash\n$ pdefc generate-objc https://raw.github.com/pdef/pdef/1.2/example/world.yaml \\\n --prefix world.space:SP\n --prefix world:WL\n --out Generated\n```\n\nMessages\n--------\nGenerated messages implement the `isEqual`, `hash` methods, the `NSCopying` and `NSCoding`\nprotocols and support merging. The `copyWithZone` method returns a message deep copy.\nThe messages are not thread-safe. The examples are based on\nthe [pdef example package](https://github.com/pdef/pdef/tree/master/example).\n\n```objectivec\nHuman *human = [[Human alloc]init];\nhuman.id = 1;\nhuman.name = @\"John\";\nhuman.sex = Sex_MALE;\nhuman.continent = ContinentName_EUROPE;\n\nHuman *copy = [human copy];\nassert([human isEqual:copy]);\n```\n\nMessages support merging which deep copies fields from a source message to a destination one:\n```\nHuman *human = [[Human alloc]init];\n human.id = 1;\n human.name = @\"John\";\n human.sex = Sex_MALE;\n human.continent = ContinentName_EUROPE;\n\nHuman *another [[Human alloc]init];\n[another merge:human];\n\nassert([another isEqual:human]);\n```\n\nMessages use unboxed types for primitives and bool flags to indicate when a field is set or empty.\n```objectivec\n// Primitive fields return default values, has{FieldName} returns NO.\nHuman *human = [[Human alloc]init];\nassert(human.id == 0);\nassert([human hasId] == NO);\n\n// When a field is set has{FieldName} returns YES.\nhuman.id = 123;\nassert([human hasId] == YES);\n\n// Execute a special clear method to clear a field.\n[human clearId];\n```\n\nJSON Format\n-----------\nJSON serialization is based on `NSJSONSerialization` with the additional support\nto serialize/deserialize primitives as root JSON objects (not only objects and arrays).\n```objectivec\n// To a JSON-compatible dictionary.\nNSDictionary *dict = [human toDictionary];\n\n// To JSON data.\nNSError *error = nil;\nNSData *data = [human toJsonError:&error];\n```\n\nParsing:\n```objectivec\n// From a JSON-compatible dictionary, supports polymorphic messages.\nNSDictionary *dict = getJsonDictionary();\nHuman *human = [Human messageWithDictionary:dict];\n\n// From JSON data, supports polymorphic messages.\nHuman *human1 = [Human messageWithData:data error:&error];\n```\n\nUser `PDJsonFormat` to read/write other pdef data types:\n```objectivec\n// Serialize a list of ints.\nPDDataTypeDescriptor *listd = [PDDescriptors listWithElement:[PDDescriptors int32]];\nNSArray *array = @[@1, @2, @3];\nNSError *error = nil;\nNSString *json = [PDJsonFormat writeString:array descriptor:listd error:&error];\n\n// Parse a list of ints.\nNSArray *parsed = [PDJsonFormat readString:array descriptor:listd error:&error];\n```\n\nHTTP RPC Client\n---------------\nRPC client is based on [AFNetworking](https://github.com/AFNetworking/AFNetworking),\nthe implementation is thread-safe.\n\n```\n// Create an RPC client as an invocation handler.\nPDRpcClient *handler = [[PDRpcClient alloc]\n initWithDescriptor:WorldDescriptor()\n baseUrl:@\"http://example.com/world\"];\n\n// Create a generated protocol client and pass the handler to it.\nWorld *world = [[WorldClient alloc] initWithHandler:client];\n\n// Execute a void remote method.\n[world switchDayNightCallback:^(id result, NSError *error) {\n NSLog(@\"Switched the light\");\n}];\n\n// Execute a remote method with result.\n[[world humans] allLimit:10 offset:0 callback:^(id result, NSError *error) {\n if (error) {\n NSLog(@\"%@\", error.localizedDescription);\n } else {\n NSArray *humans = result;\n for (Human *h in humans) {\n NSLog(@\"%@\", h.name);\n }\n }\n}];\n```\n\nInitialize the `PDRpcClient` with a custom `NSURLSession` or `AFURLSessionManager`\nwhen you need custom headers, or subclass it.\n\nRemote application errors are passed as `NSErrors` with the `PDefErrorDomain` domain\nand the `PDRpcException` code, the exception message is put in the user dict\nunder the `PDRpcExceptionKey` key.\n```\n// Get a remote exception.\n[[world humans] allLimit:10 offset:0 callback:^(id result, NSError *error) {\n if ([error.domain isEqualToString:PDefErrorDomain] && error.code == PDRpcException) {\n PDMessage *exception = [error.userInfo objectForKey:PDRpcExceptionKey];\n }\n}];\n\n// Or a simplified version.\n[[world humans] allLimit:10 offset:0 callback:^(id result, NSError *error) {\n if (PDIsRpcError(error)) {\n PDMessage *exception = PDGetRpcException(error);\n }\n}];\n```\n\nObjective-C does not have a server implementation.\n\nLicense and Copyright\n---------------------\nCopyright: 2013 Ivan Korobkov \n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/pdef/pdef-objc", "keywords": null, "license": "Apache License 2.0", "maintainer": null, "maintainer_email": null, "name": "pdef-objc", "package_url": "https://pypi.org/project/pdef-objc/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pdef-objc/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/pdef/pdef-objc" }, "release_url": "https://pypi.org/project/pdef-objc/1.2.0/", "requires_dist": null, "requires_python": null, "summary": "Pdef Objective-C generator", "version": "1.2.0" }, "last_serial": 996969, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "4ad1eb9d4fced5e5749116ff27a9bd30", "sha256": "9325ed1b72fa231c01aae100f64a7c30a1d3ac953c942afc5b6a65ed068c35ad" }, "downloads": -1, "filename": "pdef-objc-1.0.0.tar.gz", "has_sig": false, "md5_digest": "4ad1eb9d4fced5e5749116ff27a9bd30", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12472, "upload_time": "2013-12-04T13:02:51", "url": "https://files.pythonhosted.org/packages/d0/43/5d85bd502973c88a4609b62daeec01675f49010d6081f3d1d7a765e2e7e0/pdef-objc-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "d8408062ec65debce90b8118ad149cdd", "sha256": "48ddb001e70b272c6b551c9d4677df91c6445936ece0d75faf30cb2c0d097aff" }, "downloads": -1, "filename": "pdef-objc-1.0.1.tar.gz", "has_sig": false, "md5_digest": "d8408062ec65debce90b8118ad149cdd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12581, "upload_time": "2013-12-18T16:37:33", "url": "https://files.pythonhosted.org/packages/7a/8f/89b0b303e97070eb4519b4b2e0f0c2af141494157819d066ecd757f31a5c/pdef-objc-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "2efb00270d2094a9cace35543e747019", "sha256": "c394ca4f4b8967f9cf61639b68d17fd11f63f7272323590c82e8d1e57899c4ab" }, "downloads": -1, "filename": "pdef-objc-1.1.0.tar.gz", "has_sig": false, "md5_digest": "2efb00270d2094a9cace35543e747019", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12511, "upload_time": "2013-12-22T16:32:35", "url": "https://files.pythonhosted.org/packages/92/75/22746ef392994d3e851c748c5f27754f46ccf7b76cb4d627aaf72c3b4738/pdef-objc-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "326efd340c872248acd94b309367abb4", "sha256": "52757877ecfc36dc89a6515b5faf716e173e0f5625e050b43dd8e68a060d0216" }, "downloads": -1, "filename": "pdef-objc-1.1.1.tar.gz", "has_sig": false, "md5_digest": "326efd340c872248acd94b309367abb4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12516, "upload_time": "2014-01-14T10:52:02", "url": "https://files.pythonhosted.org/packages/f6/f4/647ca1a2aaa96d45c0e82f4fe408cb01b42bed1a009b3e8a0688dbd7dfe4/pdef-objc-1.1.1.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "6d4e3c31d6f619852c6b1fff8f82adb2", "sha256": "d016121270900be0bcb25e4d520266d58136bcc6288365f58c20f062f365cd80" }, "downloads": -1, "filename": "pdef-objc-1.2.0.tar.gz", "has_sig": false, "md5_digest": "6d4e3c31d6f619852c6b1fff8f82adb2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12561, "upload_time": "2014-02-11T10:27:04", "url": "https://files.pythonhosted.org/packages/66/32/3f181c04f141224710b423b4e3678d9bf1894cad13e58edfd566d2352d95/pdef-objc-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6d4e3c31d6f619852c6b1fff8f82adb2", "sha256": "d016121270900be0bcb25e4d520266d58136bcc6288365f58c20f062f365cd80" }, "downloads": -1, "filename": "pdef-objc-1.2.0.tar.gz", "has_sig": false, "md5_digest": "6d4e3c31d6f619852c6b1fff8f82adb2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12561, "upload_time": "2014-02-11T10:27:04", "url": "https://files.pythonhosted.org/packages/66/32/3f181c04f141224710b423b4e3678d9bf1894cad13e58edfd566d2352d95/pdef-objc-1.2.0.tar.gz" } ] }