Skip to content

Convenience types and methods #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
IngwiePhoenix opened this issue Sep 11, 2014 · 1 comment
Open

Convenience types and methods #58

IngwiePhoenix opened this issue Sep 11, 2014 · 1 comment

Comments

@IngwiePhoenix
Copy link
Contributor

Hey.

When working with objects in a C++ function, it turns out that its quite hard to avoid boilerplate code.

I would like to make a few suggestions:

  • Offer wrapper types to access values in objects/arrays. Example: OS::Object obj = os->toObj(...); std::string str = obj["foo"];
  • Offer convenience methods to convert arrays into lists: OS::List ls = os->toList(...); std::string str = ls[0];

I am mainly asking, since I am trying to write a converter between (VarObject)[https://github.com/eJimLee/VarObject] and an OS Object.

I just can't seem to find a "good" way of doing it. So having a method provided by the internals would be very nice. Do you think this could be implemented?

Kind regards, Ingwie.

@unitpoint
Copy link
Owner

Programmer have to write own utility functions to convert data between ObjectScript and C++. Note that ObjectScript supports any ObjectScript's value type as key of object property.

Any ObjectScript object has id (see getValueId, pushValuebyId, retainValueById, releaseValueById). Numbers, booleans and null have no id because they are not controlled by garbage collector.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants