Skip to content

Commit

Permalink
tweak chugin api version printing
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Oct 22, 2023
1 parent 1b3f6c2 commit fb50c3b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/core/chuck_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ t_CKBOOL load_external_module_at_path( Chuck_Compiler * compiler,
}

// print
EM_log_opts( CK_LOG_SEVERE, EM_LOG_NO_PREFIX, "[%s] (API version: %d.%d)", TC::green("OK",true).c_str(), dll->versionMajor(), dll->versionMinor() );
EM_log_opts( CK_LOG_SEVERE, EM_LOG_NO_PREFIX, "[%s]", TC::green("OK",true).c_str() );
// add to compiler
compiler->m_dlls.push_back(dll);
// commit operator overloads | 1.5.1.5
Expand Down
21 changes: 11 additions & 10 deletions src/core/chuck_dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,12 +917,12 @@ const Chuck_DL_Query * Chuck_DLL::query()
// check version
t_CKUINT dll_version = m_api_version_func();
// get major and minor version numbers
m_versionMajor = CK_DLL_VERSION_GETMAJOR(dll_version);
m_versionMinor = CK_DLL_VERSION_GETMINOR(dll_version);
m_apiVersionMajor = CK_DLL_VERSION_GETMAJOR(dll_version);
m_apiVersionMinor = CK_DLL_VERSION_GETMINOR(dll_version);
// is version ok
t_CKBOOL version_ok = FALSE;
// major version must be same; minor version must less than or equal
if( m_versionMajor == CK_DLL_VERSION_MAJOR && m_versionMinor <= CK_DLL_VERSION_MINOR)
if( m_apiVersionMajor == CK_DLL_VERSION_MAJOR && m_apiVersionMinor <= CK_DLL_VERSION_MINOR)
version_ok = TRUE;

// if version not okay
Expand All @@ -932,7 +932,7 @@ const Chuck_DL_Query * Chuck_DLL::query()
ostringstream oss;
oss << "chugin API version incompatible..." << endl
<< "chugin path: '" << m_filename << "'" << endl
<< "chugin API version: " << m_versionMajor << "." << m_versionMinor
<< "chugin API version: " << m_apiVersionMajor << "." << m_apiVersionMinor
<< " VS host API version: " << CK_DLL_VERSION_MAJOR << "." << CK_DLL_VERSION_MINOR;
m_last_error = oss.str();
return NULL;
Expand Down Expand Up @@ -1082,8 +1082,8 @@ t_CKBOOL Chuck_DLL::probe()
// check version
t_CKUINT dll_version = m_api_version_func();
// get major and minor version numbers
m_versionMajor = CK_DLL_VERSION_GETMAJOR(dll_version);
m_versionMinor = CK_DLL_VERSION_GETMINOR(dll_version);
m_apiVersionMajor = CK_DLL_VERSION_GETMAJOR(dll_version);
m_apiVersionMinor = CK_DLL_VERSION_GETMINOR(dll_version);

return TRUE;
}
Expand Down Expand Up @@ -1182,7 +1182,7 @@ t_CKUINT Chuck_DLL::versionMajor()
// probe dll
if( !this->probe() ) return 0;
// return
return m_versionMajor;
return m_apiVersionMajor;
}


Expand All @@ -1197,7 +1197,7 @@ t_CKUINT Chuck_DLL::versionMinor()
// probe dll
if( !this->probe() ) return 0;
// return
return m_versionMinor;
return m_apiVersionMinor;
}


Expand All @@ -1213,10 +1213,11 @@ t_CKBOOL Chuck_DLL::compatible()
if( !this->probe() ) return FALSE;
// major version must be same between chugin and host
// chugin minor version must less than or equal host minor version
if( m_versionMajor == CK_DLL_VERSION_MAJOR && m_versionMinor <= CK_DLL_VERSION_MINOR )
if( m_apiVersionMajor == CK_DLL_VERSION_MAJOR && m_apiVersionMinor <= CK_DLL_VERSION_MINOR )
{ return TRUE; }
else {
m_last_error = string("incompatible API version: chugin (") + ck_itoa(m_versionMajor) + "." + ck_itoa(m_versionMinor)
m_last_error = string("incompatible API version: chugin (")
+ ck_itoa(m_apiVersionMajor) + "." + ck_itoa(m_apiVersionMinor)
+ string(") vs. host (")
+ ck_itoa(CK_DLL_VERSION_MAJOR) + "." + ck_itoa(CK_DLL_VERSION_MINOR)
+ ")";
Expand Down
6 changes: 3 additions & 3 deletions src/core/chuck_dl.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ struct Chuck_DLL : public Chuck_VM_Object
Chuck_DLL( Chuck_Carrier * carrier, const char * xid = NULL )
: m_handle(NULL), m_id(xid ? xid : ""),
m_done_query(FALSE), m_api_version_func(NULL), m_info_func(NULL), m_query_func(NULL),
m_query( carrier, this ), m_versionMajor(0), m_versionMinor(0)
m_query( carrier, this ), m_apiVersionMajor(0), m_apiVersionMinor(0)
{ }
// destructor
~Chuck_DLL() { this->unload(); }
Expand All @@ -790,8 +790,8 @@ struct Chuck_DLL : public Chuck_VM_Object
Chuck_DL_Query m_query;

protected: // addition info 1.5.0.4 (ge) added
t_CKUINT m_versionMajor;
t_CKUINT m_versionMinor;
t_CKUINT m_apiVersionMajor;
t_CKUINT m_apiVersionMinor;
};


Expand Down

0 comments on commit fb50c3b

Please sign in to comment.