Skip to content
This repository was archived by the owner on Feb 28, 2022. It is now read-only.

[WIP] Small fixes for cpp #24

Open
wants to merge 2 commits into
base: azuredocs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ Shared/version
*.pdb
*.sln.docstates
**/Redis/dump.rdb

test/code2yaml.Tests/TestData/out/
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ public Task<PageModel> GenerateArticleAsync(BuildContext context, XDocument docu
{
string kind = section.NullableAttribute("kind").NullableValue();
var tuple = KindMapToType(kind);
if (tuple.Item1.HasValue && ((tuple.Item2 & AccessLevel.NotAccessible) == AccessLevel.None))
ConfigModel config = (ConfigModel) context.GetSharedObject(Constants.Config);
bool generate = config.GenerateDocForPrivateParts ||
((tuple.Item2 & AccessLevel.NotAccessible) == AccessLevel.None);

if (tuple.Item1.HasValue && generate)
{
foreach (var member in section.Elements("memberdef"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;

using GitSharp;
using Microsoft.Content.Build.Code2Yaml.Common;
using Microsoft.Content.Build.Code2Yaml.DataContracts;
using Microsoft.Content.Build.Code2Yaml.DeclarationGenerator;
using Microsoft.Content.Build.Code2Yaml.NameGenerator;
Expand Down
4 changes: 4 additions & 0 deletions src/Microsoft.Content.Build.Code2Yaml.Constants/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public static class Constants
public const string CmdArgLanguage = "lang:";
public const string Dot = ".";

public const string GeneratePrivate = "generate_private";

public static class YamlMime
{
public const string YamlMimePrefix = "### YamlMime:";
Expand All @@ -54,5 +56,7 @@ public static class ServiceMappingConfig
public const string Service = "service";
public const string Category = "category";
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class ConfigModel
[JsonProperty(Constants.GenerateTocMDFile)]
public bool GenerateTocMDFile { get; set; } = false;

[JsonProperty(Constants.GeneratePrivate)]
public bool GenerateDocForPrivateParts { get; set; } = false;

[JsonProperty(Constants.ExcludePaths)]
public List<string> ExcludePaths { get; set; }

Expand Down
14 changes: 13 additions & 1 deletion src/Microsoft.Content.Build.Code2Yaml.Utility/YamlUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ public static string ParseNameFromFullName(HierarchyType htype, string wrapperNa
{
return fullName;
}
return fullName.Substring(wrapperName.Length + spliter.Length);

string res = "";
if (fullName.Contains(spliter))
{
res = fullName.Substring(wrapperName.Length + spliter.Length);
}
else if(fullName.Contains(Constants.Dot))
{
spliter = Constants.Dot;
res = fullName.Substring(wrapperName.Length + spliter.Length);
}

return res;
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/code2yaml/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"code2yaml": {
"commandName": "Project",
"workingDirectory": "P:\\csharp\\code2yaml\\test\\code2yaml.Tests\\TestData"
}
}
}
2 changes: 2 additions & 0 deletions test/code2yaml.Tests/TestData/SHObject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "shpch.h"
#include "SHObject.h"
59 changes: 59 additions & 0 deletions test/code2yaml.Tests/TestData/SHObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#pragma once
#include "shpch.h"

namespace ShadowEngine {

/**
* \brief This is the base class for every class in the Engine that uses runtime reflection.

* Currently it provides a runtime TypeID and TypeName witch can be accesed as static and as class memebers.
* The ID is a int type number witch is generated incramently, on the first call to get a type.

* Each class that inherits from this or it's parent inheris form it must implement the
SHObject::GetType and SHObject::GetTypeId methodes and make it's own static methodes.
To make it easier a standard implementation of these can be used with the SHObject_Base() macro
witch implements all of these functions. It uses the typeid().name of the class.

*/
class SHObject
{
protected:
/**
* \brief Generates a new UID for each call
* \return the next Unique ID that was just generated
*/
static uint64_t GenerateId() noexcept
{
static uint64_t count = 0;
return ++count;
}

public:
/**
* \brief Returns the top level class type name of the object
* \return The class Class name as a string
*/
virtual const std::string& GetType() const = 0;
/**
* \brief Gets the top level type ID
* \return UID of the class
*/
virtual const uint64_t GetTypeId() const = 0;

virtual ~SHObject() = default;
};


/**
* \brief Macro to make the override functions of SHObject. This should be added in each derived class
* \param type The type of the class
*/
#define SHObject_Base(type) \
public: \
static const std::string& Type() { static const std::string t = typeid(type).name(); return t; } \
static uint64_t TypeId() { static const uint64_t id = GenerateId(); return id; } \
const std::string& GetType() const override { return Type(); } \
const uint64_t GetTypeId() const override { return type::TypeId(); } \
private:

}
29 changes: 29 additions & 0 deletions test/code2yaml.Tests/TestData/Scene.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "shpch.h"
#include "Scene.h"

namespace ShadowEngine::EntitySystem {

void EntitySystem::Scene::Start()
{
for (auto& entity : m_entities)
{
//entity->Start();
}
}

void Scene::Update()
{
for (auto& entity : m_entities)
{
//entity->Update(dt);
}
}

void Scene::Init() {

for (auto& entity : m_entities)
{
//entity->Init();
}
}
}
75 changes: 75 additions & 0 deletions test/code2yaml.Tests/TestData/Scene.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#pragma once
#include <memory>

#include "Core/SHObject.h"
#include "Entity.h"
#include "EntityManager.h"
#include "ShadowMath/Transform.h"

class Camera;

namespace ShadowEngine::EntitySystem {

/// <summary>
/// Represents a scene, that is composed of Entities.
///
/// </summary>
class Scene : public SHObject, public std::enable_shared_from_this<Scene>
{
SHObject_Base(Scene)

public:

/// <summary>
/// Represents the Entities in this Scene
/// </summary>
/// This is a list of all the top level Entities that are in this Scene
/// To add to the list use <see cref="AddEntity"/>
std::list<rtm_ptr<Entity>> m_entities;

ShadowEntity::Transform centerTransform;

//Main Camera ref
Camera* mainCamera;

Scene() : mainCamera(nullptr) {

}
virtual ~Scene() = default;


virtual void Init();


virtual void Start();
virtual void Update();

template<class T, class ...ARGS>
rtm_ptr<T> AddEntity(ARGS&&... args) {
rtm_ptr<T> ptr = EntityManager::Instance->AddEntity<T>(std::forward<ARGS>(args)...);
ptr->scene = this;
ptr->Build();
m_entities.push_back(ptr);

return ptr;
}

template<class T>
void DestroyEntity(rtm_ptr<T>& entity) {
EntityManager::Instance->RemoveEntity<T>(entity);
m_entities.remove(entity);
}

void DestroyScene() {
for each (auto var in m_entities)
{
EntityManager::Instance->RemoveEntity(var);
}
}

ShadowEntity::Transform* GetCenter() {
return &centerTransform;
}
};

}
7 changes: 7 additions & 0 deletions test/code2yaml.Tests/TestData/code2yaml.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"input_paths": [ "./" ],
"output_path": "./out",
"exclude_paths": [ "./azure-sdk-for-java/azure-samples" ],
"language": "cplusplus",
"generate_private": "true"
}
107 changes: 0 additions & 107 deletions test/code2yaml.Tests/TestData/test.java

This file was deleted.

11 changes: 0 additions & 11 deletions test/code2yaml.Tests/TestData/testDuplicate.java

This file was deleted.