Cosmetic tidyup in smartptr feature code and document smartptr fix in previous commit

This commit is contained in:
William S Fulton 2013-04-17 21:47:36 +01:00
commit 296498c159
3 changed files with 11 additions and 12 deletions

View file

@ -3389,7 +3389,7 @@ public:
String *norm_name = SwigType_namestr(Getattr(n, "name"));
String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect");
String *swig_director_connect_jni = makeValidJniName(swig_director_connect);
String *smartptr_feature = Getattr(n, "feature:smartptr");
String *smartptr = Getattr(n, "feature:smartptr");
String *dirClassName = directorClassName(n);
Wrapper *code_wrap;
@ -3401,15 +3401,11 @@ public:
"SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jswig_mem_own, "
"jboolean jweak_global) {\n", jnipackage, jni_imclass_name, swig_director_connect_jni);
if (Len(smartptr_feature)) {
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr_feature, smartptr_feature);
if (Len(smartptr)) {
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr, smartptr);
Printf(code_wrap->code, " (void)jcls;\n");
Printf(code_wrap->code, " // NOTE: Pulling the raw pointer out of the smart pointer as the following code does\n");
Printf(code_wrap->code, " // is generally a bad idea. However, in this case we keep a local instance of the\n");
Printf(code_wrap->code, " // smart pointer around while we are using the raw pointer, which should keep the\n");
Printf(code_wrap->code, " // raw pointer alive. This is done instead of using the smart pointer's dynamic cast\n");
Printf(code_wrap->code, " // feature since different smart pointer implementations have differently named dynamic\n");
Printf(code_wrap->code, " // cast mechanisms.\n");
Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n");
Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n");
Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName);
}
else {