Notepad ++提供了一个功能列表.
我目前正在使用Notepad ++ 6.5
functionList.xml使用正则表达式定义函数名称的解析器.
以下代码定义了c函数的解析器
<parser id="c_function" displayName="C source" commentExpr="((/\*.*?\*)/|(//.*?$))">
<function
mainExpr="^[\t ]*((static|const|virtual)[\s]+)?[\w:]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+)([\w_]+[\s]*::)?(?!(if|while|for))[\w_]+[\s]*\([^\)\(]*\)([\s]*const[\s]*)?[\n\s]*\{"
displayMode="$functionName">
<functionName>
<nameExpr expr="(?!(if|while|for))[\w_~]+[\s]*\("/>
<nameExpr expr="(?!(if|while|for))[\w_~]+"/>
</functionName> </function>
</parser>
Run Code Online (Sandbox Code Playgroud)
我在网上尝试了我的正则表达式,一切都很好.但它不能以某种方式对functionList.xml起作用.功能列表保持为空.
这对于Lua函数看起来如何?
这是我的尝试:
<parser id="lua_function" displayName="Lua Function" commentExpr="((--\[\[\*.*?\*)/|(--.*[\n\s\w\t]*\]\]))">
<function
mainExpr="^[\t\s]*(function)[\s]+[\w]+\("
displayMode="$functionName">
<functionName>
<nameExpr expr="(?:(function[\s]+))[\w]+"/>
</functionName>
</function>
</parser>
Run Code Online (Sandbox Code Playgroud) 我有一个单独的label.js文件,我在其中定义了一个自定义叠加层.它使用google.maps.OverlayView作为其原型:
Label.prototype = new google.maps.OverlayView();
Run Code Online (Sandbox Code Playgroud)
我不知道在我的index.html文件中将js文件的脚本标记放在何处.如果我将脚本标记放在google maps加载标记下面,如下所示:
....
<script async defer
src="https://maps.googleapis.com/maps/api/js?...
</script>
<script src="js/label.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
label.js文件会立即加载,而地图api尚未加载导致错误.
我目前通过在我的地图加载的回调中手动加载JS来解决这个问题:
function initMap() {
gMap = new google.maps.Map(document.getElementById(strMapDivName), {
center: {lat: 21, lng: 78},
mapTypeId: google.maps.MapTypeId.HYBRID,
zoom: 6,
heading: 90,
tilt: 0
});
// Load label.js afterwards so we can be sure that the google maps api has loaded
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", "js/label.js")
document.getElementsByTagName("head")[0].appendChild(fileref)
}
Run Code Online (Sandbox Code Playgroud)
这是解决这个问题的最佳方法吗?
Bullet在旧的OpenGL中有一个btIDebugDraw接口的实现,用于绘制物理世界以进行调试.界面是这样的:
class GLDebugDrawer : public btIDebugDraw
{
int m_debugMode;
public:
GLDebugDrawer();
virtual ~GLDebugDrawer();
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& fromColor, const btVector3& toColor);
virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color);
virtual void drawSphere (const btVector3& p, btScalar radius, const btVector3& color);
virtual void drawTriangle(const btVector3& a,const btVector3& b,const btVector3& c,const btVector3& color,btScalar alpha);
virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color);
virtual void reportErrorWarning(const char* warningString);
virtual void draw3dText(const btVector3& location,const char* textString); …Run Code Online (Sandbox Code Playgroud) 我想画一个单一的与下面的代码行,它的工作原理:
// Include standard headers
#include <stdio.h>
#include <stdlib.h>
// Include GLEW
#include <GL/glew.h>
// Include GLFW
#include <GL/glfw.h>
// Include GLM
#include <glm/glm.hpp>
using namespace glm;
// shaders
#include "shader.hpp"
int main( void )
{
// Initialise GLFW
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
return -1;
}
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Open a window and create its OpenGL context
if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) …Run Code Online (Sandbox Code Playgroud) 我正在使用工厂模式.它基本上允许类在编译时注册并存储在映射中.然后可以使用BaseFactory :: createInstance()返回一个实例
我不确定地图在编译时如何持有类名!如何在运行时有效的编译时分配内存?
在这种情况下,所有类都是从父类Bump_BaseObject派生的
//C++ STL used for adding Reflection
#include <string>
#include <map>
class Bump_BaseObject;
/**
* Derived Base objects creation factory
*/
template<typename T>
Bump_BaseObject* createT(void)
{
#pragma message("createT instantiated")
return new T();
}
struct BaseFactory {
typedef std::map<std::string, Bump_BaseObject*(*)()> map_type;
//return an instance of the class type 's'
static Bump_BaseObject* createInstance(const std::string& s) {
map_type::iterator it = getMap()->find(s);
if(it == getMap()->end())
return 0;
//this is where we instatiate and allocate memory for the object(it must NOT …Run Code Online (Sandbox Code Playgroud) 我自己编译了Boost并用它将以下函数导出到DLL:
#include <boost/python.hpp>
using namespace boost::python;
std::string greet()
{
return "hello, dude !!";
}
BOOST_PYTHON_MODULE(hello)
{
def("greet", greet);
}
Run Code Online (Sandbox Code Playgroud)
在我将hello.dll文件重命名为hello.pyd后,这在Python中加载正常.
现在我正在尝试这个:
#include <boost/python.hpp>
using namespace boost::python;
struct World
{
void set(std::string msg) { this->msg = msg; }
std::string greet() { return msg; }
std::string msg;
};
BOOST_PYTHON_MODULE(hello)
{
class_<World>("World")
.def("greet", &World::greet)
.def("set", &World::set);
}
Run Code Online (Sandbox Code Playgroud)
它出错了:
Error 29 error LNK2019: unresolved external symbol "__declspec(dllimport) void * __cdecl boost::python::objects::find_static_type(void *,struct boost::python::type_info,struct boost::python::type_info)" (__imp_?find_static_type@objects@python@boost@@YAPAXPAXUtype_info@23@1@Z) referenced in function "private: virtual void * __thiscall boost::python::objects::value_holder<struct …Run Code Online (Sandbox Code Playgroud) c++ ×2
opengl-3 ×2
boost ×1
boost-python ×1
factory ×1
google-maps ×1
javascript ×1
lua ×1
notepad++ ×1
python ×1
regex ×1
xml ×1