Skip to content
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

Change enumeration typemaps in SWIG Java #2233

Closed
pjsipbot opened this issue Sep 24, 2019 · 0 comments
Closed

Change enumeration typemaps in SWIG Java #2233

pjsipbot opened this issue Sep 24, 2019 · 0 comments

Comments

@pjsipbot
Copy link
Collaborator

2019-09-24 12:10:44: @nanangizz created the issue on trac ticket 2233

Currently we use SWIG default typemap for enumeration, i.e: typesafe enums. But now we find that it may not be the best approach for PJSIP (see pro vs cons below). This ticket will change the typemap to type-unsafe enums.

Pro:

  • Some PJSIP C enumerations are actually not pure enumeration, for example PJSIP_TRANSPORT_IPV6 in pjsip_transport_type_e is actually a bitflag value.
  • After SWIG exception in mapping an invalid C++ enum value to Java (continuation of #2121) #2219, there is still crash reported that may be caused by enumeration.
  • Method swigToEnum() generated by SWIG for typesafe enum contains iteration which is not efficient on enumeration types whose big and non-contiguous values, e.g: pj_ssl_cert_verify_flag_t whose values ranging from 0 to (1<<31) with exponentially increased intervals.
  • Some PJSIP enumerations define only subset values, e.g: pj_ssl_cipher only defines some basic SSL/TLS ciphers, so any Java variable typed pj_ssl_cipher or function returning pj_ssl_cipher cannot contain or return non basic ciphers.

Cons:

  • Backward compatibility issue!

Changes to be done in application

As described above, this ticket introduces backward compatibility issues, here are modifications needed to be done in Java applications:

  • accessing enumeration value is no longer using swigValue() method, e.g: pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED.swigValue() must be changed to pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED.
  • all enumeration types are now int, e.g: pjsip_status_code code must be changed to int code

2019-09-24 12:12:47: @nanangizz changed status from new to closed


2019-09-24 12:12:47: @nanangizz set owner to @nanangizz


2019-09-24 12:12:47: @nanangizz set resolution to fixed


2019-09-24 12:12:47: @nanangizz commented

In r6075:
Close #2233: Changed enumeration approach in SWIG Java to type-unsafe enums.

@pjsipbot pjsipbot added this to the release-2.10 milestone Feb 14, 2020
qmphan pushed a commit to qmphan/pjproject that referenced this issue Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants