是否可以修改 swig 生成的代码?我想替换 swig 生成的代码。例如
我有结构
typedef struct Test {
char *buffer;
} Test;
Swig 将创建以下代码
SWIGEXPORT void JNICALL Java_Test_1buffer_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
struct Test *arg1 = (struct Test *) 0 ;
char *arg2 = (char *) 0 ;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = (struct Test*)&jarg1;
arg2 = 0;
{
if (arg2) {
arg1->buffer= (char const *) malloc(strlen((const char *)arg2)+1);
strcpy((char *)arg1->buffer, (const char *)arg2);
} else {
arg1->buffer= 0;
}
}
if (arg2) (*jenv)->ReleaseStringUTFChars(jenv, jarg2, (const char *)arg2);
}
是否可以strcpy
用其他功能代替customized_strcpy
?